org.hibernate.search.impl
Class MassIndexerImpl

java.lang.Object
  extended by org.hibernate.search.impl.MassIndexerImpl
All Implemented Interfaces:
MassIndexer

public class MassIndexerImpl
extends java.lang.Object
implements MassIndexer

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
protected  java.util.Set<java.lang.Class<?>> rootEntities
           
 
Constructor Summary
protected MassIndexerImpl(SearchFactoryImplementor searchFactory, org.hibernate.SessionFactory sessionFactory, java.lang.Class<?>... entities)
           
 
Method Summary
 MassIndexer batchSizeToLoadObjects(int batchSize)
          Sets the batch size used to load the root entities.
 MassIndexer cacheMode(org.hibernate.CacheMode cacheMode)
          Sets the cache interaction mode for the data loading tasks.
protected  BatchCoordinator createCoordinator()
           
 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 purgeAllOnStart(boolean purgeAll)
          If all entities should be removed from the index before starting using purgeAll.
 java.util.concurrent.Future<?> start()
          Starts the indexing process in background (asynchronous).
 void startAndWait()
          Starts the indexing process, and then block until it's finished.
 MassIndexer threadsForSubsequentFetching(int numberOfThreads)
          Sets the number of threads used to load the lazy collections related to the indexed entities.
 MassIndexer threadsToLoadObjects(int numberOfThreads)
          Set the number of threads to be used to load the root entities.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootEntities

protected java.util.Set<java.lang.Class<?>> rootEntities
Constructor Detail

MassIndexerImpl

protected MassIndexerImpl(SearchFactoryImplementor searchFactory,
                          org.hibernate.SessionFactory sessionFactory,
                          java.lang.Class<?>... entities)
Method Detail

cacheMode

public MassIndexer cacheMode(org.hibernate.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
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
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
Returns:
this for method chaining

threadsForSubsequentFetching

public MassIndexer threadsForSubsequentFetching(int numberOfThreads)
Description copied from interface: MassIndexer
Sets the number of threads used to load the lazy collections related to the indexed entities.

Specified by:
threadsForSubsequentFetching in interface MassIndexer
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
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
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
Returns:
this for method chaining

start

public java.util.concurrent.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 task canceling. get() will block until completion. cancel() is currently not implemented.

startAndWait

public void startAndWait()
                  throws java.lang.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:
java.lang.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
Returns:


Copyright © 2006-2010 Hibernate. All Rights Reserved.