org.hibernate.search.indexes.impl
Class DirectoryBasedIndexManager

java.lang.Object
  extended by org.hibernate.search.indexes.impl.DirectoryBasedIndexManager
All Implemented Interfaces:
IndexManager
Direct Known Subclasses:
NRTIndexManager

public class DirectoryBasedIndexManager
extends Object
implements IndexManager

This implementation of IndexManager is coupled to a DirectoryProvider and a DirectoryBasedReaderProvider

Author:
Sanne Grinovero (C) 2011 Red Hat Inc.

Constructor Summary
DirectoryBasedIndexManager()
           
 
Method Summary
 void addContainedEntity(Class<?> entity)
           
protected  BackendQueueProcessor createBackend(String indexName, Properties cfg, WorkerBuildContext buildContext)
          extensions points from initialize(String, Properties, WorkerBuildContext)
protected  DirectoryProvider createDirectoryProvider(String indexName, Properties cfg, WorkerBuildContext buildContext)
           
protected  DirectoryBasedReaderProvider createIndexReader(String indexName, Properties cfg, WorkerBuildContext buildContext)
           
 void destroy()
          Called when a SearchFactory is stopped.
 org.apache.lucene.analysis.Analyzer getAnalyzer(String name)
           
 BackendQueueProcessor getBackendQueueProcessor()
           
 Set<Class<?>> getContainedTypes()
           
 Lock getDirectoryModificationLock()
           
 DirectoryProvider getDirectoryProvider()
           
 EntityIndexBinder getIndexBindingForEntity(Class<?> entityType)
           
 LuceneIndexingParameters getIndexingParameters()
           
 String getIndexName()
          Useful for labeling and logging resources from this instance.
 OptimizerStrategy getOptimizerStrategy()
           
 ReaderProvider getReaderProvider()
          Provide access to IndexReaders.
 LuceneWorkSerializer getSerializer()
           
 org.apache.lucene.search.Similarity getSimilarity()
           
 void initialize(String indexName, Properties cfg, WorkerBuildContext buildContext)
          Initialize the IndexManager before its use.
 void optimize()
          To optimize the underlying index.
 void performOperations(List<LuceneWork> workList, IndexingMonitor monitor)
          Used to apply update operations to the index.
 void performStreamOperation(LuceneWork singleOperation, IndexingMonitor monitor, boolean forceAsync)
          Perform a single non-transactional operation, best to stream large amounts of operations.
 void setIndexWriterConfig(org.apache.lucene.index.IndexWriterConfig writerConfig)
           
 void setSearchFactory(SearchFactoryImplementor boundSearchFactory)
          Connects this IndexManager to a new SearchFactory.
 void setSimilarity(org.apache.lucene.search.Similarity newSimilarity)
          Not intended to be a mutable option, but the Similarity might be defined later in the boot lifecycle.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectoryBasedIndexManager

public DirectoryBasedIndexManager()
Method Detail

getIndexName

public String getIndexName()
Description copied from interface: IndexManager
Useful for labeling and logging resources from this instance.

Specified by:
getIndexName in interface IndexManager
Returns:
the name of the index maintained by this manager.

getReaderProvider

public ReaderProvider getReaderProvider()
Description copied from interface: IndexManager
Provide access to IndexReaders.

Specified by:
getReaderProvider in interface IndexManager
Returns:
a ReaderProvider instance for the index managed by this instance

destroy

public void destroy()
Description copied from interface: IndexManager
Called when a SearchFactory is stopped. This method typically releases resources.

Specified by:
destroy in interface IndexManager

initialize

public void initialize(String indexName,
                       Properties cfg,
                       WorkerBuildContext buildContext)
Description copied from interface: IndexManager
Initialize the IndexManager before its use.

Specified by:
initialize in interface IndexManager
Parameters:
indexName - The unique name of the index (manager). Can be used to retrieve a IndexManager instance via the search factory and IndexManagerHolder.
cfg - The configuration properties
buildContext - context information needed to initialize this index manager

getContainedTypes

public Set<Class<?>> getContainedTypes()
Specified by:
getContainedTypes in interface IndexManager
Returns:
the set of classes being indexed in this manager

