Skip to content

Commit

Permalink
Fix points writing with no values (apache#13378)
Browse files Browse the repository at this point in the history
This commit updates the writer to handle the case where there are no values.

Previously (before apache#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.
  • Loading branch information
ChrisHegarty authored May 16, 2024
1 parent b1d3c08 commit 731cecf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ private IORunnable writeFieldNDims(

pointCount = values.size();

if (pointCount == 0) {
return null;
}

final int numLeaves =
Math.toIntExact((pointCount + config.maxPointsInLeafNode - 1) / config.maxPointsInLeafNode);
final int numSplits = numLeaves - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,8 @@ public TokenStreamComponents createComponents(String fieldName) {
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();
Expand Down

0 comments on commit 731cecf

Please sign in to comment.