Apache Lucene open-source search software
fix overflows in compound assignments (#11938)
Robert Muirc5da727493b7
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.javaindex 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 {@Overridepublic long cost() {- return cost;+ return size;}@Overridediff --git a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.javaindex 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 matchedfinal 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.javaindex 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) */