From e58fbee1d16435cfbb7ab18845fb7194ce9055c7 Mon Sep 17 00:00:00 2001 From: easyice <80152403@qq.com> Date: Thu, 17 Aug 2023 20:32:59 +0800 Subject: [PATCH 1/3] init --- lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java | 2 -- 1 file changed, 2 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 b4b8f1fe66d0..c37bb6df5bf7 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 @@ -104,7 +104,6 @@ public class BKDWriter implements Closeable { final byte[] scratchDiff; final byte[] scratch1; - final byte[] scratch2; final BytesRef scratchBytesRef1 = new BytesRef(); final BytesRef scratchBytesRef2 = new BytesRef(); final int[] commonPrefixLengths; @@ -157,7 +156,6 @@ public BKDWriter( scratchDiff = new byte[config.bytesPerDim]; scratch1 = new byte[config.packedBytesLength]; - scratch2 = new byte[config.packedBytesLength]; commonPrefixLengths = new int[config.numDims]; minPackedValue = new byte[config.packedIndexBytesLength]; From 4ebe73f134452ff7f8c1fa679bbde9853b71132c Mon Sep 17 00:00:00 2001 From: easyice <80152403@qq.com> Date: Tue, 22 Aug 2023 10:45:42 +0800 Subject: [PATCH 2/3] rename scratch1 to scratch --- .../org/apache/lucene/util/bkd/BKDWriter.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 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 c37bb6df5bf7..5bea2e4ac5ae 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 @@ -103,7 +103,7 @@ public class BKDWriter implements Closeable { final double maxMBSortInHeap; final byte[] scratchDiff; - final byte[] scratch1; + final byte[] scratch; final BytesRef scratchBytesRef1 = new BytesRef(); final BytesRef scratchBytesRef2 = new BytesRef(); final int[] commonPrefixLengths; @@ -155,7 +155,7 @@ public BKDWriter( docsSeen = new FixedBitSet(maxDoc); scratchDiff = new byte[config.bytesPerDim]; - scratch1 = new byte[config.packedBytesLength]; + scratch = new byte[config.packedBytesLength]; commonPrefixLengths = new int[config.numDims]; minPackedValue = new byte[config.packedIndexBytesLength]; @@ -1321,21 +1321,21 @@ private void writeLowCardinalityLeafBlockPackedValues( writeActualBounds(out, commonPrefixLengths, count, packedValues); } BytesRef value = packedValues.apply(0); - System.arraycopy(value.bytes, value.offset, scratch1, 0, config.packedBytesLength); + System.arraycopy(value.bytes, value.offset, scratch, 0, config.packedBytesLength); int cardinality = 1; for (int i = 1; i < count; i++) { value = packedValues.apply(i); for (int dim = 0; dim < config.numDims; dim++) { final int start = dim * config.bytesPerDim; - if (equalsPredicate.test(value.bytes, value.offset + start, scratch1, start) == false) { + if (equalsPredicate.test(value.bytes, value.offset + start, scratch, start) == false) { out.writeVInt(cardinality); for (int j = 0; j < config.numDims; j++) { out.writeBytes( - scratch1, + scratch, j * config.bytesPerDim + commonPrefixLengths[j], config.bytesPerDim - commonPrefixLengths[j]); } - System.arraycopy(value.bytes, value.offset, scratch1, 0, config.packedBytesLength); + System.arraycopy(value.bytes, value.offset, scratch, 0, config.packedBytesLength); cardinality = 1; break; } else if (dim == config.numDims - 1) { @@ -1346,7 +1346,7 @@ private void writeLowCardinalityLeafBlockPackedValues( out.writeVInt(cardinality); for (int i = 0; i < config.numDims; i++) { out.writeBytes( - scratch1, + scratch, i * config.bytesPerDim + commonPrefixLengths[i], config.bytesPerDim - commonPrefixLengths[i]); } @@ -1543,8 +1543,8 @@ protected int split(byte[] minPackedValue, byte[] maxPackedValue, int[] parentSp int splitDim = -1; for (int dim = 0; dim < config.numIndexDims; dim++) { NumericUtils.subtract(config.bytesPerDim, dim, maxPackedValue, minPackedValue, scratchDiff); - if (splitDim == -1 || comparator.compare(scratchDiff, 0, scratch1, 0) > 0) { - System.arraycopy(scratchDiff, 0, scratch1, 0, config.bytesPerDim); + if (splitDim == -1 || comparator.compare(scratchDiff, 0, scratch, 0) > 0) { + System.arraycopy(scratchDiff, 0, scratch, 0, config.bytesPerDim); splitDim = dim; } } @@ -1686,8 +1686,8 @@ private void build( // Write the common prefixes: reader.getValue(from, scratchBytesRef1); System.arraycopy( - scratchBytesRef1.bytes, scratchBytesRef1.offset, scratch1, 0, config.packedBytesLength); - writeCommonPrefixes(out, commonPrefixLengths, scratch1); + scratchBytesRef1.bytes, scratchBytesRef1.offset, scratch, 0, config.packedBytesLength); + writeCommonPrefixes(out, commonPrefixLengths, scratch); // Write the full values: IntFunction packedValues = @@ -1884,8 +1884,8 @@ private void build( int from = Math.toIntExact(points.start); int to = Math.toIntExact(points.start + points.count); - // we store common prefix on scratch1 - computeCommonPrefixLength(heapSource, scratch1, from, to); + // we store common prefix on scratch + computeCommonPrefixLength(heapSource, scratch, from, to); int sortedDim = 0; int sortedDimCardinality = Integer.MAX_VALUE; @@ -1940,7 +1940,7 @@ private void build( // from the index, much like how terms dict does so from the FST: // Write the common prefixes: - writeCommonPrefixes(out, commonPrefixLengths, scratch1); + writeCommonPrefixes(out, commonPrefixLengths, scratch); // Write the full values: IntFunction packedValues = From 127d0790b8d59b3e57dd43876e7bf9c713daa1bc Mon Sep 17 00:00:00 2001 From: easyice <80152403@qq.com> Date: Tue, 22 Aug 2023 12:45:49 +0800 Subject: [PATCH 3/3] iter --- lucene/CHANGES.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 41ee5343e090..3a88efece170 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -214,6 +214,8 @@ Other * GITHUB#12428: Replace consecutive close() calls and close() calls with null checks with IOUtils.close(). (Shubham Chaudhary) +* GITHUB#12512: Remove unused variable in BKDWriter. (Chao Zhang) + ======================== Lucene 9.7.0 ======================= API Changes