org.hibernate.search.backend.impl.lucene
Class AbstractWorkspaceImpl

java.lang.Object
  extended by org.hibernate.search.backend.impl.lucene.AbstractWorkspaceImpl
All Implemented Interfaces:
Workspace
Direct Known Subclasses:
ExclusiveIndexWorkspaceImpl, NRTWorkspaceImpl, SharedIndexWorkspaceImpl

public abstract class AbstractWorkspaceImpl
extends Object
implements Workspace

Lucene workspace for an IndexManager

Author:
Emmanuel Bernard, Hardy Ferentschik, Sanne Grinovero

Field Summary
protected  org.hibernate.search.backend.impl.lucene.IndexWriterHolder writerHolder
           
 
Constructor Summary
AbstractWorkspaceImpl(DirectoryBasedIndexManager indexManager, WorkerBuildContext context, Properties cfg)
           
 
Method Summary
abstract  void afterTransactionApplied(boolean someFailureHappened, boolean streaming)
          Invoked after all changes of a transaction are applied.
 boolean areSingleTermDeletesSafe()
          Return true if it's safe to perform index delete operations using only the identifier term.
 org.apache.lucene.analysis.Analyzer getAnalyzer(String name)
           
<T> DocumentBuilderIndexedEntity<?>
getDocumentBuilder(Class<T> entity)
           
 Set<Class<?>> getEntitiesInIndexManager()
           
 org.apache.lucene.index.IndexWriter getIndexWriter()
          Gets the IndexWriter, opening one if needed.
 org.apache.lucene.index.IndexWriter getIndexWriter(ErrorContextBuilder errorContextBuilder)
           
 void incrementModificationCounter(int modCount)
          Increment the counter of modification operations done on the index.
 void optimizerPhase()
          If optimization has not been forced give a chance to configured OptimizerStrategy to optimize the index.
 void performOptimization(org.apache.lucene.index.IndexWriter writer)
          Used by OptimizeLuceneWork to start an optimization process of the index.
 void shutDownNow()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hibernate.search.store.Workspace
flush
 

Field Detail

writerHolder

protected final org.hibernate.search.backend.impl.lucene.IndexWriterHolder writerHolder
Constructor Detail

AbstractWorkspaceImpl

public AbstractWorkspaceImpl(DirectoryBasedIndexManager indexManager,
                             WorkerBuildContext context,
                             Properties cfg)
Method Detail

getDocumentBuilder

public <T> DocumentBuilderIndexedEntity<?> getDocumentBuilder(Class<T> entity)
Specified by:
getDocumentBuilder in interface Workspace

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer(String name)
Specified by:
getAnalyzer in interface Workspace

optimizerPhase

public void optimizerPhase()
Description copied from interface: Workspace
If optimization has not been forced give a chance to configured OptimizerStrategy to optimize the index.

Specified by:
optimizerPhase in interface Workspace

performOptimization

public void performOptimization(org.apache.lucene.index.IndexWriter writer)
Description copied from interface: Workspace
Used by OptimizeLuceneWork to start an optimization process of the index.

Specified by:
performOptimization in interface Workspace
Parameters:
writer - the IndexWriter to use for optimization
See Also:
OptimizeLuceneWork, SearchFactory.optimize(), SearchFactory.optimize(Class)

incrementModificationCounter

public void incrementModificationCounter(int modCount)
Description copied from interface: Workspace
Increment the counter of modification operations done on the index. Used (currently only) by the OptimizerStrategy.

Specified by:
incrementModificationCounter in interface Workspace
Parameters:
modCount - the increment to add to the counter.

getEntitiesInIndexManager

public Set<Class<?>> getEntitiesInIndexManager()
Specified by:
getEntitiesInIndexManager in interface Workspace
Returns:
The unmodifiable set of entity types being indexed in the underlying IndexManager backing this Workspace.

afterTransactionApplied

public abstract void afterTransactionApplied(boolean someFailureHappened,
                                             boolean streaming)
Description copied from interface: Workspace
Invoked after all changes of a transaction are applied. Must be invoked strictly once after every Workspace.getIndexWriter() in a finally block as implementations might rely on counters to release the IndexWriter.

Specified by:
afterTransactionApplied in interface Workspace
Parameters:
someFailureHappened - usually false, set to true if errors where caught while using the IndexWriter
streaming - if no immediate visibility of the change is required (hint for performance)

shutDownNow

public void shutDownNow()

getIndexWriter

public org.apache.lucene.index.IndexWriter getIndexWriter()
Description copied from interface: Workspace
Gets the IndexWriter, opening one if needed.

Specified by:
getIndexWriter in interface Workspace
Returns:
a new IndexWriter or an already open one, or null if an error happened.

getIndexWriter

public org.apache.lucene.index.IndexWriter getIndexWriter(ErrorContextBuilder errorContextBuilder)

areSingleTermDeletesSafe

public boolean areSingleTermDeletesSafe()
Description copied from interface: Workspace
Return true if it's safe to perform index delete operations using only the identifier term. This can be more efficient but can not work if there are multiple indexed types in the same index possibly sharing the same id term, or if the index might contain entity types we don't know.

Specified by:
areSingleTermDeletesSafe in interface Workspace
Returns:
true if it's safe to do the single term operation.


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