Apache Lucene open-source search software
LUCENE-8709: Set pointWriter to null when size of the HeapPointWriter is 0
iverased381b739993e
diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointReader.java b/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointReader.javaindex bc37f5b780f..735b3138b21 100644--- a/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointReader.java+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointReader.java@@ -41,7 +41,7 @@ public final class HeapPointReader implements PointReader {this.pointValue = new HeapPointValue(block, packedBytesLength);} else {//no values- this.pointValue = new HeapPointValue(block, 0);+ this.pointValue = null;}}diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointWriter.javaindex 83978510bbb..db30548e58b 100644--- a/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointWriter.java+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/HeapPointWriter.java@@ -32,7 +32,7 @@ public final class HeapPointWriter implements PointWriter {private int nextWrite;private boolean closed;- private HeapPointReader.HeapPointValue offlinePointValue;+ private HeapPointReader.HeapPointValue pointValue;public HeapPointWriter(int size, int packedBytesLength) {@@ -42,18 +42,18 @@ public final class HeapPointWriter implements PointWriter {this.packedBytesLength = packedBytesLength;this.scratch = new byte[packedBytesLength];if (size > 0) {- offlinePointValue = new HeapPointReader.HeapPointValue(block, packedBytesLength);+ pointValue = new HeapPointReader.HeapPointValue(block, packedBytesLength);} else {//no values- offlinePointValue = new HeapPointReader.HeapPointValue(block, 0);+ pointValue = null;}}/** Returns a reference, in <code>result</code>, to the byte[] slice holding this value */public PointValue getPackedValueSlice(int index) {assert index < nextWrite : "nextWrite=" + (nextWrite) + " vs index=" + index;- offlinePointValue.setValue(index * packedBytesLength, docIDs[index]);- return offlinePointValue;+ pointValue.setValue(index * packedBytesLength, docIDs[index]);+ return pointValue;}@Override