code: private void setLastApplied(long lastApplied) {
      // lastApplied should be either equal to or one greater than this.lastApplied.
      if (lastApplied > this.lastApplied) {
        Assert.arg(lastApplied == this.lastApplied + 1, "lastApplied must be sequential");
  
        this.lastApplied = lastApplied;
  
        // Update the index for each session. This will be used to trigger queries that are awaiting the
        // application of specific indexes to the state machine. Setting the session index may cause query
        // callbacks to be called and queries to be evaluated.
        for (ServerSessionContext session : executor.context().sessions().sessions.values()) {
          session.setLastApplied(lastApplied);
        }
  
        // Take a state machine snapshot if necessary.
        takeSnapshot();
  
        // Install a state machine snapshot if necessary.
        installSnapshot();
      } else {
        Assert.arg(lastApplied == this.lastApplied, "lastApplied cannot be decreased");
      }
    }
docs: Sets the last applied index.
  <p>
  The last applied index is updated *after* each time a non-query entry is applied to the state machine.
  
  @param lastApplied The last applied index.