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.java index 7beb8df6e14..bc37f5b780f 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 @@ -37,7 +37,12 @@ public final class HeapPointReader implements PointReader { curRead = start-1; this.end = end; this.packedBytesLength = packedBytesLength; - this.pointValue = new HeapPointValue(block, packedBytesLength); + if (start < end) { + this.pointValue = new HeapPointValue(block, packedBytesLength); + } else { + //no values + this.pointValue = new HeapPointValue(block, 0); + } } @Override 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.java index 8915b0c27e3..83978510bbb 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 @@ -41,7 +41,12 @@ public final class HeapPointWriter implements PointWriter { this.size = size; this.packedBytesLength = packedBytesLength; this.scratch = new byte[packedBytesLength]; - offlinePointValue = new HeapPointReader.HeapPointValue(block, packedBytesLength); + if (size > 0) { + offlinePointValue = new HeapPointReader.HeapPointValue(block, packedBytesLength); + } else { + //no values + offlinePointValue = new HeapPointReader.HeapPointValue(block, 0); + } } /** Returns a reference, in result, to the byte[] slice holding this value */