Class CachingMultiIndexReader
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.MultiReader
-
- org.apache.jackrabbit.core.query.lucene.CachingMultiIndexReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Cloneable,HierarchyResolver,MultiIndexReader,ReleaseableIndexReader
public final class CachingMultiIndexReader extends MultiReader implements HierarchyResolver, MultiIndexReader
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.ReaderClosedListener
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.index.MultiReader
starts
-
Fields inherited from class org.apache.lucene.index.IndexReader
hasChanges
-
-
Constructor Summary
Constructors Constructor Description CachingMultiIndexReader(org.apache.jackrabbit.core.query.lucene.ReadOnlyIndexReader[] subReaders, org.apache.jackrabbit.core.query.lucene.DocNumberCache cache)Creates a newCachingMultiIndexReaderbased on sub readers.
-
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()intgetDocumentNumber(org.apache.jackrabbit.core.query.lucene.ForeignSegmentDocId docId)Returns the document number for the passeddocId.IndexReader[]getIndexReaders()org.apache.jackrabbit.core.query.lucene.DocIdgetParentDocId(int n)Returns the DocId of the parent ofnorDocId.NULLifndoes not have a parent (nis the root node).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).voidrelease()Releases this index reader and potentially frees resources.TermDocstermDocs(Term term)-
Methods inherited from class org.apache.lucene.index.MultiReader
clone, clone, docFreq, doCommit, document, doDelete, doOpenIfChanged, doOpenIfChanged, doSetNorm, doUndeleteAll, getFieldInfos, getSequentialSubReaders, getTermFreqVector, getTermFreqVector, getTermFreqVector, getTermFreqVectors, getVersion, hasDeletions, hasNorms, isCurrent, isDeleted, isOptimized, maxDoc, norms, norms, numDocs, readerIndex, termDocs, termPositions, terms, terms
-
Methods inherited from class org.apache.lucene.index.IndexReader
acquireWriteLock, addReaderClosedListener, close, commit, commit, decRef, deleteDocument, deleteDocuments, directory, document, doOpenIfChanged, doOpenIfChanged, ensureOpen, flush, flush, getCommitUserData, getCommitUserData, getCoreCacheKey, getCurrentVersion, getDeletesCacheKey, getIndexCommit, getRefCount, getTermInfosIndexDivisor, getUniqueTermCount, 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, toString, tryIncRef, undeleteAll
-
-
-
-
Constructor Detail
-
CachingMultiIndexReader
public CachingMultiIndexReader(org.apache.jackrabbit.core.query.lucene.ReadOnlyIndexReader[] subReaders, org.apache.jackrabbit.core.query.lucene.DocNumberCache cache)Creates a newCachingMultiIndexReaderbased on sub readers.- Parameters:
subReaders- the sub readers.cache- the document number cache.
-
-
Method Detail
-
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.
-
getParentDocId
public org.apache.jackrabbit.core.query.lucene.DocId getParentDocId(int n) throws IOExceptionReturns the DocId of the parent ofnorDocId.NULLifndoes not have a parent (nis the root node).- Parameters:
n- the document number.- Returns:
- the DocId of
n's parent. - Throws:
IOException- if an error occurs while reading from the index.
-
termDocs
public TermDocs termDocs(Term term) throws IOException
- Overrides:
termDocsin classMultiReader- Throws:
IOException
-
release
public final 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.
-
doClose
protected void doClose() throws IOException- Overrides:
doClosein classMultiReader- Throws:
IOException
-
getIndexReaders
public IndexReader[] getIndexReaders()
- Specified by:
getIndexReadersin interfaceMultiIndexReader- Returns:
- the
IndexReaders that are contained in thisMultiIndexReader.
-
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)
Returns 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).
-
-