org.apache.jackrabbit.core.query.lucene
Class CachingMultiIndexReader

java.lang.Object
  extended by org.apache.lucene.index.IndexReader
      extended by org.apache.lucene.index.MultiReader
          extended by org.apache.jackrabbit.core.query.lucene.CachingMultiIndexReader
All Implemented Interfaces:
HierarchyResolver, MultiIndexReader

public final class CachingMultiIndexReader
extends org.apache.lucene.index.MultiReader
implements HierarchyResolver, MultiIndexReader

Extends a MultiReader with support for cached TermDocs on FieldNames.UUID field.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
org.apache.lucene.index.IndexReader.FieldOption
 
Constructor Summary
CachingMultiIndexReader(org.apache.jackrabbit.core.query.lucene.ReadOnlyIndexReader[] subReaders, org.apache.jackrabbit.core.query.lucene.DocNumberCache cache)
          Creates a new CachingMultiIndexReader based on sub readers.
 
Method Summary
 org.apache.jackrabbit.core.query.lucene.ForeignSegmentDocId createDocId(UUID uuid)
          Creates a document id for the given uuid.
protected  void doClose()
          Decrements the reference count and closes the underlying readers if this reader is not in use anymore.
 int getDocumentNumber(org.apache.jackrabbit.core.query.lucene.ForeignSegmentDocId docId)
          Returns the document number for the passed docId.
 org.apache.lucene.index.IndexReader[] getIndexReaders()
          
 int getParent(int n)
          Returns the document number of the parent of n or -1 if n does not have a parent (n is the root node).
 org.apache.jackrabbit.core.query.lucene.DocId getParentDocId(int n)
          Returns the DocId of the parent of n or DocId#NULL if n does not have a parent (n is the root node).
 org.apache.lucene.index.TermDocs termDocs(org.apache.lucene.index.Term term)
          
 
Methods inherited from class org.apache.lucene.index.MultiReader
docFreq, doCommit, document, doDelete, doSetNorm, doUndeleteAll, getFieldNames, getTermFreqVector, getTermFreqVectors, hasDeletions, hasNorms, isDeleted, maxDoc, norms, norms, numDocs, termDocs, termPositions, terms, terms
 
Methods inherited from class org.apache.lucene.index.IndexReader
close, commit, deleteDocument, deleteDocuments, directory, document, ensureOpen, finalize, getCurrentVersion, getCurrentVersion, getCurrentVersion, getVersion, indexExists, indexExists, indexExists, isCurrent, isLocked, isLocked, isOptimized, lastModified, lastModified, lastModified, main, open, open, open, open, setNorm, setNorm, termPositions, undeleteAll, unlock
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingMultiIndexReader

public CachingMultiIndexReader(org.apache.jackrabbit.core.query.lucene.ReadOnlyIndexReader[] subReaders,
                               org.apache.jackrabbit.core.query.lucene.DocNumberCache cache)
                        throws IOException
Creates a new CachingMultiIndexReader based on sub readers.

Parameters:
subReaders - the sub readers.
cache - the document number cache.
Throws:
IOException - if an error occurs while reading from the indexes.
Method Detail

getParent

public int getParent(int n)
              throws IOException
Returns the document number of the parent of n or -1 if n does not have a parent (n is the root node).

Specified by:
getParent in interface HierarchyResolver
Parameters:
n - the document number.
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 IOException
Returns the DocId of the parent of n or DocId#NULL if n does not have a parent (n is 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 org.apache.lucene.index.TermDocs termDocs(org.apache.lucene.index.Term term)
                                          throws IOException

Overrides:
termDocs in class org.apache.lucene.index.IndexReader
Throws:
IOException

doClose

protected void doClose()
                throws IOException
Decrements the reference count and closes the underlying readers if this reader is not in use anymore.

Overrides:
doClose in class org.apache.lucene.index.MultiReader
Throws:
IOException - if an error occurs while closing this reader.

getIndexReaders

public org.apache.lucene.index.IndexReader[] getIndexReaders()

Specified by:
getIndexReaders in interface MultiIndexReader
Returns:
the IndexReaders that are contained in this MultiIndexReader.

createDocId

public org.apache.jackrabbit.core.query.lucene.ForeignSegmentDocId createDocId(UUID uuid)
                                                                        throws IOException
Creates a document id for the given uuid.

Specified by:
createDocId in interface MultiIndexReader
Parameters:
uuid - the uuid of the node.
Returns:
a foreign segment doc id or null if there is no node with the given uuid.
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 passed docId. If the id is invalid -1 is returned.

Specified by:
getDocumentNumber in interface MultiIndexReader
Parameters:
docId - the document id to resolve.
Returns:
the document number or -1 if it is invalid (e.g. does not exist).


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.