Skip to content

Commit 099fe90

Browse files
committed
Allocate postings payload buffers only when the query requests them
1 parent 1fca5f4 commit 099fe90

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

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)