Package org.apache.lucene.util.bkd
Class BKDReader
java.lang.Object
org.apache.lucene.index.PointValues
org.apache.lucene.util.bkd.BKDReader
Handles intersection of an multi-dimensional shape in byte[] space with a block KD-tree previously written with
BKDWriter.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classReusableDocIdSetIteratorto handle low cardinality leaves.classUsed to walk the off-heap index.static final classUsed to track all state for a single call tointersect(org.apache.lucene.index.PointValues.IntersectVisitor).Nested classes/interfaces inherited from class org.apache.lucene.index.PointValues
PointValues.IntersectVisitor, PointValues.Relation -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final BKDConfig(package private) final int(package private) final IndexInput(package private) final int(package private) final byte[](package private) final long(package private) final byte[](package private) final int(package private) final IndexInput(package private) final long(package private) final intFields inherited from class org.apache.lucene.index.PointValues
MAX_DIMENSIONS, MAX_INDEX_DIMENSIONS, MAX_NUM_BYTES -
Constructor Summary
ConstructorsConstructorDescriptionBKDReader(IndexInput metaIn, IndexInput indexIn, IndexInput dataIn) Caller must pre-seek the providedIndexInputto the index location thatBKDWriter.finish(org.apache.lucene.store.IndexOutput, org.apache.lucene.store.IndexOutput, org.apache.lucene.store.IndexOutput)returned. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddAll(BKDReader.IntersectState state, boolean grown) Fast path: this is called when the query box fully encompasses all cells under this node.longEstimate the number of points that would be visited byPointValues.intersect(org.apache.lucene.index.PointValues.IntersectVisitor)with the givenPointValues.IntersectVisitor.private longestimatePointCount(BKDReader.IntersectState state, byte[] cellMinPacked, byte[] cellMaxPacked) intReturns the number of bytes per dimensionintReturns the total number of documents that have indexed at least one point.Create a newBKDReader.IntersectStatebyte[]Returns maximum value for each dimension, packed, or null ifPointValues.size(org.apache.lucene.index.IndexReader, java.lang.String)is0(package private) longbyte[]Returns minimum value for each dimension, packed, or null ifPointValues.size(org.apache.lucene.index.IndexReader, java.lang.String)is0intReturns how many dimensions are represented in the valuesintReturns how many dimensions are used for the indexprivate intvoidintersect(PointValues.IntersectVisitor visitor) Finds all documents and points matching the provided visitor.private voidintersect(BKDReader.IntersectState state, byte[] cellMinPacked, byte[] cellMaxPacked) booleanisLeafNode(int nodeID) private voidreadCommonPrefixes(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in) private int(package private) intreadDocIDs(IndexInput in, long blockFP, BKDReader.BKDReaderDocIDSetIterator iterator) private voidreadMinMax(int[] commonPrefixLengths, byte[] minPackedValue, byte[] maxPackedValue, IndexInput in) longsize()Returns the total number of indexed points across all documents.private voidvisitCompressedDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor, int compressedDim) private voidvisitDocIDs(IndexInput in, long blockFP, PointValues.IntersectVisitor visitor) (package private) voidvisitDocValues(int[] commonPrefixLengths, byte[] scratchDataPackedValue, byte[] scratchMinIndexPackedValue, byte[] scratchMaxIndexPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) (package private) voidvisitDocValuesNoCardinality(int[] commonPrefixLengths, byte[] scratchDataPackedValue, byte[] scratchMinIndexPackedValue, byte[] scratchMaxIndexPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) (package private) voidvisitDocValuesWithCardinality(int[] commonPrefixLengths, byte[] scratchDataPackedValue, byte[] scratchMinIndexPackedValue, byte[] scratchMaxIndexPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) voidvisitLeafBlockValues(BKDReader.IndexTree index, BKDReader.IntersectState state) Visits all docIDs and packed values in a single leaf blockprivate voidvisitSparseRawDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) private voidvisitUniqueRawDocValues(byte[] scratchPackedValue, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) Methods inherited from class org.apache.lucene.index.PointValues
estimateDocCount, getDocCount, getMaxPackedValue, getMinPackedValue, size
-
Field Details
-
leafNodeOffset
final int leafNodeOffset -
config
-
numLeaves
final int numLeaves -
in
-
minPackedValue
final byte[] minPackedValue -
maxPackedValue
final byte[] maxPackedValue -
pointCount
final long pointCount -
docCount
final int docCount -
version
final int version -
minLeafBlockFP
final long minLeafBlockFP -
packedIndex
-
-
Constructor Details
-
BKDReader
Caller must pre-seek the providedIndexInputto the index location thatBKDWriter.finish(org.apache.lucene.store.IndexOutput, org.apache.lucene.store.IndexOutput, org.apache.lucene.store.IndexOutput)returned. BKD tree is always stored off-heap.- Throws:
IOException
-
-
Method Details
-
getMinLeafBlockFP
long getMinLeafBlockFP() -
getTreeDepth
private int getTreeDepth() -
intersect
Description copied from class:PointValuesFinds all documents and points matching the provided visitor. This method does not enforce live documents, so it's up to the caller to test whether each document is deleted, if necessary.- Specified by:
intersectin classPointValues- Throws:
IOException
-
estimatePointCount
Description copied from class:PointValuesEstimate the number of points that would be visited byPointValues.intersect(org.apache.lucene.index.PointValues.IntersectVisitor)with the givenPointValues.IntersectVisitor. This should run many times faster thanPointValues.intersect(IntersectVisitor).- Specified by:
estimatePointCountin classPointValues
-
addAll
Fast path: this is called when the query box fully encompasses all cells under this node.- Throws:
IOException
-
getIntersectState
Create a newBKDReader.IntersectState -
visitLeafBlockValues
public void visitLeafBlockValues(BKDReader.IndexTree index, BKDReader.IntersectState state) throws IOException Visits all docIDs and packed values in a single leaf block- Throws:
IOException
-
visitDocIDs
private void visitDocIDs(IndexInput in, long blockFP, PointValues.IntersectVisitor visitor) throws IOException - Throws:
IOException
-
readDocIDs
int readDocIDs(IndexInput in, long blockFP, BKDReader.BKDReaderDocIDSetIterator iterator) throws IOException - Throws:
IOException
-
visitDocValues
void visitDocValues(int[] commonPrefixLengths, byte[] scratchDataPackedValue, byte[] scratchMinIndexPackedValue, byte[] scratchMaxIndexPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) throws IOException - Throws:
IOException
-
visitDocValuesNoCardinality
void visitDocValuesNoCardinality(int[] commonPrefixLengths, byte[] scratchDataPackedValue, byte[] scratchMinIndexPackedValue, byte[] scratchMaxIndexPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) throws IOException - Throws:
IOException
-
visitDocValuesWithCardinality
void visitDocValuesWithCardinality(int[] commonPrefixLengths, byte[] scratchDataPackedValue, byte[] scratchMinIndexPackedValue, byte[] scratchMaxIndexPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) throws IOException - Throws:
IOException
-
readMinMax
private void readMinMax(int[] commonPrefixLengths, byte[] minPackedValue, byte[] maxPackedValue, IndexInput in) throws IOException - Throws:
IOException
-
visitSparseRawDocValues
private void visitSparseRawDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) throws IOException - Throws:
IOException
-
visitUniqueRawDocValues
private void visitUniqueRawDocValues(byte[] scratchPackedValue, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor) throws IOException - Throws:
IOException
-
visitCompressedDocValues
private void visitCompressedDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, BKDReader.BKDReaderDocIDSetIterator scratchIterator, int count, PointValues.IntersectVisitor visitor, int compressedDim) throws IOException - Throws:
IOException
-
readCompressedDim
- Throws:
IOException
-
readCommonPrefixes
private void readCommonPrefixes(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in) throws IOException - Throws:
IOException
-
intersect
private void intersect(BKDReader.IntersectState state, byte[] cellMinPacked, byte[] cellMaxPacked) throws IOException - Throws:
IOException
-
estimatePointCount
private long estimatePointCount(BKDReader.IntersectState state, byte[] cellMinPacked, byte[] cellMaxPacked) -
getMinPackedValue
public byte[] getMinPackedValue()Description copied from class:PointValuesReturns minimum value for each dimension, packed, or null ifPointValues.size(org.apache.lucene.index.IndexReader, java.lang.String)is0- Specified by:
getMinPackedValuein classPointValues
-
getMaxPackedValue
public byte[] getMaxPackedValue()Description copied from class:PointValuesReturns maximum value for each dimension, packed, or null ifPointValues.size(org.apache.lucene.index.IndexReader, java.lang.String)is0- Specified by:
getMaxPackedValuein classPointValues
-
getNumDimensions
public int getNumDimensions()Description copied from class:PointValuesReturns how many dimensions are represented in the values- Specified by:
getNumDimensionsin classPointValues
-
getNumIndexDimensions
public int getNumIndexDimensions()Description copied from class:PointValuesReturns how many dimensions are used for the index- Specified by:
getNumIndexDimensionsin classPointValues
-
getBytesPerDimension
public int getBytesPerDimension()Description copied from class:PointValuesReturns the number of bytes per dimension- Specified by:
getBytesPerDimensionin classPointValues
-
size
public long size()Description copied from class:PointValuesReturns the total number of indexed points across all documents.- Specified by:
sizein classPointValues
-
getDocCount
public int getDocCount()Description copied from class:PointValuesReturns the total number of documents that have indexed at least one point.- Specified by:
getDocCountin classPointValues
-
isLeafNode
public boolean isLeafNode(int nodeID)
-