BKDWriter

open class BKDWriter(maxDoc: Int, tempDir: Directory, tempFileNamePrefix: String, config: BKDConfig, maxMBSortInHeap: Double, totalPointCount: Long) : AutoCloseable

Recursively builds a block KD-tree to assign all incoming points in N-dim space to smaller and smaller N-dim rectangles (cells) until the number of points in a given rectangle is <= 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.

Constructors

Link copied to clipboard
constructor(maxDoc: Int, tempDir: Directory, tempFileNamePrefix: String, config: BKDConfig, maxMBSortInHeap: Double, totalPointCount: Long)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun add(packedValue: ByteArray, docID: Int)
Link copied to clipboard
open override fun close()
Link copied to clipboard
fun computeCommonPrefixLength(heapPointWriter: HeapPointWriter, commonPrefix: ByteArray, from: Int, to: Int)
Link copied to clipboard
fun finish(metaOut: IndexOutput, indexOut: IndexOutput, dataOut: IndexOutput): IORunnable?

Writes the BKD tree to the provided IndexOutputs and returns a Runnable that writes the index of the tree if at least one point has been added, or null otherwise.

Link copied to clipboard
fun merge(metaOut: IndexOutput, indexOut: IndexOutput, dataOut: IndexOutput, docMaps: MutableList<MergeState.DocMap>?, readers: MutableList<PointValues>): IORunnable?

More efficient bulk-add for incoming PointValuess. 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.

Link copied to clipboard
fun writeField(metaOut: IndexOutput, indexOut: IndexOutput, dataOut: IndexOutput, fieldName: String, reader: MutablePointTree): IORunnable?

Write a field from a MutablePointTree. This way of writing points is faster than regular writes with BKDWriter.add since there is opportunity for reordering points before writing them to disk. This method does not use transient disk in order to reorder points.