Class ChangeIndexer

java.lang.Object
com.google.gerrit.server.index.change.ChangeIndexer

public class ChangeIndexer extends Object
Helper for (re)indexing a change document.

Indexing is run in the background, as it may require substantial work to compute some of the fields and/or update the index.

  • Method Details

    • indexAsync

      public com.google.common.util.concurrent.ListenableFuture<ChangeData> indexAsync(Project.NameKey project, Change.Id changeId)
      Start indexing a change.
      Parameters:
      changeId - change to index.
      Returns:
      future for the indexing task.
    • index

      public void index(ChangeData cd)
      Synchronously index a local or imported change, then check if the index is stale due to a race condition.
      Parameters:
      cd - change to index.
    • index

      @Deprecated public void index(Change change)
      Deprecated.
      callers should use index(com.google.gerrit.entities.Project.NameKey, com.google.gerrit.entities.Change.Id) which reloads the full change details, including the associated serverId.
      Synchronously index local a change.
      Parameters:
      change - change to index.
    • index

      public void index(ChangeNotes notes)
      Synchronously index a local or imported change with associated notes.
      Parameters:
      notes - change notes associated with the change to index.
    • index

      public void index(Project.NameKey project, Change.Id changeId)
      Synchronously index a local or imported change.

      Load the change full details from NoteDb and update the corresponding entry in the index.

      Parameters:
      project - the project to which the change belongs.
      changeId - ID of the change to index.
    • deleteAsync

      public com.google.common.util.concurrent.ListenableFuture<ChangeData> deleteAsync(Project.NameKey project, Change.Id id)
      Start deleting a change.
      Parameters:
      id - change to delete.
      Returns:
      future for the deleting task, the result of the future is always null
    • delete

      public void delete(Change.Id id)
      Synchronously delete a change.
      Parameters:
      id - change ID to delete.
    • asyncReindexIfStale

      public com.google.common.util.concurrent.ListenableFuture<Boolean> asyncReindexIfStale(Project.NameKey project, Change.Id id)
      Asynchronously check if a change is stale, and reindex if it is.

      Always run on the batch executor, even if this indexer instance is configured to use a different executor.

      Parameters:
      project - the project to which the change belongs.
      id - ID of the change to index.
      Returns:
      future for reindexing the change; returns true if the change was stale.
    • reindexIfStale

      public boolean reindexIfStale(ChangeData cd)
      Synchronously check if a change is stale, and reindex if it is.
      Parameters:
      cd - the change data to be checked for staleness.
      Returns:
      true if the change was stale, false if it was up-to-date
    • reindexIfStale

      public boolean reindexIfStale(Project.NameKey project, Change.Id id)
      Synchronously check if a change is stale, and reindex if it is.
      Parameters:
      project - the project to which the change belongs.
      id - ID of the change to index.
      Returns:
      true if the change was stale, false if it was up-to-date