You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2023/11/30 14:02:49 UTC
(lucene) branch main updated: Avoid null PointValues when merging points in SlowCompositeCodecReaderWrapper (#12859)
This is an automated email from the ASF dual-hosted git repository.
mikemccand 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 00de0aef634 Avoid null PointValues when merging points in SlowCompositeCodecReaderWrapper (#12859)
00de0aef634 is described below
commit 00de0aef6348ab816e9594781aedbb92d266573e
Author: Michael McCandless <mi...@apache.org>
AuthorDate: Thu Nov 30 08:58:51 2023 -0500
Avoid null PointValues when merging points in SlowCompositeCodecReaderWrapper (#12859)
* avoid null PointValues when merging points in SlowCompositeCodecReaderWrapper
* null check in SortingCodecReader
---------
Co-authored-by: ChrisHegarty <ch...@gmail.com>
---
.../org/apache/lucene/index/SlowCompositeCodecReaderWrapper.java | 8 ++++++--
.../core/src/java/org/apache/lucene/index/SortingCodecReader.java | 7 ++++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/index/SlowCompositeCodecReaderWrapper.java b/lucene/core/src/java/org/apache/lucene/index/SlowCompositeCodecReaderWrapper.java
index 849872a2bd5..0376f1e6243 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SlowCompositeCodecReaderWrapper.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SlowCompositeCodecReaderWrapper.java
@@ -558,7 +558,7 @@ final class SlowCompositeCodecReaderWrapper extends CodecReader {
private final int docBase;
PointValuesSub(PointValues sub, int docBase) {
- this.sub = sub;
+ this.sub = Objects.requireNonNull(sub);
this.docBase = docBase;
}
}
@@ -599,7 +599,11 @@ final class SlowCompositeCodecReaderWrapper extends CodecReader {
FieldInfo fi = codecReaders[i].getFieldInfos().fieldInfo(field);
if (fi != null && fi.getPointDimensionCount() > 0) {
PointValues v = readers[i].getValues(field);
- values.add(new PointValuesSub(v, docStarts[i]));
+ if (v != null) {
+ // Apparently FieldInfo can claim a field has points, yet the returned
+ // PointValues is null
+ values.add(new PointValuesSub(v, docStarts[i]));
+ }
}
}
if (values.isEmpty()) {
diff --git a/lucene/core/src/java/org/apache/lucene/index/SortingCodecReader.java b/lucene/core/src/java/org/apache/lucene/index/SortingCodecReader.java
index 6e3057585ed..f346313ff99 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SortingCodecReader.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SortingCodecReader.java
@@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Objects;
import org.apache.lucene.codecs.DocValuesProducer;
import org.apache.lucene.codecs.FieldsProducer;
import org.apache.lucene.codecs.KnnVectorsReader;
@@ -77,7 +78,7 @@ public final class SortingCodecReader extends FilterCodecReader {
private final Sorter.DocMap docMap;
SortingPointValues(final PointValues in, Sorter.DocMap docMap) {
- this.in = in;
+ this.in = Objects.requireNonNull(in);
this.docMap = docMap;
}
@@ -472,6 +473,10 @@ public final class SortingCodecReader extends FilterCodecReader {
@Override
public PointValues getValues(String field) throws IOException {
+ var values = delegate.getValues(field);
+ if (values == null) {
+ return null;
+ }
return new SortingPointValues(delegate.getValues(field), docMap);
}