org.hibernate.search.backend.impl.lucene

## Class AbstractWorkspaceImpl

- java.lang.Object
- - 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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.hibernate.search.backend.impl.lucene.IndexWriterHolder` | `writerHolder`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractWorkspaceImpl(DirectoryBasedIndexManager indexManager, WorkerBuildContext context, Properties cfg)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterTransactionApplied(boolean someFailureHappened, boolean streaming)` Invoked after all changes of a transaction are applied.
    `boolean` | `areSingleTermDeletesSafe()` Returns true if one and only one entity type is stored in the targeted index.
    `void` | `closeIndexWriter()`
    `void` | `flush()` Makes sure eventually pending changes are made visible to IndexReaders.
    `Analyzer` | `getAnalyzer(String name)`
    `DocumentBuilderIndexedEntity` | `getDocumentBuilder(IndexedTypeIdentifier type)`
    `IndexedTypeSet` | `getEntitiesInIndexManager()`
    `String` | `getIndexName()` Returns the name of the index this workspace is being used for.
    `IndexWriter` | `getIndexWriter()` Gets the IndexWriter, opening one if needed.
    `IndexWriter` | `getIndexWriter(ErrorContextBuilder errorContextBuilder)`
    `IndexWriterDelegate` | `getIndexWriterDelegate()`
    `IndexWriterDelegate` | `getIndexWriterDelegate(ErrorContextBuilder errorContextBuilder)`
    `protected void` | `incrementModificationCounter()`
    `boolean` | `isDeleteByTermEnforced()` Returns true if either the configuration guarantees that one can use delete by term on all indexes or if we ensure that entity types stored in the index return positive to `IdUniquenessResolver` and that the document id and JPA id are the same property.
    `void` | `optimizerPhase()` If optimization has not been forced give a chance to configured OptimizerStrategy to optimize the index.
    `void` | `performOptimization(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

      `getCommitPolicy, notifyWorkApplied`

- - ### 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 DocumentBuilderIndexedEntity getDocumentBuilder(IndexedTypeIdentifier type)

      Specified by:
        `getDocumentBuilder` in interface `Workspace`

    - #### getAnalyzer

          public 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(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`, `SearchIntegrator.optimize()`, `SearchIntegrator.optimize(IndexedTypeIdentifier)`

    - #### incrementModificationCounter

          protected void incrementModificationCounter()

    - #### getEntitiesInIndexManager

          public IndexedTypeSet getEntitiesInIndexManager()

      Specified by:
        `getEntitiesInIndexManager` in interface `Workspace`
      Returns:
        The set of entity types being indexed in the underlying IndexManager backing this Workspace.

    - #### afterTransactionApplied

          public 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()

    - #### closeIndexWriter

          public void closeIndexWriter()

    - #### getIndexWriter

          public 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 IndexWriter getIndexWriter(ErrorContextBuilder errorContextBuilder)

    - #### areSingleTermDeletesSafe

          public boolean areSingleTermDeletesSafe()

      Description copied from interface: `Workspace`
      Returns true if one and only one entity type is stored in the targeted index. This allows to use delete by the identifier term which is much faster. This method should really be named `isSingleClassInIndex` but that's a public contract.
      Specified by:
        `areSingleTermDeletesSafe` in interface `Workspace`
      Returns:
        true if one and only one entity type is stored in the targeted index.

    - #### isDeleteByTermEnforced

          public boolean isDeleteByTermEnforced()

      Description copied from interface: `Workspace`
      Returns true if either the configuration guarantees that one can use delete by term on all indexes or if we ensure that entity types stored in the index return positive to `IdUniquenessResolver` and that the document id and JPA id are the same property. This allows to use delete by identifier term in a safe way and is much more efficient. If unsure, we will delete taking the class field into account to avoid unwanted document deletions. The method should really be named `isDeleteByTermEnforcedOrSafe` but that's a public contract.
      Specified by:
        `isDeleteByTermEnforced` in interface `Workspace`
      Returns:
        true if either the configuration guarantees that one can use delete by term on all indexes

    - #### flush

          public void flush()

      Description copied from interface: `Workspace`
      Makes sure eventually pending changes are made visible to IndexReaders.
      Specified by:
        `flush` in interface `Workspace`

    - #### getIndexName

          public String getIndexName()

      Description copied from interface: `Workspace`
      Returns the name of the index this workspace is being used for.
      Specified by:
        `getIndexName` in interface `Workspace`
      Returns:
        the name of the index

    - #### getIndexWriterDelegate

          public IndexWriterDelegate getIndexWriterDelegate(ErrorContextBuilder errorContextBuilder)

    - #### getIndexWriterDelegate

          public IndexWriterDelegate getIndexWriterDelegate()

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