mirror of https://github.com/apache/lucene.git
Speed up 1D BKD merging. (#12079)
On the NYC taxis dataset on my local machine, switching from `Arrays#compareUnsigned` to `ArrayUtil#getUnsignedComparator` yielded a 15% speedup of BKD merging.
This commit is contained in:
parent
59b17452aa
commit
729fedcbac
|
@ -278,6 +278,8 @@ Optimizations
|
|||
|
||||
* GITHUB#12017: Aggressive count in BooleanWeight. (Lu Xugang)
|
||||
|
||||
* GITHUB#12079: Faster merging of 1D points. (Adrien Grand)
|
||||
|
||||
|
||||
Other
|
||||
---------------------
|
||||
|
|
|
@ -366,19 +366,19 @@ public class BKDWriter implements Closeable {
|
|||
}
|
||||
|
||||
private static class BKDMergeQueue extends PriorityQueue<MergeReader> {
|
||||
private final int bytesPerDim;
|
||||
private final ArrayUtil.ByteArrayComparator comparator;
|
||||
|
||||
public BKDMergeQueue(int bytesPerDim, int maxSize) {
|
||||
super(maxSize);
|
||||
this.bytesPerDim = bytesPerDim;
|
||||
this.comparator = ArrayUtil.getUnsignedComparator(bytesPerDim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean lessThan(MergeReader a, MergeReader b) {
|
||||
assert a != b;
|
||||
|
||||
int cmp =
|
||||
Arrays.compareUnsigned(a.packedValue, 0, bytesPerDim, b.packedValue, 0, bytesPerDim);
|
||||
int cmp = comparator.compare(a.packedValue, 0, b.packedValue, 0);
|
||||
|
||||
if (cmp < 0) {
|
||||
return true;
|
||||
} else if (cmp > 0) {
|
||||
|
|
Loading…
Reference in New Issue