Skip to content

Commit 6f9702e

Browse files
authored
Removing unnecessary ByteArrayDataInput allocations by resetting inplace (#14113)
Removing unnecessary ByteArrayDataInput allocations by resetting inplace Signed-off-by: Ankit Jain <[email protected]>
1 parent 1778377 commit 6f9702e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lucene/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Improvements
5252
(Robert Muir)
5353
* GITHUB#13984: Add HNSW graph checks and stats to CheckIndex
5454

55+
* GITHUB#14113: Remove unnecessary ByteArrayDataInput allocations from `Lucene90DocValuesProducer$TermsDict.decompressBlock`. (Ankit Jain)
56+
5557
Optimizations
5658
---------------------
5759

lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,10 +1122,9 @@ private class TermsDict extends BaseTermsEnum {
11221122
final LongValues indexAddresses;
11231123
final RandomAccessInput indexBytes;
11241124
final BytesRef term;
1125+
final BytesRef blockBuffer;
1126+
final ByteArrayDataInput blockInput;
11251127
long ord = -1;
1126-
1127-
BytesRef blockBuffer = null;
1128-
ByteArrayDataInput blockInput = null;
11291128
long currentCompressedBlockStart = -1;
11301129
long currentCompressedBlockEnd = -1;
11311130

@@ -1149,6 +1148,7 @@ private class TermsDict extends BaseTermsEnum {
11491148
// add 7 padding bytes can help decompression run faster.
11501149
int bufferSize = entry.maxBlockLength + entry.maxTermLength + LZ4_DECOMPRESSOR_PADDING;
11511150
blockBuffer = new BytesRef(new byte[bufferSize], 0, bufferSize);
1151+
blockInput = new ByteArrayDataInput();
11521152
}
11531153

11541154
@Override
@@ -1324,8 +1324,7 @@ private void decompressBlock() throws IOException {
13241324
}
13251325

13261326
// Reset the buffer.
1327-
blockInput =
1328-
new ByteArrayDataInput(blockBuffer.bytes, blockBuffer.offset, blockBuffer.length);
1327+
blockInput.reset(blockBuffer.bytes, blockBuffer.offset, blockBuffer.length);
13291328
}
13301329
}
13311330

0 commit comments

Comments
 (0)