You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2022/11/16 16:06:45 UTC

[lucene] branch branch_9x updated: fix overflows in compound assignments (#11938)

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

rmuir 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 fb7d65cb667 fix overflows in compound assignments (#11938)
fb7d65cb667 is described below

commit fb7d65cb66754b41fe01a999a3bca7e75da7e2c7
Author: Robert Muir <rm...@apache.org>
AuthorDate: Wed Nov 16 10:53:34 2022 -0500

    fix overflows in compound assignments (#11938)
    
    * Count points as longs.
    
    * Simplify KnnVectorsWriter.
    
    Co-authored-by: Adrien Grand <jp...@gmail.com>
---
 .../core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java   | 7 ++-----
 lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java | 4 ++--
 lucene/core/src/java/org/apache/lucene/util/OfflineSorter.java     | 2 +-
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java
index 1ae41c8be10..e15c6d8bc07 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java
@@ -108,7 +108,6 @@ public abstract class KnnVectorsWriter implements Accountable, Closeable {
   protected static class MergedVectorValues extends VectorValues {
     private final List<VectorValuesSub> subs;
     private final DocIDMerger<VectorValuesSub> docIdMerger;
-    private final int cost;
     private final int size;
 
     private int docId;
@@ -136,12 +135,10 @@ public abstract class KnnVectorsWriter implements Accountable, Closeable {
         throws IOException {
       this.subs = subs;
       docIdMerger = DocIDMerger.of(subs, mergeState.needsIndexSort);
-      int totalCost = 0, totalSize = 0;
+      int totalSize = 0;
       for (VectorValuesSub sub : subs) {
-        totalCost += sub.values.cost();
         totalSize += sub.values.size();
       }
-      cost = totalCost;
       size = totalSize;
       docId = -1;
     }
@@ -184,7 +181,7 @@ public abstract class KnnVectorsWriter implements Accountable, Closeable {
 
     @Override
     public long cost() {
-      return cost;
+      return size;
     }
 
     @Override
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 81f838c4165..60875bffe81 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
@@ -415,7 +415,7 @@ public abstract class PointRangeQuery extends Query {
           BiFunction<byte[], byte[], Relation> nodeComparator,
           Predicate<byte[]> leafComparator)
           throws IOException {
-        final int[] matchingNodeCount = {0};
+        final long[] matchingNodeCount = {0};
         // create a custom IntersectVisitor that records the number of leafNodes that matched
         final IntersectVisitor visitor =
             new IntersectVisitor() {
@@ -446,7 +446,7 @@ public abstract class PointRangeQuery extends Query {
       }
 
       private void pointCount(
-          IntersectVisitor visitor, PointValues.PointTree pointTree, int[] matchingNodeCount)
+          IntersectVisitor visitor, PointValues.PointTree pointTree, long[] matchingNodeCount)
           throws IOException {
         Relation r = visitor.compare(pointTree.getMinPackedValue(), pointTree.getMaxPackedValue());
         switch (r) {
diff --git a/lucene/core/src/java/org/apache/lucene/util/OfflineSorter.java b/lucene/core/src/java/org/apache/lucene/util/OfflineSorter.java
index e479f110f8d..2aefd238fa8 100644
--- a/lucene/core/src/java/org/apache/lucene/util/OfflineSorter.java
+++ b/lucene/core/src/java/org/apache/lucene/util/OfflineSorter.java
@@ -141,7 +141,7 @@ public class OfflineSorter {
     /** number of partition merges */
     public int mergeRounds;
     /** number of lines of data read */
-    public int lineCount;
+    public long lineCount;
     /** time spent merging sorted partitions (in milliseconds) */
     public final AtomicLong mergeTimeMS = new AtomicLong();
     /** time spent sorting data (in milliseconds) */