Package org.apache.lucene.index
Class SortingLeafReader
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.LeafReader
-
- org.apache.lucene.index.FilterLeafReader
-
- org.apache.lucene.index.SortingLeafReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
class SortingLeafReader extends FilterLeafReader
AnLeafReader
which supports sorting documents by a givenSort
. This is package private and is only used by Lucene for BWC when it needs to merge an unsorted flushed segment built by an older version (newly flushed segments are sorted since version 7.0).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
SortingLeafReader.CachedBinaryDVs
(package private) static class
SortingLeafReader.CachedNumericDVs
(package private) static class
SortingLeafReader.SortingBinaryDocValues
private static class
SortingLeafReader.SortingBits
(package private) static class
SortingLeafReader.SortingDocsEnum
(package private) static class
SortingLeafReader.SortingFields
(package private) static class
SortingLeafReader.SortingNumericDocValues
private static class
SortingLeafReader.SortingPointValues
(package private) static class
SortingLeafReader.SortingPostingsEnum
(package private) static class
SortingLeafReader.SortingSortedDocValues
(package private) static class
SortingLeafReader.SortingSortedNumericDocValues
(package private) static class
SortingLeafReader.SortingSortedSetDocValues
private static class
SortingLeafReader.SortingTerms
private static class
SortingLeafReader.SortingTermsEnum
-
Nested classes/interfaces inherited from class org.apache.lucene.index.FilterLeafReader
FilterLeafReader.FilterFields, FilterLeafReader.FilterPostingsEnum, FilterLeafReader.FilterTerms, FilterLeafReader.FilterTermsEnum
-
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.CacheHelper, IndexReader.CacheKey, IndexReader.ClosedListener
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,SortingLeafReader.CachedBinaryDVs>
cachedBinaryDVs
private java.util.Map<java.lang.String,SortingLeafReader.CachedNumericDVs>
cachedNorms
private java.util.Map<java.lang.String,SortingLeafReader.CachedNumericDVs>
cachedNumericDVs
private java.util.Map<java.lang.String,int[]>
cachedSortedDVs
private java.util.Map<java.lang.String,long[][]>
cachedSortedNumericDVs
private java.util.Map<java.lang.String,long[][]>
cachedSortedSetDVs
(package private) Sorter.DocMap
docMap
-
Fields inherited from class org.apache.lucene.index.FilterLeafReader
in
-
-
Constructor Summary
Constructors Modifier Constructor Description private
SortingLeafReader(LeafReader in, Sorter.DocMap docMap)
-
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.BinaryDocValues
getBinaryDocValues(java.lang.String field)
ReturnsBinaryDocValues
for this field, or null if no binary doc values were indexed for this field.IndexReader.CacheHelper
getCoreCacheHelper()
Optional method: Return aIndexReader.CacheHelper
that can be used to cache based on the content of this leaf regardless of deletions.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 no numeric doc values were indexed for this field.PointValues
getPointValues(java.lang.String fieldName)
Returns thePointValues
used for numeric or spatial searches for the given field, or null if there are no point fields.IndexReader.CacheHelper
getReaderCacheHelper()
Optional method: Return aIndexReader.CacheHelper
that can be used to cache based on the content of this reader.SortedDocValues
getSortedDocValues(java.lang.String field)
ReturnsSortedDocValues
for this field, or null if noSortedDocValues
were indexed for this field.SortedNumericDocValues
getSortedNumericDocValues(java.lang.String field)
ReturnsSortedNumericDocValues
for this field, or null if noSortedNumericDocValues
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.Terms
terms(java.lang.String field)
Returns theTerms
index for this field, or null if it has none.java.lang.String
toString()
(package private) static LeafReader
wrap(LeafReader reader, Sorter.DocMap docMap)
Expert: same aswrap(org.apache.lucene.index.LeafReader, Sort)
but operates directly on aSorter.DocMap
.static LeafReader
wrap(LeafReader reader, Sort sort)
Return a sorted view ofreader
according to the order defined bysort
.-
Methods inherited from class org.apache.lucene.index.FilterLeafReader
checkIntegrity, doClose, getDelegate, getFieldInfos, getMetaData, maxDoc, numDocs, unwrap
-
Methods inherited from class org.apache.lucene.index.LeafReader
docFreq, getContext, getDocCount, getSumDocFreq, getSumTotalTermFreq, postings, postings, totalTermFreq
-
Methods inherited from class org.apache.lucene.index.IndexReader
close, decRef, document, document, ensureOpen, equals, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, notifyReaderClosedListeners, numDeletedDocs, registerParentReader, tryIncRef
-
-
-
-
Field Detail
-
cachedNumericDVs
private final java.util.Map<java.lang.String,SortingLeafReader.CachedNumericDVs> cachedNumericDVs
-
cachedBinaryDVs
private final java.util.Map<java.lang.String,SortingLeafReader.CachedBinaryDVs> cachedBinaryDVs
-
cachedSortedDVs
private final java.util.Map<java.lang.String,int[]> cachedSortedDVs
-
cachedSortedSetDVs
private final java.util.Map<java.lang.String,long[][]> cachedSortedSetDVs
-
cachedSortedNumericDVs
private final java.util.Map<java.lang.String,long[][]> cachedSortedNumericDVs
-
docMap
final Sorter.DocMap docMap
-
cachedNorms
private final java.util.Map<java.lang.String,SortingLeafReader.CachedNumericDVs> cachedNorms
-
-
Constructor Detail
-
SortingLeafReader
private SortingLeafReader(LeafReader in, Sorter.DocMap docMap)
-
-
Method Detail
-
wrap
public static LeafReader wrap(LeafReader reader, Sort sort) throws java.io.IOException
Return a sorted view ofreader
according to the order defined bysort
. If the reader is already sorted, this method might return the reader as-is.- Throws:
java.io.IOException
-
wrap
static LeafReader wrap(LeafReader reader, Sorter.DocMap docMap)
Expert: same aswrap(org.apache.lucene.index.LeafReader, Sort)
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 classFilterLeafReader
- Throws:
java.io.IOException
-
terms
public Terms terms(java.lang.String field) throws java.io.IOException
Description copied from class:LeafReader
Returns theTerms
index for this field, or null if it has none.- Overrides:
terms
in classFilterLeafReader
- Throws:
java.io.IOException
-
getBinaryDocValues
public BinaryDocValues getBinaryDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:LeafReader
ReturnsBinaryDocValues
for this field, or null if no binary doc values were indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getBinaryDocValues
in classFilterLeafReader
- Throws:
java.io.IOException
-
getLiveDocs
public Bits getLiveDocs()
Description copied from class:LeafReader
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 classFilterLeafReader
-
getPointValues
public PointValues getPointValues(java.lang.String fieldName) throws java.io.IOException
Description copied from class:LeafReader
Returns thePointValues
used for numeric or spatial searches for the given field, or null if there are no point fields.- Overrides:
getPointValues
in classFilterLeafReader
- Throws:
java.io.IOException
-
getNormValues
public NumericDocValues getNormValues(java.lang.String field) throws java.io.IOException
Description copied from class:LeafReader
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 classFilterLeafReader
- Throws:
java.io.IOException
-
getNumericDocValues
public NumericDocValues getNumericDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:LeafReader
ReturnsNumericDocValues
for this field, or null if no numeric doc values were indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getNumericDocValues
in classFilterLeafReader
- Throws:
java.io.IOException
-
getSortedNumericDocValues
public SortedNumericDocValues getSortedNumericDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:LeafReader
ReturnsSortedNumericDocValues
for this field, or null if noSortedNumericDocValues
were indexed for this field. The returned instance should only be used by a single thread.- Overrides:
getSortedNumericDocValues
in classFilterLeafReader
- Throws:
java.io.IOException
-
getSortedDocValues
public SortedDocValues getSortedDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:LeafReader
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 classFilterLeafReader
- Throws:
java.io.IOException
-
getSortedSetDocValues
public SortedSetDocValues getSortedSetDocValues(java.lang.String field) throws java.io.IOException
Description copied from class:LeafReader
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 classFilterLeafReader
- 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 classFilterLeafReader
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classFilterLeafReader
-
getCoreCacheHelper
public IndexReader.CacheHelper getCoreCacheHelper()
Description copied from class:LeafReader
Optional method: Return aIndexReader.CacheHelper
that can be used to cache based on the content of this leaf regardless of deletions. Two readers that have the same data but different sets of deleted documents or doc values updates may be considered equal. Consider usingIndexReader.getReaderCacheHelper()
if you need deletions or dv updates to be taken into account.A return value of
null
indicates that this reader is not suited for caching, which is typically the case for short-lived wrappers that alter the content of the wrapped leaf reader.- Specified by:
getCoreCacheHelper
in classLeafReader
-
getReaderCacheHelper
public IndexReader.CacheHelper getReaderCacheHelper()
Description copied from class:IndexReader
Optional method: Return aIndexReader.CacheHelper
that can be used to cache based on the content of this reader. Two readers that have different data or different sets of deleted documents will be considered different.A return value of
null
indicates that this reader is not suited for caching, which is typically the case for short-lived wrappers that alter the content of the wrapped reader.- Specified by:
getReaderCacheHelper
in classIndexReader
-
-