You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ch...@apache.org on 2024/05/16 13:24:06 UTC
(lucene) branch main updated: Fix points writing with no values (#13378)
This is an automated email from the ASF dual-hosted git repository.
chegar pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new 731cecf730a Fix points writing with no values (#13378)
731cecf730a is described below
commit 731cecf730a0a38620b9e7360e16b9b2c5a11492
Author: Chris Hegarty <62...@users.noreply.github.com>
AuthorDate: Thu May 16 14:24:00 2024 +0100
Fix points writing with no values (#13378)
This commit updates the writer to handle the case where there are no values.
Previously (before #13369), there was a check that there were some points values before trying to write, this is no longer the case. The code in writeFieldNDims has an assumption that the values is not empty - an empty values will result in calculating a negative number of splits, and a negate array size to hold the splits.
The fix is trivial, return null when values is empty - null is an allowable return value from this method. Note: writeField1Dim is able to handle an empty values.
---
lucene/CHANGES.txt | 2 ++
lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java | 4 ++++
.../src/test/org/apache/lucene/index/TestIndexWriterExceptions.java | 2 ++
3 files changed, 8 insertions(+)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 8737d1ce7ce..a00c594f9ac 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -370,6 +370,8 @@ Bug Fixes
* GITHUB#13369: Fix NRT opening failure when soft deletes are enabled and the document fails to index before a point
field is written (Ben Trent)
+* GITHUB#13378: Fix points writing with no values (Chris Hegarty)
+
Build
---------------------
diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
index b370f552642..1eb3be29d8e 100644
--- a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
@@ -513,6 +513,10 @@ public class BKDWriter implements Closeable {
pointCount = values.size();
+ if (pointCount == 0) {
+ return null;
+ }
+
final int numLeaves =
Math.toIntExact((pointCount + config.maxPointsInLeafNode - 1) / config.maxPointsInLeafNode);
final int numSplits = numLeaves - 1;
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
index a4228054e07..674ba6eac65 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
@@ -2338,6 +2338,8 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
LeafReader onlyReader = getOnlyLeafReader(r);
// we mark the failed doc as deleted
assertEquals(onlyReader.numDeletedDocs(), 1);
+ // there are not points values (rather than an empty set of values)
+ assertNull(onlyReader.getPointValues("field"));
onlyReader.close();
w.close();
dir.close();