org.hibernate.search.batchindexing.impl

## Class MassIndexerImpl

- java.lang.Object
- - org.hibernate.search.batchindexing.impl.MassIndexerImpl

- All Implemented Interfaces:
    MassIndexerWithTenant, MassIndexer

      public class MassIndexerImpl
      extends Object
      implements MassIndexerWithTenant

  Prepares and configures a BatchIndexingWorkspace to start rebuilding the indexes for all entity instances in the database. The type of these entities is either all indexed entities or a subset, always including all subtypes.
  Author:
    Sanne Grinovero

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected IndexedTypeSet` | `rootEntities`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `MassIndexerImpl(SearchIntegrator searchIntegrator, SessionFactoryImplementor sessionFactory, Class<?>... entities)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `MassIndexer` | `batchSizeToLoadObjects(int batchSize)` Sets the batch size used to load the root entities.
    `MassIndexer` | `cacheMode(CacheMode cacheMode)` Sets the cache interaction mode for the data loading tasks.
    `protected BatchCoordinator` | `createCoordinator()`
    `MassIndexer` | `idFetchSize(int idFetchSize)` Specifies the fetch size to be used when loading primary keys if objects to be indexed.
    `MassIndexer` | `limitIndexedObjectsTo(long maximum)` EXPERIMENTAL method: will probably change Will stop indexing after having indexed a set amount of objects.
    `MassIndexer` | `optimizeAfterPurge(boolean optimize)` If index optimization should be run before starting, after the purgeAll.
    `MassIndexer` | `optimizeOnFinish(boolean optimize)` If index optimization has to be started at the end of the indexing process.
    `MassIndexer` | `progressMonitor(MassIndexerProgressMonitor monitor)` Override the default `MassIndexerProgressMonitor`.
    `MassIndexer` | `purgeAllOnStart(boolean purgeAll)` If all entities should be removed from the index before starting using purgeAll.
    `Future<?>` | `start()` Starts the indexing process in background (asynchronous).
    `void` | `startAndWait()` Starts the indexing process, and then block until it's finished.
    `MassIndexerWithTenant` | `tenantIdentifier(String tenantIdentifier)` Set the tenant that is associated to this `MassIndexer`.
    `MassIndexer` | `threadsForSubsequentFetching(int numberOfThreads)` Deprecated.
    `MassIndexer` | `threadsToLoadObjects(int numberOfThreads)` Set the number of threads to be used to load the root entities.
    `MassIndexer` | `transactionTimeout(int timeoutInSeconds)` Timeout of transactions for loading ids and entities to be re-indexed.
    `MassIndexer` | `typesToIndexInParallel(int numberOfThreads)` Sets the number of entity types to be indexed in parallel.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### rootEntities

          protected final IndexedTypeSet rootEntities

  - ### Constructor Detail

    - #### MassIndexerImpl

          protected MassIndexerImpl(SearchIntegrator searchIntegrator,
                                    SessionFactoryImplementor sessionFactory,
                                    Class<?>... entities)

  - ### Method Detail

    - #### typesToIndexInParallel

          public MassIndexer typesToIndexInParallel(int numberOfThreads)

      Description copied from interface: `MassIndexer`
      Sets the number of entity types to be indexed in parallel. Defaults to 1.
      Specified by:
        `typesToIndexInParallel` in interface `MassIndexer`
      Parameters:
        `numberOfThreads` - number of entity types to be indexed in parallel
      Returns:
        `this` for method chaining

    - #### cacheMode

          public MassIndexer cacheMode(CacheMode cacheMode)

      Description copied from interface: `MassIndexer`
      Sets the cache interaction mode for the data loading tasks. Defaults to `CacheMode.IGNORE`.
      Specified by:
        `cacheMode` in interface `MassIndexer`
      Parameters:
        `cacheMode` - the cache interaction mode
      Returns:
        `this` for method chaining

    - #### threadsToLoadObjects

          public MassIndexer threadsToLoadObjects(int numberOfThreads)

      Description copied from interface: `MassIndexer`
      Set the number of threads to be used to load the root entities.
      Specified by:
        `threadsToLoadObjects` in interface `MassIndexer`
      Parameters:
        `numberOfThreads` - the number of threads
      Returns:
        `this` for method chaining

    - #### batchSizeToLoadObjects

          public MassIndexer batchSizeToLoadObjects(int batchSize)

      Description copied from interface: `MassIndexer`
      Sets the batch size used to load the root entities.
      Specified by:
        `batchSizeToLoadObjects` in interface `MassIndexer`
      Parameters:
        `batchSize` - the batch size
      Returns:
        `this` for method chaining

    - #### threadsForSubsequentFetching

          @Deprecated
          public MassIndexer threadsForSubsequentFetching(int numberOfThreads)

      Deprecated.
      Description copied from interface: `MassIndexer`
      Deprecated: value is ignored.
      Specified by:
        `threadsForSubsequentFetching` in interface `MassIndexer`
      Parameters:
        `numberOfThreads` - the number of threads
      Returns:
        `this` for method chaining

    - #### progressMonitor

          public MassIndexer progressMonitor(MassIndexerProgressMonitor monitor)

      Description copied from interface: `MassIndexer`
      Override the default `MassIndexerProgressMonitor`.
      Specified by:
        `progressMonitor` in interface `MassIndexer`
      Parameters:
        `monitor` - this instance will receive updates about the massindexing progress.
      Returns:
        `this` for method chaining

    - #### optimizeOnFinish

          public MassIndexer optimizeOnFinish(boolean optimize)

      Description copied from interface: `MassIndexer`
      If index optimization has to be started at the end of the indexing process. Defaults to `true`.
      Specified by:
        `optimizeOnFinish` in interface `MassIndexer`
      Parameters:
        `optimize` - `true` to enable the index optimization at the end of the indexing process
      Returns:
        `this` for method chaining

    - #### optimizeAfterPurge

          public MassIndexer optimizeAfterPurge(boolean optimize)

      Description copied from interface: `MassIndexer`
      If index optimization should be run before starting, after the purgeAll. Has no effect if `purgeAll` is set to false. Defaults to `true`.
      Specified by:
        `optimizeAfterPurge` in interface `MassIndexer`
      Parameters:
        `optimize` - `true` to enable the index optimization after purge
      Returns:
        `this` for method chaining

    - #### purgeAllOnStart

          public MassIndexer purgeAllOnStart(boolean purgeAll)

      Description copied from interface: `MassIndexer`
      If all entities should be removed from the index before starting using purgeAll. Set it to false only if you know there are no entities in the index: otherwise search results may be duplicated. Defaults to true.
      Specified by:
        `purgeAllOnStart` in interface `MassIndexer`
      Parameters:
        `purgeAll` - if `true` all entities will be removed from the index before starting the indexing
      Returns:
        `this` for method chaining

    - #### transactionTimeout

          public MassIndexer transactionTimeout(int timeoutInSeconds)

      Description copied from interface: `MassIndexer`
      Timeout of transactions for loading ids and entities to be re-indexed. Specify a timeout which is long enough to load and index all entities of the type with the most instances, taking into account the configured batch size and number of threads to load objects.

      Only supported in JTA-compatible environments.

      Specified by:
        `transactionTimeout` in interface `MassIndexer`
      Parameters:
        `timeoutInSeconds` - the transaction timeout in seconds; If no value is given, the global default timeout of the JTA environment applies.
      Returns:
        `this` for method chaining

    - #### tenantIdentifier

          public MassIndexerWithTenant tenantIdentifier(String tenantIdentifier)

      Description copied from interface: `MassIndexerWithTenant`
      Set the tenant that is associated to this `MassIndexer`.
      Specified by:
        `tenantIdentifier` in interface `MassIndexerWithTenant`
      Parameters:
        `tenantIdentifier` - the identifier of the tenant associated this `MassIndexer`
      Returns:
        `this` for method chaining

    - #### start

          public Future<?> start()

      Description copied from interface: `MassIndexer`
      Starts the indexing process in background (asynchronous). Can be called only once.
      Specified by:
        `start` in interface `MassIndexer`
      Returns:
        a Future to control the indexing task.

    - #### startAndWait

          public void startAndWait()
                            throws InterruptedException

      Description copied from interface: `MassIndexer`
      Starts the indexing process, and then block until it's finished. Can be called only once.
      Specified by:
        `startAndWait` in interface `MassIndexer`
      Throws:
        `InterruptedException` - if the current thread is interrupted while waiting.

    - #### createCoordinator

          protected BatchCoordinator createCoordinator()

    - #### limitIndexedObjectsTo

          public MassIndexer limitIndexedObjectsTo(long maximum)

      Description copied from interface: `MassIndexer`
      EXPERIMENTAL method: will probably change Will stop indexing after having indexed a set amount of objects. As a results the index will not be consistent with the database: use only for testing on an (undefined) subset of database data.
      Specified by:
        `limitIndexedObjectsTo` in interface `MassIndexer`
      Parameters:
        `maximum` - the maximum number of objects to index
      Returns:
        `this` for method chaining

    - #### idFetchSize

          public MassIndexer idFetchSize(int idFetchSize)

      Description copied from interface: `MassIndexer`
      Specifies the fetch size to be used when loading primary keys if objects to be indexed. Some databases accept special values, for example MySQL might benefit from using `Integer.MIN_VALUE` otherwise it will attempt to preload everything in memory.
      Specified by:
        `idFetchSize` in interface `MassIndexer`
      Parameters:
        `idFetchSize` - the fetch size to be used when loading primary keys
      Returns:
        `this` for method chaining

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved