Package org.apache.lucene.index
Class SortingCodecReader
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.LeafReader
-
- org.apache.lucene.index.CodecReader
-
- org.apache.lucene.index.FilterCodecReader
-
- org.apache.lucene.index.SortingCodecReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class SortingCodecReader extends FilterCodecReader
AnCodecReader
which supports sorting documents by a givenSort
. This can be used to re-sort and index after it's been created by wrapping all readers of the index with this reader and adding it to a fresh IndexWriter viaIndexWriter.addIndexes(CodecReader...)
. NOTE: This reader should only be used for merging. Pulling fields from this reader might be very costly and memory intensive.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SortingCodecReader.SortingBits
private static class
SortingCodecReader.SortingIntersectVisitor
private static class
SortingCodecReader.SortingPointTree
private static class
SortingCodecReader.SortingPointValues
-
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.lang.String
cachedField
private java.lang.Object
cachedObject
private boolean
cacheIsNorms
private java.util.Map<java.lang.String,java.lang.Integer>
cacheStats
(package private) Sorter.DocMap
docMap
(package private) LeafMetaData
metaData
-
Fields inherited from class org.apache.lucene.index.FilterCodecReader
in
-
-
Constructor Summary
Constructors Modifier Constructor Description private
SortingCodecReader(CodecReader in, Sorter.DocMap docMap, LeafMetaData metaData)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
assertCreatedOnlyOnce(java.lang.String field, boolean norms)
IndexReader.CacheHelper
getCoreCacheHelper()
Optional method: Return aIndexReader.CacheHelper
that can be used to cache based on the content of this leaf regardless of deletions.DocValuesProducer
getDocValuesReader()
Expert: retrieve underlying DocValuesProducerStoredFieldsReader
getFieldsReader()
Expert: retrieve thread-private StoredFieldsReaderBits
getLiveDocs()
Returns theBits
representing live (not deleted) docs.LeafMetaData
getMetaData()
Return metadata about this leaf.NormsProducer
getNormsReader()
Expert: retrieve underlying NormsProducerprivate NumericDocValuesWriter.NumericDVs
getNumericDocValues(NumericDocValues oldNumerics)
private <T> T
getOrCreate(java.lang.String field, boolean norms, IOSupplier<T> supplier)
private <T> T
getOrCreateDV(java.lang.String field, IOSupplier<T> supplier)
private <T> T
getOrCreateNorms(java.lang.String field, IOSupplier<T> supplier)
PointsReader
getPointsReader()
Expert: retrieve underlying PointsReaderFieldsProducer
getPostingsReader()
Expert: retrieve underlying FieldsProducerIndexReader.CacheHelper
getReaderCacheHelper()
Optional method: Return aIndexReader.CacheHelper
that can be used to cache based on the content of this reader.TermVectorsReader
getTermVectorsReader()
Expert: retrieve thread-private TermVectorsReaderKnnVectorsReader
getVectorReader()
Expert: retrieve underlying VectorReaderprivate StoredFieldsReader
newStoredFieldsReader(StoredFieldsReader delegate)
private TermVectorsReader
newTermVectorsReader(TermVectorsReader delegate)
java.lang.String
toString()
(package private) static CodecReader
wrap(CodecReader reader, Sorter.DocMap docMap, Sort sort)
Expert: same aswrap(org.apache.lucene.index.CodecReader, Sort)
but operates directly on aSorter.DocMap
.static CodecReader
wrap(CodecReader reader, Sort sort)
Return a sorted view ofreader
according to the order defined bysort
.-
Methods inherited from class org.apache.lucene.index.FilterCodecReader
checkIntegrity, doClose, getDelegate, getFieldInfos, maxDoc, numDocs, unwrap, wrapLiveDocs
-
Methods inherited from class org.apache.lucene.index.CodecReader
document, getBinaryDocValues, getNormValues, getNumericDocValues, getPointValues, getSortedDocValues, getSortedNumericDocValues, getSortedSetDocValues, getTermVectors, getVectorValues, searchNearestVectors, terms
-
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
-
docMap
final Sorter.DocMap docMap
-
metaData
final LeafMetaData metaData
-
cachedField
private java.lang.String cachedField
-
cachedObject
private java.lang.Object cachedObject
-
cacheIsNorms
private boolean cacheIsNorms
-
cacheStats
private final java.util.Map<java.lang.String,java.lang.Integer> cacheStats
-
-
Constructor Detail
-
SortingCodecReader
private SortingCodecReader(CodecReader in, Sorter.DocMap docMap, LeafMetaData metaData)
-
-
Method Detail
-
wrap
public static CodecReader wrap(CodecReader 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 CodecReader wrap(CodecReader reader, Sorter.DocMap docMap, Sort sort)
Expert: same aswrap(org.apache.lucene.index.CodecReader, Sort)
but operates directly on aSorter.DocMap
.
-
getPostingsReader
public FieldsProducer getPostingsReader()
Description copied from class:CodecReader
Expert: retrieve underlying FieldsProducer- Overrides:
getPostingsReader
in classFilterCodecReader
-
getFieldsReader
public StoredFieldsReader getFieldsReader()
Description copied from class:CodecReader
Expert: retrieve thread-private StoredFieldsReader- Overrides:
getFieldsReader
in classFilterCodecReader
-
newStoredFieldsReader
private StoredFieldsReader newStoredFieldsReader(StoredFieldsReader delegate)
-
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 classFilterCodecReader
-
getPointsReader
public PointsReader getPointsReader()
Description copied from class:CodecReader
Expert: retrieve underlying PointsReader- Overrides:
getPointsReader
in classFilterCodecReader
-
getVectorReader
public KnnVectorsReader getVectorReader()
Description copied from class:CodecReader
Expert: retrieve underlying VectorReader- Overrides:
getVectorReader
in classFilterCodecReader
-
getNormsReader
public NormsProducer getNormsReader()
Description copied from class:CodecReader
Expert: retrieve underlying NormsProducer- Overrides:
getNormsReader
in classFilterCodecReader
-
getDocValuesReader
public DocValuesProducer getDocValuesReader()
Description copied from class:CodecReader
Expert: retrieve underlying DocValuesProducer- Overrides:
getDocValuesReader
in classFilterCodecReader
-
getNumericDocValues
private NumericDocValuesWriter.NumericDVs getNumericDocValues(NumericDocValues oldNumerics) throws java.io.IOException
- Throws:
java.io.IOException
-
getTermVectorsReader
public TermVectorsReader getTermVectorsReader()
Description copied from class:CodecReader
Expert: retrieve thread-private TermVectorsReader- Overrides:
getTermVectorsReader
in classFilterCodecReader
-
newTermVectorsReader
private TermVectorsReader newTermVectorsReader(TermVectorsReader delegate)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
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
-
getMetaData
public LeafMetaData getMetaData()
Description copied from class:LeafReader
Return metadata about this leaf.- Overrides:
getMetaData
in classFilterCodecReader
-
getOrCreateNorms
private <T> T getOrCreateNorms(java.lang.String field, IOSupplier<T> supplier) throws java.io.IOException
- Throws:
java.io.IOException
-
getOrCreate
private <T> T getOrCreate(java.lang.String field, boolean norms, IOSupplier<T> supplier) throws java.io.IOException
- Throws:
java.io.IOException
-
assertCreatedOnlyOnce
private boolean assertCreatedOnlyOnce(java.lang.String field, boolean norms)
-
getOrCreateDV
private <T> T getOrCreateDV(java.lang.String field, IOSupplier<T> supplier) throws java.io.IOException
- Throws:
java.io.IOException
-
-