Package org.apache.lucene.index.sorter
Class SortingAtomicReader
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.AtomicReader
-
- org.apache.lucene.index.FilterAtomicReader
-
- org.apache.lucene.index.sorter.SortingAtomicReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class SortingAtomicReader extends FilterAtomicReader
AnAtomicReader
which supports sorting documents by a givenSorter
. You can use this class to sort an index as follows:IndexWriter writer; // writer to which the sorted index will be added DirectoryReader reader; // reader on the input index Sorter sorter; // determines how the documents are sorted AtomicReader sortingReader = SortingAtomicReader.wrap(SlowCompositeReaderWrapper.wrap(reader), sorter); writer.addIndexes(reader); writer.close(); reader.close();
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.index.FilterAtomicReader
FilterAtomicReader.FilterDocsAndPositionsEnum, FilterAtomicReader.FilterDocsEnum, FilterAtomicReader.FilterFields, FilterAtomicReader.FilterTerms, FilterAtomicReader.FilterTermsEnum
-
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.ReaderClosedListener
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
document(int docID, StoredFieldVisitor visitor)
Expert: visits the fields of a stored document, for custom processing/loading of each field.Fields
fields()
ReturnsFields
for this reader.BinaryDocValues
getBinaryDocValues(java.lang.String field)
ReturnsBinaryDocValues
for this field, or null if noBinaryDocValues
were indexed for this field.Bits
getDocsWithField(java.lang.String field)
Returns aBits
at the size ofreader.maxDoc()
, with turned on bits for each docid that does have a value for this field, or null if no DocValues were indexed for this field.Bits
getLiveDocs()
Returns theBits
representing live (not deleted) docs.NumericDocValues
getNormValues(java.lang.String field)
ReturnsNumericDocValues
representing norms for this field, or null if noNumericDocValues
were indexed.NumericDocValues
getNumericDocValues(java.lang.String field)
ReturnsNumericDocValues
for this field, or null if noNumericDocValues
were indexed for this field.SortedDocValues
getSortedDocValues(java.lang.String field)
ReturnsSortedDocValues
for this field, or null if noSortedDocValues
were indexed for this field.SortedSetDocValues
getSortedSetDocValues(java.lang.String field)
ReturnsSortedSetDocValues
for this field, or null if noSortedSetDocValues
were indexed for this field.Fields
getTermVectors(int docID)
Retrieve term vectors for this document, or null if term vectors were not indexed.static AtomicReader
wrap(AtomicReader reader, Sorter sorter)
Return a sorted view ofreader
according to the order defined bysorter
.static AtomicReader
wrap(AtomicReader reader, Sorter.DocMap docMap)
Expert: same aswrap(AtomicReader, Sorter)
but operates directly on aSorter.DocMap
.-
Methods inherited from class org.apache.lucene.index.FilterAtomicReader
getFieldInfos, maxDoc, numDocs, toString
-
Methods inherited from class org.apache.lucene.index.AtomicReader
docFreq, getContext, getDocCount, getSumDocFreq, getSumTotalTermFreq, hasNorms, termDocsEnum, termPositionsEnum, terms, totalTermFreq
-
Methods inherited from class org.apache.lucene.index.IndexReader
addReaderClosedListener, close, decRef, document, document, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, open, open, open, open, open, registerParentReader, removeReaderClosedListener, tryIncRef
-
-
-
-
Method Detail
-
wrap
public static AtomicReader wrap(AtomicReader reader, Sorter sorter) throws java.io.IOException
Return a sorted view ofreader
according to the order defined bysorter
. If the reader is already sorted, this method might return the reader as-is.- Throws:
java.io.IOException
-
wrap
public static AtomicReader wrap(AtomicReader reader, Sorter.DocMap docMap)
Expert: same aswrap(AtomicReader, Sorter)
but operates directly on aSorter.DocMap
.
-
document
public void document(int docID, StoredFieldVisitor visitor) throws java.io.IOException
Description copied from class:IndexReader
Expert: visits the fields of a stored document, for custom processing/loading of each field. If you simply want to load all fields, useIndexReader.document(int)
. If you want to load a subset, useDocumentStoredFieldVisitor
.- Overrides:
document
in classFilterAtomicReader
- Throws:
java.io.IOException
-
fields
public Fields fields() throws java.io.IOException
Description copied from class:AtomicReader
ReturnsFields
for this reader. This method may return null if the reader has no postings.- Overrides:
fields
in classFilterAtomicReader
- Throws:
java.io.IOException
-
getBinaryDocValues
public BinaryDocValues getBinaryDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReader
ReturnsBinaryDocValues
for this field, or null if noBinaryDocValues
were indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getBinaryDocValues
in classFilterAtomicReader
- Throws:
java.io.IOException
-
getLiveDocs
public Bits getLiveDocs()
Description copied from class:AtomicReader
Returns theBits
representing live (not deleted) docs. A set bit indicates the doc ID has not been deleted. If this method returns null it means there are no deleted documents (all documents are live). The returned instance has been safely published for use by multiple threads without additional synchronization.- Overrides:
getLiveDocs
in classFilterAtomicReader
-
getNormValues
public NumericDocValues getNormValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReader
ReturnsNumericDocValues
representing norms for this field, or null if noNumericDocValues
were indexed. The returned instance should only be used by a single thread.- Overrides:
getNormValues
in classFilterAtomicReader
- Throws:
java.io.IOException
-
getNumericDocValues
public NumericDocValues getNumericDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReader
ReturnsNumericDocValues
for this field, or null if noNumericDocValues
were indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getNumericDocValues
in classFilterAtomicReader
- Throws:
java.io.IOException
-
getSortedDocValues
public SortedDocValues getSortedDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReader
ReturnsSortedDocValues
for this field, or null if noSortedDocValues
were indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getSortedDocValues
in classFilterAtomicReader
- Throws:
java.io.IOException
-
getSortedSetDocValues
public SortedSetDocValues getSortedSetDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReader
ReturnsSortedSetDocValues
for this field, or null if noSortedSetDocValues
were indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getSortedSetDocValues
in classFilterAtomicReader
- Throws:
java.io.IOException
-
getDocsWithField
public Bits getDocsWithField(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReader
Returns aBits
at the size ofreader.maxDoc()
, with turned on bits for each docid that does have a value for this field, or null if no DocValues were indexed for this field. The returned instance should only be used by a single thread- Overrides:
getDocsWithField
in classFilterAtomicReader
- Throws:
java.io.IOException
-
getTermVectors
public Fields getTermVectors(int docID) throws java.io.IOException
Description copied from class:IndexReader
Retrieve term vectors for this document, or null if term vectors were not indexed. The returned Fields instance acts like a single-document inverted index (the docID will be 0).- Overrides:
getTermVectors
in classFilterAtomicReader
- Throws:
java.io.IOException
-
-