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
AnAtomicReaderwhich 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 voiddocument(int docID, StoredFieldVisitor visitor)Expert: visits the fields of a stored document, for custom processing/loading of each field.Fieldsfields()ReturnsFieldsfor this reader.BinaryDocValuesgetBinaryDocValues(java.lang.String field)ReturnsBinaryDocValuesfor this field, or null if noBinaryDocValueswere indexed for this field.BitsgetDocsWithField(java.lang.String field)Returns aBitsat 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.BitsgetLiveDocs()Returns theBitsrepresenting live (not deleted) docs.NumericDocValuesgetNormValues(java.lang.String field)ReturnsNumericDocValuesrepresenting norms for this field, or null if noNumericDocValueswere indexed.NumericDocValuesgetNumericDocValues(java.lang.String field)ReturnsNumericDocValuesfor this field, or null if noNumericDocValueswere indexed for this field.SortedDocValuesgetSortedDocValues(java.lang.String field)ReturnsSortedDocValuesfor this field, or null if noSortedDocValueswere indexed for this field.SortedSetDocValuesgetSortedSetDocValues(java.lang.String field)ReturnsSortedSetDocValuesfor this field, or null if noSortedSetDocValueswere indexed for this field.FieldsgetTermVectors(int docID)Retrieve term vectors for this document, or null if term vectors were not indexed.static AtomicReaderwrap(AtomicReader reader, Sorter sorter)Return a sorted view ofreaderaccording to the order defined bysorter.static AtomicReaderwrap(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 ofreaderaccording 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.IOExceptionDescription copied from class:IndexReaderExpert: 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:
documentin classFilterAtomicReader- Throws:
java.io.IOException
-
fields
public Fields fields() throws java.io.IOException
Description copied from class:AtomicReaderReturnsFieldsfor this reader. This method may return null if the reader has no postings.- Overrides:
fieldsin classFilterAtomicReader- Throws:
java.io.IOException
-
getBinaryDocValues
public BinaryDocValues getBinaryDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReaderReturnsBinaryDocValuesfor this field, or null if noBinaryDocValueswere indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getBinaryDocValuesin classFilterAtomicReader- Throws:
java.io.IOException
-
getLiveDocs
public Bits getLiveDocs()
Description copied from class:AtomicReaderReturns theBitsrepresenting 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:
getLiveDocsin classFilterAtomicReader
-
getNormValues
public NumericDocValues getNormValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReaderReturnsNumericDocValuesrepresenting norms for this field, or null if noNumericDocValueswere indexed. The returned instance should only be used by a single thread.- Overrides:
getNormValuesin classFilterAtomicReader- Throws:
java.io.IOException
-
getNumericDocValues
public NumericDocValues getNumericDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReaderReturnsNumericDocValuesfor this field, or null if noNumericDocValueswere indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getNumericDocValuesin classFilterAtomicReader- Throws:
java.io.IOException
-
getSortedDocValues
public SortedDocValues getSortedDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReaderReturnsSortedDocValuesfor this field, or null if noSortedDocValueswere indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getSortedDocValuesin classFilterAtomicReader- Throws:
java.io.IOException
-
getSortedSetDocValues
public SortedSetDocValues getSortedSetDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReaderReturnsSortedSetDocValuesfor this field, or null if noSortedSetDocValueswere indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getSortedSetDocValuesin classFilterAtomicReader- Throws:
java.io.IOException
-
getDocsWithField
public Bits getDocsWithField(java.lang.String field) throws java.io.IOException
Description copied from class:AtomicReaderReturns aBitsat 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:
getDocsWithFieldin classFilterAtomicReader- Throws:
java.io.IOException
-
getTermVectors
public Fields getTermVectors(int docID) throws java.io.IOException
Description copied from class:IndexReaderRetrieve 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:
getTermVectorsin classFilterAtomicReader- Throws:
java.io.IOException
-
-