Class JackrabbitIndexReader
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.FilterIndexReader
-
- org.apache.jackrabbit.core.query.lucene.JackrabbitIndexReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Cloneable,HierarchyResolver,MultiIndexReader,ReleaseableIndexReader
public final class JackrabbitIndexReader extends FilterIndexReader implements HierarchyResolver, MultiIndexReader
JackrabbitIndexReaderwraps an index reader andreleasesthe underlying reader when a client callsIndexReader.close()on this reader. This allows reusing of the underlying index reader instance.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.index.FilterIndexReader
FilterIndexReader.FilterTermDocs, FilterIndexReader.FilterTermEnum, FilterIndexReader.FilterTermPositions
-
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.ReaderClosedListener
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.index.FilterIndexReader
in
-
Fields inherited from class org.apache.lucene.index.IndexReader
hasChanges
-
-
Constructor Summary
Constructors Constructor Description JackrabbitIndexReader(IndexReader in)Creates a newJackrabbitIndexReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.jackrabbit.core.query.lucene.ForeignSegmentDocIdcreateDocId(NodeId id)Creates a document id for the given node identifier.protected voiddoClose()Calls release on the underlyingMultiIndexReaderinstead of closing it.intgetDocumentNumber(org.apache.jackrabbit.core.query.lucene.ForeignSegmentDocId docId)Returns the document number for the passeddocId.IndexReader[]getIndexReaders()int[]getParents(int n, int[] docNumbers)Returns the document number of the parent ofnor an empty array ifndoes not have a parent (nis the root node).IndexReader[]getSequentialSubReaders()voidrelease()Releases this index reader and potentially frees resources.TermDocstermDocs(Term term)OverwritetermDocs(Term)and forward the call to the wrapped reader.-
Methods inherited from class org.apache.lucene.index.FilterIndexReader
directory, docFreq, doCommit, document, doDelete, doSetNorm, doUndeleteAll, getCommitUserData, getCoreCacheKey, getDeletesCacheKey, getFieldInfos, getIndexCommit, getTermFreqVector, getTermFreqVector, getTermFreqVector, getTermFreqVectors, getTermInfosIndexDivisor, getUniqueTermCount, getVersion, hasDeletions, hasNorms, isCurrent, isDeleted, isOptimized, maxDoc, norms, norms, numDocs, termDocs, termPositions, terms, terms, toString
-
Methods inherited from class org.apache.lucene.index.IndexReader
acquireWriteLock, addReaderClosedListener, clone, clone, close, commit, commit, decRef, deleteDocument, deleteDocuments, document, doOpenIfChanged, doOpenIfChanged, doOpenIfChanged, doOpenIfChanged, ensureOpen, flush, flush, getCommitUserData, getCurrentVersion, getRefCount, incRef, indexExists, lastModified, listCommits, numDeletedDocs, open, open, open, open, open, open, open, open, open, open, open, openIfChanged, openIfChanged, openIfChanged, openIfChanged, removeReaderClosedListener, reopen, reopen, reopen, reopen, setNorm, setNorm, termPositions, tryIncRef, undeleteAll
-
-
-
-
Constructor Detail
-
JackrabbitIndexReader
public JackrabbitIndexReader(IndexReader in)
Creates a newJackrabbitIndexReader. The passed index reader must also implement the interfacesHierarchyResolverandMultiIndexReader.- Parameters:
in- the underlying index reader.- Throws:
IllegalArgumentException- ifindoes not implementHierarchyResolverandMultiIndexReader.
-
-
Method Detail
-
termDocs
public TermDocs termDocs(Term term) throws IOException
OverwritetermDocs(Term)and forward the call to the wrapped reader.- Overrides:
termDocsin classFilterIndexReader- Throws:
IOException
-
doClose
protected void doClose() throws IOExceptionCalls release on the underlyingMultiIndexReaderinstead of closing it.- Overrides:
doClosein classFilterIndexReader- Throws:
IOException- if an error occurs while releaseing the underlying index reader.
-
getParents
public int[] getParents(int n, int[] docNumbers) throws IOExceptionReturns the document number of the parent ofnor an empty array ifndoes not have a parent (nis the root node).- Specified by:
getParentsin interfaceHierarchyResolver- Parameters:
n- the document number.docNumbers- an array for reuse. An implementation should use the passed array as a container for the return value, unless the length of the returned array is different fromdocNumbers. In which case an implementation will create a new array with an appropriate size.- Returns:
- the document number of
n's parent. - Throws:
IOException- if an error occurs while reading from the index.
-
getIndexReaders
public IndexReader[] getIndexReaders()
- Specified by:
getIndexReadersin interfaceMultiIndexReader- Returns:
- the
IndexReaders that are contained in thisMultiIndexReader.
-
getSequentialSubReaders
public IndexReader[] getSequentialSubReaders()
- Overrides:
getSequentialSubReadersin classFilterIndexReader
-
createDocId
public org.apache.jackrabbit.core.query.lucene.ForeignSegmentDocId createDocId(NodeId id) throws IOException
Creates a document id for the given node identifier.- Specified by:
createDocIdin interfaceMultiIndexReader- Parameters:
id- the id of the node.- Returns:
- a foreign segment doc id or
nullif there is no node with the givenid. - Throws:
IOException- if an error occurs while reading from the index.
-
getDocumentNumber
public int getDocumentNumber(org.apache.jackrabbit.core.query.lucene.ForeignSegmentDocId docId) throws IOExceptionReturns the document number for the passeddocId. If the id is invalid-1is returned.- Specified by:
getDocumentNumberin interfaceMultiIndexReader- Parameters:
docId- the document id to resolve.- Returns:
- the document number or
-1if it is invalid (e.g. does not exist). - Throws:
IOException- if an error occurs while reading from the index.
-
release
public void release() throws IOExceptionReleases this index reader and potentially frees resources. In contrast toIndexReader.close()this method does not necessarily close the index reader, but gives the implementation the opportunity to do reference counting.- Specified by:
releasein interfaceReleaseableIndexReader- Throws:
IOException- if an error occurs while releasing the index reader.
-
-