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#12017: Aggressive count in BooleanWeight. (Lu Xugang)
|
||||||
|
|
||||||
|
* GITHUB#12079: Faster merging of 1D points. (Adrien Grand)
|
||||||
|
|
||||||
|
|
||||||
Other
|
Other
|
||||||
---------------------
|
---------------------
|
||||||
|
|
|
@ -366,19 +366,19 @@ public class BKDWriter implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BKDMergeQueue extends PriorityQueue<MergeReader> {
|
private static class BKDMergeQueue extends PriorityQueue<MergeReader> {
|
||||||
private final int bytesPerDim;
|
private final ArrayUtil.ByteArrayComparator comparator;
|
||||||
|
|
||||||
public BKDMergeQueue(int bytesPerDim, int maxSize) {
|
public BKDMergeQueue(int bytesPerDim, int maxSize) {
|
||||||
super(maxSize);
|
super(maxSize);
|
||||||
this.bytesPerDim = bytesPerDim;
|
this.comparator = ArrayUtil.getUnsignedComparator(bytesPerDim);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean lessThan(MergeReader a, MergeReader b) {
|
public boolean lessThan(MergeReader a, MergeReader b) {
|
||||||
assert a != b;
|
assert a != b;
|
||||||
|
|
||||||
int cmp =
|
int cmp = comparator.compare(a.packedValue, 0, b.packedValue, 0);
|
||||||
Arrays.compareUnsigned(a.packedValue, 0, bytesPerDim, b.packedValue, 0, bytesPerDim);
|
|
||||||
if (cmp < 0) {
|
if (cmp < 0) {
|
||||||
return true;
|
return true;
|
||||||
} else if (cmp > 0) {
|
} else if (cmp > 0) {
|
||||||
|
|
Loading…
Reference in New Issue