org.apache.solr.search
Class SolrIndexReader

java.lang.Object
  extended by org.apache.lucene.index.IndexReader
      extended by org.apache.lucene.index.FilterIndexReader
          extended by org.apache.solr.search.SolrIndexReader
All Implemented Interfaces:
Closeable, Cloneable

public class SolrIndexReader
extends FilterIndexReader

Solr wrapper for IndexReader that contains extra context. This is currently experimental, for internal use only, and subject to change.


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
SolrIndexReader(IndexReader in, SolrIndexReader parent, int base)
          Recursively wrap an IndexReader in SolrIndexReader instances.
 
Method Summary
 void associateInfo(SolrIndexReader source)
          Copies SolrReaderInfo instances from the source to this SolrIndexReader
 Object clone()
           
 IndexReader clone(boolean openReadOnly)
           
 Directory directory()
           
 int docFreq(Term t)
           
protected  void doClose()
           
 Document document(int n, FieldSelector fieldSelector)
           
protected  void doDelete(int n)
           
protected  void doSetNorm(int d, String f, byte b)
           
protected  void doUndeleteAll()
           
 boolean equals(Object o)
           
 int getBase()
          returns the docid offset within the parent reader
 Map getCommitUserData()
           
 Object getCoreCacheKey()
           
 FieldInfos getFieldInfos()
           
 IndexCommit getIndexCommit()
           
 int[] getLeafOffsets()
          Return the doc id offsets for each leaf reader.
 SolrIndexReader[] getLeafReaders()
          return the leaf readers in this reader tree, or an array of size 1 containing "this" if "this" is a leaf
 SolrIndexReader getParent()
          returns the parent reader, or null of none
 SolrIndexReader[] getSequentialSubReaders()
           
 TermFreqVector getTermFreqVector(int docNumber, String field)
           
 void getTermFreqVector(int docNumber, String field, TermVectorMapper mapper)
           
 void getTermFreqVector(int docNumber, TermVectorMapper mapper)
           
 TermFreqVector[] getTermFreqVectors(int docNumber)
           
 int getTermInfosIndexDivisor()
           
 long getUniqueTermCount()
           
 long getVersion()
           
 IndexReader getWrappedReader()
           
 boolean hasDeletions()
           
 int hashCode()
           
 boolean hasNorms(String field)
           
 boolean isCurrent()
           
 boolean isDeleted(int n)
           
 boolean isOptimized()
           
 int maxDoc()
           
 byte[] norms(String f)
           
 void norms(String f, byte[] bytes, int offset)
           
 int numDocs()
           
static int readerIndex(int doc, int[] offsets)
          Given an array of IndexReader offsets, find which contains the given doc
 SolrIndexReader reopen()
           
 SolrIndexReader reopen(boolean openReadOnly)
           
 IndexReader reopen(IndexCommit commit)
           
 TermDocs termDocs()
           
 TermDocs termDocs(Term term)
           
 TermPositions termPositions()
           
 TermEnum terms()
           
 TermEnum terms(Term t)
           
 String toString()
           
 
Methods inherited from class org.apache.lucene.index.FilterIndexReader
doCommit, getDeletesCacheKey
 
Methods inherited from class org.apache.lucene.index.IndexReader
acquireWriteLock, addReaderClosedListener, 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, setNorm, setNorm, termPositions, tryIncRef, undeleteAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SolrIndexReader

public SolrIndexReader(IndexReader in,
                       SolrIndexReader parent,
                       int base)
Recursively wrap an IndexReader in SolrIndexReader instances.

Parameters:
in - the reader to wrap
parent - the parent, if any (null if none)
base - the docid offset in the parent (0 if top level)
Method Detail

getLeafReaders

public SolrIndexReader[] getLeafReaders()
return the leaf readers in this reader tree, or an array of size 1 containing "this" if "this" is a leaf


getLeafOffsets

public int[] getLeafOffsets()
Return the doc id offsets for each leaf reader. This will be different than getBase() for any leaf reader who is not a direct descendant of "this".


readerIndex

public static int readerIndex(int doc,
                              int[] offsets)
Given an array of IndexReader offsets, find which contains the given doc


toString

public String toString()
Overrides:
toString in class FilterIndexReader

associateInfo

public void associateInfo(SolrIndexReader source)
Copies SolrReaderInfo instances from the source to this SolrIndexReader


getWrappedReader

public IndexReader getWrappedReader()

getParent

public SolrIndexReader getParent()
returns the parent reader, or null of none


getBase

public int getBase()
returns the docid offset within the parent reader


directory

public Directory directory()
Overrides:
directory in class FilterIndexReader

getTermFreqVectors

public TermFreqVector[] getTermFreqVectors(int docNumber)
                                    throws IOException
Overrides:
getTermFreqVectors in class FilterIndexReader
Throws:
IOException

getTermFreqVector

public TermFreqVector getTermFreqVector(int docNumber,
                                        String field)
                                 throws IOException
Overrides:
getTermFreqVector in class FilterIndexReader
Throws:
IOException

getTermFreqVector

public void getTermFreqVector(int docNumber,
                              String field,
                              TermVectorMapper mapper)
                       throws IOException
