public final class BKDRadixSelector
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BKDRadixSelector.PathSlice
Sliced reference to points in an PointWriter.
|
Modifier and Type | Field and Description |
---|---|
private int |
bytesPerDim |
private int |
bytesSorted |
private long[] |
histogram |
private static int |
HISTOGRAM_SIZE |
private static int |
MAX_SIZE_OFFLINE_BUFFER |
private int |
maxPointsSortInHeap |
private byte[] |
offlineBuffer |
private int |
packedBytesLength |
private int[] |
partitionBucket |
private byte[] |
scratch |
private Directory |
tempDir |
private java.lang.String |
tempFileNamePrefix |
Constructor and Description |
---|
BKDRadixSelector(int numDim,
int bytesPerDim,
int maxPointsSortInHeap,
Directory tempDir,
java.lang.String tempFileNamePrefix)
Sole constructor.
|
Modifier and Type | Method and Description |
---|---|
private byte[] |
buildHistogramAndPartition(OfflinePointWriter points,
PointWriter left,
PointWriter right,
long from,
long to,
long partitionPoint,
int iteration,
int baseCommonPrefix,
int dim) |
(package private) void |
checkArgs(long from,
long to,
long partitionPoint) |
private int |
findCommonPrefixAndHistogram(OfflinePointWriter points,
long from,
long to,
int dim,
int dimCommonPrefix) |
private int |
getBucket(int offset,
int commonPrefixPosition,
PointValue pointValue) |
private PointWriter |
getDeltaPointWriter(PointWriter left,
PointWriter right,
long delta,
int iteration) |
private int |
getMaxPointsSortInHeap(PointWriter left,
PointWriter right) |
(package private) PointWriter |
getPointWriter(long count,
java.lang.String desc) |
private byte[] |
heapPartition(HeapPointWriter points,
PointWriter left,
PointWriter right,
int dim,
int from,
int to,
int partitionPoint,
int commonPrefix) |
private byte[] |
heapRadixSelect(HeapPointWriter points,
int dim,
int from,
int to,
int partitionPoint,
int commonPrefix) |
void |
heapRadixSort(HeapPointWriter points,
int from,
int to,
int dim,
int commonPrefixLength)
Sort the heap writer by the specified dim.
|
private void |
offlinePartition(OfflinePointWriter points,
PointWriter left,
PointWriter right,
PointWriter deltaPoints,
long from,
long to,
int dim,
int bytePosition,
long numDocsTiebreak) |
private byte[] |
partitionPointFromCommonPrefix() |
byte[] |
select(BKDRadixSelector.PathSlice points,
BKDRadixSelector.PathSlice[] partitionSlices,
long from,
long to,
long partitionPoint,
int dim,
int dimCommonPrefix)
It uses the provided
points from the given from to the given to
to populate the partitionSlices array holder (length > 1) with two path slices
so the path slice at position 0 contains partition - from points
where the value of the dim is lower or equal to the to -from
points on the slice at position 1. |
private static final int HISTOGRAM_SIZE
private static final int MAX_SIZE_OFFLINE_BUFFER
private final long[] histogram
private final int bytesPerDim
private final int bytesSorted
private final int packedBytesLength
private final int maxPointsSortInHeap
private final byte[] offlineBuffer
private final int[] partitionBucket
private final byte[] scratch
private final Directory tempDir
private final java.lang.String tempFileNamePrefix
public BKDRadixSelector(int numDim, int bytesPerDim, int maxPointsSortInHeap, Directory tempDir, java.lang.String tempFileNamePrefix)
public byte[] select(BKDRadixSelector.PathSlice points, BKDRadixSelector.PathSlice[] partitionSlices, long from, long to, long partitionPoint, int dim, int dimCommonPrefix) throws java.io.IOException
points
from the given from
to the given to
to populate the partitionSlices
array holder (length > 1) with two path slices
so the path slice at position 0 contains partition - from
points
where the value of the dim
is lower or equal to the to -from
points on the slice at position 1.
The dimCommonPrefix
provides a hint for the length of the common prefix length for
the dim
where are partitioning the points.
It return the value of the dim
at the partition point.
If the provided points
is wrapping an OfflinePointWriter
, the
writer is destroyed in the process to save disk space.java.io.IOException
void checkArgs(long from, long to, long partitionPoint)
private int findCommonPrefixAndHistogram(OfflinePointWriter points, long from, long to, int dim, int dimCommonPrefix) throws java.io.IOException
java.io.IOException
private int getBucket(int offset, int commonPrefixPosition, PointValue pointValue)
private byte[] buildHistogramAndPartition(OfflinePointWriter points, PointWriter left, PointWriter right, long from, long to, long partitionPoint, int iteration, int baseCommonPrefix, int dim) throws java.io.IOException
java.io.IOException
private void offlinePartition(OfflinePointWriter points, PointWriter left, PointWriter right, PointWriter deltaPoints, long from, long to, int dim, int bytePosition, long numDocsTiebreak) throws java.io.IOException
java.io.IOException
private byte[] partitionPointFromCommonPrefix()
private byte[] heapPartition(HeapPointWriter points, PointWriter left, PointWriter right, int dim, int from, int to, int partitionPoint, int commonPrefix) throws java.io.IOException
java.io.IOException
private byte[] heapRadixSelect(HeapPointWriter points, int dim, int from, int to, int partitionPoint, int commonPrefix)
public void heapRadixSort(HeapPointWriter points, int from, int to, int dim, int commonPrefixLength)
private PointWriter getDeltaPointWriter(PointWriter left, PointWriter right, long delta, int iteration) throws java.io.IOException
java.io.IOException
private int getMaxPointsSortInHeap(PointWriter left, PointWriter right)
PointWriter getPointWriter(long count, java.lang.String desc) throws java.io.IOException
java.io.IOException