Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused variable in BKDWriter #12512

Merged
merged 3 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 14 additions & 16 deletions lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public class BKDWriter implements Closeable {
final double maxMBSortInHeap;

final byte[] scratchDiff;
final byte[] scratch1;
final byte[] scratch2;
final byte[] scratch;
final BytesRef scratchBytesRef1 = new BytesRef();
final BytesRef scratchBytesRef2 = new BytesRef();
final int[] commonPrefixLengths;
Expand Down Expand Up @@ -156,8 +155,7 @@ public BKDWriter(
docsSeen = new FixedBitSet(maxDoc);

scratchDiff = new byte[config.bytesPerDim];
scratch1 = new byte[config.packedBytesLength];
scratch2 = new byte[config.packedBytesLength];
scratch = new byte[config.packedBytesLength];
commonPrefixLengths = new int[config.numDims];

minPackedValue = new byte[config.packedIndexBytesLength];
Expand Down Expand Up @@ -1323,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) {
Expand All @@ -1348,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]);
}
Expand Down Expand Up @@ -1545,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;
}
}
Expand Down Expand Up @@ -1688,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<BytesRef> packedValues =
Expand Down Expand Up @@ -1886,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;
Expand Down Expand Up @@ -1942,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<BytesRef> packedValues =
Expand Down