Overrides:
getTermFreqVector in class FilterIndexReader
Throws:
IOException

getTermFreqVector

public void getTermFreqVector(int docNumber,
                              TermVectorMapper mapper)
                       throws IOException
Overrides:
getTermFreqVector in class FilterIndexReader
Throws:
IOException

numDocs

public int numDocs()
Overrides:
numDocs in class FilterIndexReader

maxDoc

public int maxDoc()
Overrides:
maxDoc in class FilterIndexReader

document

public Document document(int n,
                         FieldSelector fieldSelector)
                  throws CorruptIndexException,
                         IOException
Overrides:
document in class FilterIndexReader
Throws:
CorruptIndexException
IOException

isDeleted

public boolean isDeleted(int n)
Overrides:
isDeleted in class FilterIndexReader

hasDeletions

public boolean hasDeletions()
Overrides:
hasDeletions in class FilterIndexReader

doUndeleteAll

protected void doUndeleteAll()
                      throws CorruptIndexException,
                             IOException
Overrides:
doUndeleteAll in class FilterIndexReader
Throws:
CorruptIndexException
IOException

hasNorms

public boolean hasNorms(String field)
                 throws IOException
Overrides:
hasNorms in class FilterIndexReader
Throws:
IOException

norms

public byte[] norms(String f)
             throws IOException
Overrides:
norms in class FilterIndexReader
Throws:
IOException

norms

public void norms(String f,
                  byte[] bytes,
                  int offset)
           throws IOException
Overrides:
norms in class FilterIndexReader
Throws:
IOException

doSetNorm

protected void doSetNorm(int d,
                         String f,
                         byte b)
                  throws CorruptIndexException,
                         IOException
Overrides:
doSetNorm in class FilterIndexReader
Throws:
CorruptIndexException
IOException

terms

public TermEnum terms()
               throws IOException
Overrides:
terms in class FilterIndexReader
Throws:
IOException

terms

public TermEnum terms(Term t)
               throws IOException
Overrides:
terms in class FilterIndexReader
Throws:
IOException

docFreq

public int docFreq(Term t)
            throws IOException
Overrides:
docFreq in class FilterIndexReader
Throws:
IOException

termDocs

public TermDocs termDocs()
                  throws IOException
Overrides:
termDocs in class FilterIndexReader
Throws:
IOException

termDocs

public TermDocs termDocs(Term term)
                  throws IOException
Overrides:
termDocs in class FilterIndexReader
Throws:
IOException

termPositions

public TermPositions termPositions()
                            throws IOException
Overrides:
termPositions in class FilterIndexReader
Throws:
IOException

doDelete

protected void doDelete(int n)
                 throws CorruptIndexException,
                        IOException
Overrides:
doDelete in class FilterIndexReader
Throws:
CorruptIndexException
IOException

doClose

protected void doClose()
                throws IOException
Overrides:
doClose in class FilterIndexReader
Throws:
IOException

getFieldInfos

public FieldInfos getFieldInfos()
Overrides:
getFieldInfos in class FilterIndexReader

getVersion

public long getVersion()
Overrides:
getVersion in class FilterIndexReader

isCurrent

public boolean isCurrent()
                  throws CorruptIndexException,
                         IOException
Overrides:
isCurrent in class FilterIndexReader
Throws:
CorruptIndexException
IOException

isOptimized

public boolean isOptimized()
Overrides:
isOptimized in class FilterIndexReader

getSequentialSubReaders

public SolrIndexReader[] getSequentialSubReaders()
Overrides:
getSequentialSubReaders in class FilterIndexReader

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

reopen

public IndexReader reopen(IndexCommit commit)
                   throws CorruptIndexException,
                          IOException
Overrides:
reopen in class IndexReader
Throws:
CorruptIndexException
IOException

clone

public Object clone()
Overrides:
clone in class IndexReader

clone

public IndexReader clone(boolean openReadOnly)
                  throws CorruptIndexException,
                         IOException
Overrides:
clone in class IndexReader
Throws:
CorruptIndexException
IOException

getCommitUserData

public Map getCommitUserData()
Overrides:
getCommitUserData in class FilterIndexReader

getUniqueTermCount

public long getUniqueTermCount()
                        throws IOException
Overrides:
getUniqueTermCount in class FilterIndexReader
Throws:
IOException

reopen

public SolrIndexReader reopen(boolean openReadOnly)
                       throws IOException
Overrides:
reopen in class IndexReader
Throws:
IOException

reopen

public SolrIndexReader reopen()
                       throws CorruptIndexException,
                              IOException
Overrides:
reopen in class IndexReader
Throws:
CorruptIndexException
IOException

getIndexCommit

public IndexCommit getIndexCommit()
                           throws IOException
Overrides:
getIndexCommit in class FilterIndexReader
Throws:
IOException

getCoreCacheKey

public Object getCoreCacheKey()
Overrides:
getCoreCacheKey in class FilterIndexReader

getTermInfosIndexDivisor

public int getTermInfosIndexDivisor()
Overrides:
getTermInfosIndexDivisor in class FilterIndexReader