You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2024/08/09 21:09:05 UTC

(lucene) branch branch_9x updated: Minor offset tracking tweak in PointRangeQuery #matches and #relate (#13599)

This is an automated email from the ASF dual-hosted git repository.

gsmiller pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new ef28015c0af Minor offset tracking tweak in PointRangeQuery #matches and #relate (#13599)
ef28015c0af is described below

commit ef28015c0af705e8024eb6069f3b91ec40909c0e
Author: Ankit Jain <ak...@amazon.com>
AuthorDate: Sat Aug 10 02:20:47 2024 +0530

    Minor offset tracking tweak in PointRangeQuery #matches and #relate (#13599)
---
 .../core/src/java/org/apache/lucene/search/PointRangeQuery.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
index ad5f7bd9a04..2993b790c55 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
@@ -128,8 +128,8 @@ public abstract class PointRangeQuery extends Query {
       private final ByteArrayComparator comparator = ArrayUtil.getUnsignedComparator(bytesPerDim);
 
       private boolean matches(byte[] packedValue) {
-        for (int dim = 0; dim < numDims; dim++) {
-          int offset = dim * bytesPerDim;
+        int offset = 0;
+        for (int dim = 0; dim < numDims; dim++, offset += bytesPerDim) {
           if (comparator.compare(packedValue, offset, lowerPoint, offset) < 0) {
             // Doc's value is too low, in this dimension
             return false;
@@ -145,9 +145,9 @@ public abstract class PointRangeQuery extends Query {
       private Relation relate(byte[] minPackedValue, byte[] maxPackedValue) {
 
         boolean crosses = false;
+        int offset = 0;
 
-        for (int dim = 0; dim < numDims; dim++) {
-          int offset = dim * bytesPerDim;
+        for (int dim = 0; dim < numDims; dim++, offset += bytesPerDim) {
 
           if (comparator.compare(minPackedValue, offset, upperPoint, offset) > 0
               || comparator.compare(maxPackedValue, offset, lowerPoint, offset) < 0) {