getSimilarity

public org.apache.lucene.search.Similarity getSimilarity()
Specified by:
getSimilarity in interface IndexManager
Returns:
the Similarity applied to this index. Note, only a single Similarity can be applied to a given index.

setSimilarity

public void setSimilarity(org.apache.lucene.search.Similarity newSimilarity)
Description copied from interface: IndexManager
Not intended to be a mutable option, but the Similarity might be defined later in the boot lifecycle.

Specified by:
setSimilarity in interface IndexManager
Parameters:
newSimilarity - the new similarity value

performStreamOperation

public void performStreamOperation(LuceneWork singleOperation,
                                   IndexingMonitor monitor,
                                   boolean forceAsync)
Description copied from interface: IndexManager
Perform a single non-transactional operation, best to stream large amounts of operations. Operations might be applied out-of-order! To mark two series of operations which need to be applied in order, use a transactional operation between them: a transactional operation will always flush all streaming operations first, and be applied before subsequent streaming operations.

Specified by:
performStreamOperation in interface IndexManager
Parameters:
singleOperation - the operation to perform
monitor - no be notified of indexing events
forceAsync - if true, the invocation will not block to wait for it being applied. When false this will depend on the backend configuration.

performOperations

public void performOperations(List<LuceneWork> workList,
                              IndexingMonitor monitor)
Description copied from interface: IndexManager
Used to apply update operations to the index. Operations can be applied in sync or async, depending on the IndexManager implementation and configuration.

Specified by:
performOperations in interface IndexManager
Parameters:
workList - the list of write operations to apply.
monitor - no be notified of indexing events

toString

public String toString()
Overrides:
toString in class Object

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer(String name)
Specified by:
getAnalyzer in interface IndexManager
Parameters:
name - the name of the analyzer to retrieve.
Returns:
Returns the Analyzer with the given name (see also AnalyzerDef)

setSearchFactory

public void setSearchFactory(SearchFactoryImplementor boundSearchFactory)
Description copied from interface: IndexManager
Connects this IndexManager to a new SearchFactory.

Specified by:
setSearchFactory in interface IndexManager
Parameters:
boundSearchFactory - the existing search factory to which to associate this index manager with

addContainedEntity

public void addContainedEntity(Class<?> entity)
Specified by:
addContainedEntity in interface IndexManager
Parameters:
entity - Adds the specified entity type to this index manager, making it responsible for manging this type.

optimize

public void optimize()
Description copied from interface: IndexManager
To optimize the underlying index. Some implementations might ignore the request, if it doesn't apply to them.

Specified by:
optimize in interface IndexManager

getBackendQueueProcessor

public BackendQueueProcessor getBackendQueueProcessor()

setIndexWriterConfig

public void setIndexWriterConfig(org.apache.lucene.index.IndexWriterConfig writerConfig)

getIndexBindingForEntity

public EntityIndexBinder getIndexBindingForEntity(Class<?> entityType)

getDirectoryModificationLock

public Lock getDirectoryModificationLock()

getDirectoryProvider

public DirectoryProvider getDirectoryProvider()

getOptimizerStrategy

public OptimizerStrategy getOptimizerStrategy()

getIndexingParameters

public LuceneIndexingParameters getIndexingParameters()

getSerializer

public LuceneWorkSerializer getSerializer()
Specified by:
getSerializer in interface IndexManager
Returns:
the Serializer implementation used for this IndexManager

createBackend

protected BackendQueueProcessor createBackend(String indexName,
                                              Properties cfg,
                                              WorkerBuildContext buildContext)
extensions points from initialize(String, Properties, WorkerBuildContext)


createIndexReader

protected DirectoryBasedReaderProvider createIndexReader(String indexName,
                                                         Properties cfg,
                                                         WorkerBuildContext buildContext)

createDirectoryProvider

protected DirectoryProvider createDirectoryProvider(String indexName,
                                                    Properties cfg,
                                                    WorkerBuildContext buildContext)


Copyright © 2006-2012 Red Hat Middleware, LLC. All Rights Reserved