Skip to content

Commit 109fd16

Browse files
committed
Allocate postings payload buffers only when the query requests them
1 parent e5742cf commit 109fd16

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

lucene/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ Optimizations
568568

569569
* GITHUB#16228: Reuse scratch int[] for ordinal translation. (Tim Brooks)
570570

571+
* GITHUB#16248: Allocate payload buffers in Lucene104PostingsReader only if payloads are requested. (Jakub Slowinski)
572+
571573
Bug Fixes
572574
---------------------
573575
* GITHUB#15754: Fix HTMLStripCharFilter to prevent tags from incorrectly consuming subsequent

lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104PostingsReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ public BlockPostingsEnum(FieldInfo fieldInfo, int flags, boolean needsImpacts)
476476
endOffset = -1;
477477
}
478478

479-
if (indexHasPayloads) {
479+
if (needsPayloads) {
480480
payloadLengthBuffer = new int[BLOCK_SIZE];
481481
payloadBytes = new byte[128];
482482
payload = new BytesRef();
@@ -1180,12 +1180,12 @@ private void refillLastPositionBlock() throws IOException {
11801180
for (int i = 0; i < count; i++) {
11811181
int code = posIn.readVInt();
11821182
if (indexHasPayloads) {
1183+
posDeltaBuffer[i] = code >>> 1;
11831184
if ((code & 1) != 0) {
11841185
payloadLength = posIn.readVInt();
11851186
}
1186-
if (payloadLengthBuffer != null) { // needs payloads
1187+
if (needsPayloads) {
11871188
payloadLengthBuffer[i] = payloadLength;
1188-
posDeltaBuffer[i] = code >>> 1;
11891189
if (payloadLength != 0) {
11901190
if (payloadByteUpto + payloadLength > payloadBytes.length) {
11911191
payloadBytes = ArrayUtil.grow(payloadBytes, payloadByteUpto + payloadLength);

0 commit comments

Comments
 (0)