Skip to content

Commit 6b386e7

Browse files
authored
LUCENE-9047: Remove unnecessary ByteBuffersDataOutput in BKD writer (#102)
1 parent 1b1fd72 commit 6b386e7

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,6 @@ public Runnable merge(
649649
return oneDimWriter.finish();
650650
}
651651

652-
// Reused when writing leaf blocks
653-
private final ByteBuffersDataOutput scratchOut = ByteBuffersDataOutput.newResettableInstance();
654-
655652
private class OneDimensionBKDWriter {
656653

657654
final IndexOutput metaOut, indexOut, dataOut;
@@ -820,9 +817,8 @@ private void writeLeafBlock(int leafCardinality) throws IOException {
820817

821818
commonPrefixLengths[0] = prefix;
822819

823-
assert scratchOut.size() == 0;
824-
writeLeafBlockDocs(scratchOut, leafDocs, 0, leafCount);
825-
writeCommonPrefixes(scratchOut, commonPrefixLengths, leafValues);
820+
writeLeafBlockDocs(dataOut, leafDocs, 0, leafCount);
821+
writeCommonPrefixes(dataOut, commonPrefixLengths, leafValues);
826822

827823
scratchBytesRef1.length = config.packedBytesLength;
828824
scratchBytesRef1.bytes = leafValues;
@@ -848,9 +844,7 @@ assert valuesInOrderAndBounds(
848844
leafDocs,
849845
0);
850846
writeLeafBlockPackedValues(
851-
scratchOut, commonPrefixLengths, leafCount, 0, packedValues, leafCardinality);
852-
scratchOut.copyTo(dataOut);
853-
scratchOut.reset();
847+
dataOut, commonPrefixLengths, leafCount, 0, packedValues, leafCardinality);
854848
}
855849
}
856850

@@ -1728,21 +1722,19 @@ private void build(
17281722
// Save the block file pointer:
17291723
leafBlockFPs[leavesOffset] = out.getFilePointer();
17301724

1731-
assert scratchOut.size() == 0;
1732-
17331725
// Write doc IDs
17341726
int[] docIDs = spareDocIds;
17351727
for (int i = from; i < to; ++i) {
17361728
docIDs[i - from] = reader.getDocID(i);
17371729
}
17381730
// System.out.println("writeLeafBlock pos=" + out.getFilePointer());
1739-
writeLeafBlockDocs(scratchOut, docIDs, 0, count);
1731+
writeLeafBlockDocs(out, docIDs, 0, count);
17401732

17411733
// Write the common prefixes:
17421734
reader.getValue(from, scratchBytesRef1);
17431735
System.arraycopy(
17441736
scratchBytesRef1.bytes, scratchBytesRef1.offset, scratch1, 0, config.packedBytesLength);
1745-
writeCommonPrefixes(scratchOut, commonPrefixLengths, scratch1);
1737+
writeCommonPrefixes(out, commonPrefixLengths, scratch1);
17461738

17471739
// Write the full values:
17481740
IntFunction<BytesRef> packedValues =
@@ -1756,9 +1748,7 @@ public BytesRef apply(int i) {
17561748
assert valuesInOrderAndBounds(
17571749
config, count, sortedDim, minPackedValue, maxPackedValue, packedValues, docIDs, 0);
17581750
writeLeafBlockPackedValues(
1759-
scratchOut, commonPrefixLengths, count, sortedDim, packedValues, leafCardinality);
1760-
scratchOut.copyTo(out);
1761-
scratchOut.reset();
1751+
out, commonPrefixLengths, count, sortedDim, packedValues, leafCardinality);
17621752
} else {
17631753
// inner node
17641754

0 commit comments

Comments
 (0)