You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2021/10/28 15:07:44 UTC
[lucene] branch main updated: LUCENE-10145: Revert change to
computeMinMax.
This is an automated email from the ASF dual-hosted git repository.
jpountz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new 53b40e0 LUCENE-10145: Revert change to computeMinMax.
53b40e0 is described below
commit 53b40e0fb7048dcc4778310850c859a8ae635272
Author: Adrien Grand <jp...@gmail.com>
AuthorDate: Thu Oct 28 16:23:00 2021 +0200
LUCENE-10145: Revert change to computeMinMax.
This part of the change would call `ArrayUtil#getUnsignedComparator` on a
length that is rarely 4 or 8. In such cases it's better to use
`Arrays#compareUnsigned`.
---
.../src/java/org/apache/lucene/util/bkd/BKDWriter.java | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
index 2ca964b..ab801d9 100644
--- a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
@@ -1394,12 +1394,24 @@ public class BKDWriter implements Closeable {
BytesRef first = packedValues.apply(0);
min.copyBytes(first.bytes, first.offset + offset, length);
max.copyBytes(first.bytes, first.offset + offset, length);
- final ByteArrayComparator comparator = ArrayUtil.getUnsignedComparator(length);
for (int i = 1; i < count; ++i) {
BytesRef candidate = packedValues.apply(i);
- if (comparator.compare(min.bytes(), 0, candidate.bytes, candidate.offset + offset) > 0) {
+ if (Arrays.compareUnsigned(
+ min.bytes(),
+ 0,
+ length,
+ candidate.bytes,
+ candidate.offset + offset,
+ candidate.offset + offset + length)
+ > 0) {
min.copyBytes(candidate.bytes, candidate.offset + offset, length);
- } else if (comparator.compare(max.bytes(), 0, candidate.bytes, candidate.offset + offset)
+ } else if (Arrays.compareUnsigned(
+ max.bytes(),
+ 0,
+ length,
+ candidate.bytes,
+ candidate.offset + offset,
+ candidate.offset + offset + length)
< 0) {
max.copyBytes(candidate.bytes, candidate.offset + offset, length);
}