protected boolean shouldCommit()

in encryption/src/main/java/org/apache/solr/encryption/EncryptionUpdateHandler.java [57:81]


  protected boolean shouldCommit(CommitUpdateCommand cmd, IndexWriter writer) throws IOException {
    if (!super.shouldCommit(cmd, writer)) {
      return false;
    }
    // Two cases:
    // - If cmd.commitData is null, then transfer all the latest commit transferable
    //   data to the current commit.
    // - If cmd.commitData is not null, nothing is transferred. It is the caller
    //   responsibility to include all the required user data from the latest commit.
    //   That way, the caller can remove some entries.
    if (cmd.commitData == null) {
      Map<String, String> latestCommitData = readLatestCommit(core).getUserData();
      Map<String, String> commitData = null;
      for (Map.Entry<String, String> latestCommitEntry : latestCommitData.entrySet()) {
        if (latestCommitEntry.getKey().startsWith(TRANSFERABLE_COMMIT_DATA)) {
          if (commitData == null) {
            commitData = new HashMap<>();
          }
          commitData.put(latestCommitEntry.getKey(), latestCommitEntry.getValue());
        }
      }
      cmd.commitData = commitData;
    }
    return true;
  }