public class BKDWriter extends Object implements Closeable
maxPointsInLeafNode
. The tree is
fully balanced, which means the leaf nodes will have between 50% and 100% of
the requested maxPointsInLeafNode
. 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.
See this paper for details.
This consumes heap during writing: it allocates a LongBitSet(numPoints)
,
and then uses up to the specified maxMBSortInHeap
heap space for writing.
NOTE: This can write at most Integer.MAX_VALUE * maxPointsInLeafNode
total points.
Modifier and Type | Field and Description |
---|---|
protected int |
bytesPerDim
How many bytes each value in each dimension takes.
|
static String |
CODEC_NAME |
static float |
DEFAULT_MAX_MB_SORT_IN_HEAP
Default maximum heap to use, before spilling to (slower) disk
|
static int |
DEFAULT_MAX_POINTS_IN_LEAF_NODE
Default maximum number of point in each leaf block
|
protected FixedBitSet |
docsSeen |
protected boolean |
longOrds
true if we have so many values that we must write ords using long (8 bytes) instead of int (4 bytes)
|
static int |
MAX_DIMS
Maximum number of dimensions
|
protected byte[] |
maxPackedValue
Maximum per-dim values, packed
|
protected int |
maxPointsInLeafNode |
protected byte[] |
minPackedValue
Minimum per-dim values, packed
|
protected int |
numDims
How many dimensions we are indexing
|
protected OfflineSorter.BufferSize |
offlineSorterBufferMB
How much heap OfflineSorter is allowed to use
|
protected int |
offlineSorterMaxTempFiles
How much heap OfflineSorter is allowed to use
|
protected int |
packedBytesLength
numDims * bytesPerDim
|
protected long |
pointCount |
protected boolean |
singleValuePerDoc
True if every document has at most one value.
|
static int |
VERSION_COMPRESSED_DOC_IDS |
static int |
VERSION_COMPRESSED_VALUES |
static int |
VERSION_CURRENT |
static int |
VERSION_IMPLICIT_SPLIT_DIM_1D |
static int |
VERSION_PACKED_INDEX |
static int |
VERSION_START |
Modifier | Constructor and Description |
---|---|
|
BKDWriter(int maxDoc,
Directory tempDir,
String tempFileNamePrefix,
int numDims,
int bytesPerDim,
int maxPointsInLeafNode,
double maxMBSortInHeap,
long totalPointCount,
boolean singleValuePerDoc) |
protected |
BKDWriter(int maxDoc,
Directory tempDir,
String tempFileNamePrefix,
int numDims,
int bytesPerDim,
int maxPointsInLeafNode,
double maxMBSortInHeap,
long totalPointCount,
boolean singleValuePerDoc,
boolean longOrds,
long offlineSorterBufferMB,
int offlineSorterMaxTempFiles) |
Modifier and Type | Method and Description |
---|---|
void |
add(byte[] packedValue,
int docID) |
void |
close() |
long |
finish(IndexOutput out)
Writes the BKD tree to the provided
IndexOutput and returns the file offset where index was written. |
long |
getPointCount()
How many points have been added so far
|
long |
merge(IndexOutput out,
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.
|
static void |
verifyParams(int numDims,
int maxPointsInLeafNode,
double maxMBSortInHeap,
long totalPointCount) |
long |
writeField(IndexOutput out,
String fieldName,
MutablePointsReader reader)
Write a field from a
MutablePointsReader . |
public static final String CODEC_NAME
public static final int VERSION_START
public static final int VERSION_COMPRESSED_DOC_IDS
public static final int VERSION_COMPRESSED_VALUES
public static final int VERSION_IMPLICIT_SPLIT_DIM_1D
public static final int VERSION_PACKED_INDEX
public static final int VERSION_CURRENT
public static final int DEFAULT_MAX_POINTS_IN_LEAF_NODE
public static final float DEFAULT_MAX_MB_SORT_IN_HEAP
public static final int MAX_DIMS
protected final int numDims
protected final int bytesPerDim
protected final int packedBytesLength
protected final FixedBitSet docsSeen
protected final int maxPointsInLeafNode
protected final byte[] minPackedValue
protected final byte[] maxPackedValue
protected long pointCount
protected final boolean longOrds
protected final boolean singleValuePerDoc
protected final OfflineSorter.BufferSize offlineSorterBufferMB
protected final int offlineSorterMaxTempFiles
public BKDWriter(int maxDoc, Directory tempDir, String tempFileNamePrefix, int numDims, int bytesPerDim, int maxPointsInLeafNode, double maxMBSortInHeap, long totalPointCount, boolean singleValuePerDoc) throws IOException
IOException
protected BKDWriter(int maxDoc, Directory tempDir, String tempFileNamePrefix, int numDims, int bytesPerDim, int maxPointsInLeafNode, double maxMBSortInHeap, long totalPointCount, boolean singleValuePerDoc, boolean longOrds, long offlineSorterBufferMB, int offlineSorterMaxTempFiles) throws IOException
IOException
public static void verifyParams(int numDims, int maxPointsInLeafNode, double maxMBSortInHeap, long totalPointCount)
public void add(byte[] packedValue, int docID) throws IOException
IOException
public long getPointCount()
public long writeField(IndexOutput out, String fieldName, MutablePointsReader reader) throws IOException
MutablePointsReader
. 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 long merge(IndexOutput out, 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 long finish(IndexOutput out) throws IOException
IndexOutput
and returns the file offset where index was written.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-2017 Apache Software Foundation. All Rights Reserved.