Class 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 Detail

      • 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

        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.
      • reindexIfStale

        public com.google.common.util.concurrent.ListenableFuture<Boolean> reindexIfStale​(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.