Class Workspace

java.lang.Object
org.hibernate.search.backend.Workspace

public class Workspace extends Object
Lucene workspace for a DirectoryProvider.

Before using getIndexWriter(boolean, org.hibernate.search.exception.impl.ErrorContextBuilder) the lock must be acquired, and resources must be closed before releasing the lock.

  • Constructor Details

  • Method Details

    • getDocumentBuilder

      public <T> DocumentBuilderIndexedEntity<T> getDocumentBuilder(Class<T> entity)
    • getAnalyzer

      public Analyzer getAnalyzer(String name)
    • optimizerPhase

      public void optimizerPhase()
      If optimization has not been forced give a chance to configured OptimizerStrategy to optimize the index.
    • optimize

      public void optimize()
      Used by OptimizeLuceneWork after index optimization to flag that optimization has been forced.
      See Also:
    • getIndexWriter

      public IndexWriter getIndexWriter(boolean batchmode, ErrorContextBuilder errorContextBuilder)
      Gets the IndexWriter, opening one if needed.
      Parameters:
      batchmode - when true the indexWriter settings for batch mode will be applied. Ignored if IndexWriter is open already.
      errorContextBuilder - might contain some context useful to provide when handling IOExceptions
      Returns:
      a new IndexWriter or one already open.
    • getIndexWriter

      public IndexWriter getIndexWriter(boolean batchmode)
      See Also:
    • commitIndexWriter

      public void commitIndexWriter(ErrorContextBuilder errorContextBuilder)
      Commits changes to a previously opened IndexWriter.
      Parameters:
      errorContextBuilder - use it to handle exceptions, as it might contain a reference to the work performed before the commit
    • commitIndexWriter

      public void commitIndexWriter()
      See Also:
    • closeIndexWriter

      public void closeIndexWriter()
      Closes a previously opened IndexWriter.
    • incrementModificationCounter

      public void incrementModificationCounter(int modCount)
      Increment the counter of modification operations done on the index. Used (currently only) by the OptimizerStrategy.
      Parameters:
      modCount - the increment to add to the counter.
    • getEntitiesInDirectory

      public Set<Class<?>> getEntitiesInDirectory()
      Returns:
      The unmodifiable set of entity types being indexed in the underlying Lucene Directory backing this Workspace.
    • forceLockRelease

      public void forceLockRelease()
      Forces release of Directory lock. Should be used only to cleanup as error recovery.