Skip to content

Commit

Permalink
rename scratch1 to scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
easyice committed Aug 22, 2023
1 parent e58fbee commit 4ebe73f
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 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,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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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) {
Expand All @@ -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]);
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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<BytesRef> packedValues =
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<BytesRef> packedValues =
Expand Down

0 comments on commit 4ebe73f

Please sign in to comment.