public class BKDWriter extends Object implements Closeable
config.maxPointsInLeafNode
. The tree is
partially balanced, which means the leaf nodes will have
the requested config.maxPointsInLeafNode
except one that might have less.
Leaf nodes may straddle the two bottom levels of the binary tree.
Values that fall exactly on a cell boundary may be in either cell.
The number of dimensions can be 1 to 8, but every byte[] value is fixed length.
This consumes heap during writing: it allocates a Long[numLeaves]
,
a byte[numLeaves*(1+config.bytesPerDim)]
and then uses up to the specified
maxMBSortInHeap
heap space for writing.
NOTE: This can write at most Integer.MAX_VALUE * config.maxPointsInLeafNode
/ config.bytesPerDim
total points.
Modifier and Type | Field and Description |
---|---|
static String |
CODEC_NAME |
protected BKDConfig |
config
BKD tree configuration
|
static float |
DEFAULT_MAX_MB_SORT_IN_HEAP
Default maximum heap to use, before spilling to (slower) disk
|
protected FixedBitSet |
docsSeen |
protected byte[] |
maxPackedValue
Maximum per-dim values, packed
|
protected byte[] |
minPackedValue
Minimum per-dim values, packed
|
protected long |
pointCount |
static int |
VERSION_CURRENT |
static int |
VERSION_LEAF_STORES_BOUNDS |
static int |
VERSION_LOW_CARDINALITY_LEAVES |
static int |
VERSION_META_FILE |
static int |
VERSION_SELECTIVE_INDEXING |
static int |
VERSION_START |
Constructor and Description |
---|
BKDWriter(int maxDoc,
Directory tempDir,
String tempFileNamePrefix,
BKDConfig config,
double maxMBSortInHeap,
long totalPointCount) |
Modifier and Type | Method and Description |
---|---|
void |
add(byte[] packedValue,
int docID) |
void |
close() |
Runnable |
finish(IndexOutput metaOut,
IndexOutput indexOut,
IndexOutput dataOut)
Writes the BKD tree to the provided
IndexOutput s and returns a Runnable that
writes the index of the tree if at least one point has been added, or null otherwise. |
Runnable |
merge(IndexOutput metaOut,
IndexOutput indexOut,
IndexOutput dataOut,
List<MergeState.DocMap> docMaps,
List<BKDReader> readers)
More efficient bulk-add for incoming
BKDReader s. |
protected int |
split(byte[] minPackedValue,
byte[] maxPackedValue,
int[] parentSplits)
Pick the next dimension to split.
|
Runnable |
writeField(IndexOutput metaOut,
IndexOutput indexOut,
IndexOutput dataOut,
String fieldName,
MutablePointValues reader)
Write a field from a
MutablePointValues . |
public static final String CODEC_NAME
public static final int VERSION_START
public static final int VERSION_LEAF_STORES_BOUNDS
public static final int VERSION_SELECTIVE_INDEXING
public static final int VERSION_LOW_CARDINALITY_LEAVES
public static final int VERSION_META_FILE
public static final int VERSION_CURRENT
public static final float DEFAULT_MAX_MB_SORT_IN_HEAP
protected final BKDConfig config
protected final FixedBitSet docsSeen
protected final byte[] minPackedValue
protected final byte[] maxPackedValue
protected long pointCount
public void add(byte[] packedValue, int docID) throws IOException
IOException
public Runnable writeField(IndexOutput metaOut, IndexOutput indexOut, IndexOutput dataOut, String fieldName, MutablePointValues reader) throws IOException
MutablePointValues
. This way of writing
points is faster than regular writes with add(byte[], int)
since
there is opportunity for reordering points before writing them to
disk. This method does not use transient disk in order to reorder points.IOException
public Runnable merge(IndexOutput metaOut, IndexOutput indexOut, IndexOutput dataOut, List<MergeState.DocMap> docMaps, List<BKDReader> readers) throws IOException
BKDReader
s. This does a merge sort of the already
sorted values and currently only works when numDims==1. This returns -1 if all documents containing
dimensional values were deleted.IOException
public Runnable finish(IndexOutput metaOut, IndexOutput indexOut, IndexOutput dataOut) throws IOException
IndexOutput
s and returns a Runnable
that
writes the index of the tree if at least one point has been added, or null
otherwise.IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
protected int split(byte[] minPackedValue, byte[] maxPackedValue, int[] parentSplits)
minPackedValue
- the min values for all dimensionsmaxPackedValue
- the max values for all dimensionsparentSplits
- how many times each dim has been split on the parent levelsCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.