From 7fddefce76b59cc6636a0cab98c79568690b11bf Mon Sep 17 00:00:00 2001 From: slow-J <32519034+slow-J@users.noreply.github.com> Date: Thu, 11 Jun 2026 15:09:24 +0100 Subject: [PATCH 1/2] Allocate postings payload buffers only when the query requests them --- lucene/CHANGES.txt | 2 ++ .../lucene/codecs/lucene104/Lucene104PostingsReader.java | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 42a6e8073576..79d5c3130354 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -568,6 +568,8 @@ Optimizations * GITHUB#16228: Reuse scratch int[] for ordinal translation. (Tim Brooks) +* GITHUB#16248: Allocate payload buffers in Lucene104PostingsReader only if payloads are requested. (Jakub Slowinski) + Bug Fixes --------------------- * GITHUB#15754: Fix HTMLStripCharFilter to prevent tags from incorrectly consuming subsequent diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104PostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104PostingsReader.java index eafe644c9b23..cb8634526eec 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104PostingsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene104/Lucene104PostingsReader.java @@ -476,7 +476,7 @@ public BlockPostingsEnum(FieldInfo fieldInfo, int flags, boolean needsImpacts) endOffset = -1; } - if (indexHasPayloads) { + if (needsPayloads) { payloadLengthBuffer = new int[BLOCK_SIZE]; payloadBytes = new byte[128]; payload = new BytesRef(); @@ -1180,12 +1180,12 @@ private void refillLastPositionBlock() throws IOException { for (int i = 0; i < count; i++) { int code = posIn.readVInt(); if (indexHasPayloads) { + posDeltaBuffer[i] = code >>> 1; if ((code & 1) != 0) { payloadLength = posIn.readVInt(); } - if (payloadLengthBuffer != null) { // needs payloads + if (needsPayloads) { payloadLengthBuffer[i] = payloadLength; - posDeltaBuffer[i] = code >>> 1; if (payloadLength != 0) { if (payloadByteUpto + payloadLength > payloadBytes.length) { payloadBytes = ArrayUtil.grow(payloadBytes, payloadByteUpto + payloadLength); From 054c2103b21248c3202ab7bae3294f8c24a0c1fc Mon Sep 17 00:00:00 2001 From: slow-J <32519034+slow-J@users.noreply.github.com> Date: Tue, 23 Jun 2026 16:41:15 +0100 Subject: [PATCH 2/2] Move CHANGES entry GITHUB#16248 to 10.6.0 --- lucene/CHANGES.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 79d5c3130354..3f02924ff518 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -291,7 +291,7 @@ Improvements Optimizations --------------------- -(No changes) +* GITHUB#16248: Allocate payload buffers in Lucene104PostingsReader only if payloads are requested. (Jakub Slowinski) Bug Fixes --------------------- @@ -568,8 +568,6 @@ Optimizations * GITHUB#16228: Reuse scratch int[] for ordinal translation. (Tim Brooks) -* GITHUB#16248: Allocate payload buffers in Lucene104PostingsReader only if payloads are requested. (Jakub Slowinski) - Bug Fixes --------------------- * GITHUB#15754: Fix HTMLStripCharFilter to prevent tags from incorrectly consuming subsequent