Class IndexBuildState


  • @API(UNSTABLE)
    public class IndexBuildState
    extends Object
    A class that contains the build progress of a given index in a given record store.

    It first contains IndexState. If the state is IndexState.WRITE_ONLY, it will also contain the number of records scanned and the estimated total number of records that need to be scanned.

    Note that index build state (especially records scanned) serves an informational purpose only as the number of records scanned is not necessarily 100% of records in total when the index build completes for several reasons:

    • If the OnlineIndexer has been configured to disable tracking progress (by setting OnlineIndexer.Builder.setTrackProgress(boolean) to false), then getRecordsScanned() will not include the records scanned by that OnlineIndexer.
    • Records added or deleted during the index build progress are not included in records scanned but are in records in total.
    • Records in total uses the number of all records in the store. In some cases, the real number of records that need to be scanned is less than this.
    See Also:
    loadIndexBuildStateAsync(FDBRecordStoreBase, Index)
    • Method Detail

      • loadIndexBuildStateAsync

        @Nonnull
        public static CompletableFuture<IndexBuildState> loadIndexBuildStateAsync​(FDBRecordStoreBase<?> store,
                                                                                  Index index)
        Load the build progress (IndexBuildState) of the given index in the given record store asynchronously.
        Parameters:
        store - the record store containing the index
        index - the index needed to be checked
        Returns:
        a future that completes to the index build state
      • loadRecordsScannedAsync

        @Nonnull
        public static CompletableFuture<Long> loadRecordsScannedAsync​(FDBRecordStoreBase<?> store,
                                                                      Index index)
        Load the number of records successfully scanned and processed during the online index build process asynchronously.

        If the OnlineIndexer has been configured to disable tracking progress (by setting OnlineIndexer.Builder.setTrackProgress(boolean) to false), then the number returned will not include the records scanned by that OnlineIndexer.

        Parameters:
        store - the record store containing the index
        index - the index needed to be checked
        Returns:
        a future that completes to the total records scanned
      • getIndexState

        @Nonnull
        public IndexState getIndexState()
        Get the index state.
        Returns:
        the index state
      • getRecordsInTotal

        @Nullable
        public Long getRecordsInTotal()
        Get the estimated total number of records that need to be scanned to build the index. Currently, it uses the number of all records in the store. In some cases, the real number of records that need to be scanned is less than this.

        To get the count, there must be a suitably grouped COUNT type index defined. Otherwise, it returns null.

        The returned value should be ignored if the index state is not IndexState.WRITE_ONLY.

        Returns:
        the number of total records
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object