You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by iv...@apache.org on 2019/02/28 09:42:53 UTC

[lucene-solr] branch branch_8x updated: LUCENE-8709: Handle case of creating a HeapPointWriter with size equal 0

This is an automated email from the ASF dual-hosted git repository.

ivera pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 881c9c6  LUCENE-8709: Handle case of creating a HeapPointWriter with size equal 0
881c9c6 is described below

commit 881c9c66e2306847f893a9a24e02c1f975572044
Author: iverase <iv...@apache.org>
AuthorDate: Thu Feb 28 10:41:06 2019 +0100

    LUCENE-8709: Handle case of creating a HeapPointWriter with size equal 0
---
 .../core/src/java/org/apache/lucene/util/bkd/HeapPointReader.java  | 7 ++++++-
 .../core/src/java/org/apache/lucene/util/bkd/HeapPointWriter.java  | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

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 7beb8df..bc37f5b 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 8915b0c..8397851 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 <code>result</code>, to the byte[] slice holding this value */