org.hibernate.search.backend.impl.lucene
Class NRTWorkspaceImpl
java.lang.Object
org.hibernate.search.backend.impl.lucene.AbstractWorkspaceImpl
org.hibernate.search.backend.impl.lucene.NRTWorkspaceImpl
- All Implemented Interfaces:
- DirectoryBasedReaderProvider, ReaderProvider, Workspace
public class NRTWorkspaceImpl
- extends AbstractWorkspaceImpl
- implements DirectoryBasedReaderProvider
The Workspace implementation to be used to take advantage of NRT Lucene features.
IndexReader instances are obtained directly from the IndexWriter, which is not forced
to flush all pending changes to the Directory structure.
We keep a reference Reader, obtained from the IndexWriter each time a transactional queue
is applied, so that the IndexReader instance "sees" only fully committed transactions;
the reference is never returned to clients, but each time a client needs an IndexReader
a clone is created from the last refreshed IndexReader.
Since the backend is forced to create a reference IndexReader after each (skipped) commit,
some IndexReaders might be opened without being ever used.
This class implements both Workspace and ReaderProvider.
- Author:
- Sanne Grinovero (C) 2011 Red Hat Inc.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NRTWorkspaceImpl
public NRTWorkspaceImpl(DirectoryBasedIndexManager indexManager,
WorkerBuildContext buildContext,
Properties cfg)
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
- Specified by:
afterTransactionApplied
in class AbstractWorkspaceImpl
- Parameters:
someFailureHappened
- usually false, set to true if errors
where caught while using the IndexWriterstreaming
- if no immediate visibility of the change is required (hint for performance)
openIndexReader
public org.apache.lucene.index.IndexReader openIndexReader()
- Specified by:
openIndexReader
in interface ReaderProvider
closeIndexReader
public void closeIndexReader(org.apache.lucene.index.IndexReader reader)
- Specified by:
closeIndexReader
in interface ReaderProvider
initialize
public void initialize(DirectoryBasedIndexManager indexManager,
Properties props)
- Specified by:
initialize
in interface DirectoryBasedReaderProvider
stop
public void stop()
- Specified by:
stop
in interface DirectoryBasedReaderProvider
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
Copyright © 2006-2012 Red Hat Middleware, LLC. All Rights Reserved