Package org.apache.lucene.index
Class ReaderUtil
java.lang.Object
org.apache.lucene.index.ReaderUtil
Common util methods for dealing with
IndexReaders and IndexReaderContexts.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of partitioning doc IDs by leaf, including the original input ordinals for scatter/gather. -
Method Summary
Modifier and TypeMethodDescriptionstatic IndexReaderContextgetTopLevelContext(IndexReaderContext context) Walks up the reader tree and return the given context's top level reader context, or in other words the reader tree's root context.static ReaderUtil.PartitionedHitspartitionByLeaf(int[] globalDocIds, List<LeafReaderContext> leaves) Partitions global doc IDs by leaf, tracking each doc ID's original position in the input array so callers can reassemble per-leaf results back to input order (scatter/gather).static intsubIndex(int n, int[] docStarts) Returns index of the searcher/reader for documentnin the array used to construct this searcher/reader.static intsubIndex(int n, List<LeafReaderContext> leaves) Returns index of the searcher/reader for documentnin the array used to construct this searcher/reader.
-
Method Details
-
getTopLevelContext
Walks up the reader tree and return the given context's top level reader context, or in other words the reader tree's root context. -
subIndex
public static int subIndex(int n, int[] docStarts) Returns index of the searcher/reader for documentnin the array used to construct this searcher/reader. -
subIndex
Returns index of the searcher/reader for documentnin the array used to construct this searcher/reader. -
partitionByLeaf
public static ReaderUtil.PartitionedHits partitionByLeaf(int[] globalDocIds, List<LeafReaderContext> leaves) Partitions global doc IDs by leaf, tracking each doc ID's original position in the input array so callers can reassemble per-leaf results back to input order (scatter/gather).Doc IDs may be supplied in any order (e.g., ranking order); within each leaf the returned doc IDs are sorted in ascending order. For every partitioned doc ID the result also records its index in the original
globalDocIdsarray, so callers can map per-leaf results back to input order. Callers that do not need the ordinals can simply ignoreReaderUtil.PartitionedHits.ordinalsByLeaf()and useReaderUtil.PartitionedHits.docIdsByLeaf().The input array is not mutated.
- Parameters:
globalDocIds- global doc IDs in any order (e.g., ranking order)leaves- the index reader's leaves- Returns:
- per-leaf sorted doc IDs alongside per-leaf ordinals into the input array
-