Skip to content

Apache Lucene open-source search software

LUCENE-9366: Remove unused maxDoc parameter from DocValues.emptySortedNumeric() (#1491)

Alan Woodwardd06294e6abac
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 77dce67a602..a35f5750073 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -150,6 +150,9 @@ API Changes
provide them lazily. TermsInSetQuery switches to using this method
to report matching terms. (Alan Woodward)
+* LUCENE-9366: DocValues.emptySortedNumeric() not longer takes a maxDoc parameter
+ (Alan Woodward)
+
* LUCENE-7822: CodecUtil#checkFooter(IndexInput, Throwable) now throws a
CorruptIndexException if checksums mismatch or if checksums can't be verified.
(Martin Amirault, Adrien Grand)
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java
index 408d9781478..c4bae5c0b18 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java
@@ -393,7 +393,7 @@ public abstract class DocValuesConsumer implements Closeable {
}
}
if (values == null) {
- values = DocValues.emptySortedNumeric(mergeState.maxDocs[i]);
+ values = DocValues.emptySortedNumeric();
}
cost += values.cost();
subs.add(new SortedNumericDocValuesSub(mergeState.docMaps[i], values));
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocValues.java b/lucene/core/src/java/org/apache/lucene/index/DocValues.java
index 63488d03808..f90d715e69c 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocValues.java
@@ -168,7 +168,7 @@ public final class DocValues {
/**
* An empty SortedNumericDocValues which returns zero values for every document
*/
- public static final SortedNumericDocValues emptySortedNumeric(int maxDoc) {
+ public static final SortedNumericDocValues emptySortedNumeric() {
return new SortedNumericDocValues() {
private int doc = -1;
@@ -387,7 +387,7 @@ public final class DocValues {
NumericDocValues single = reader.getNumericDocValues(field);
if (single == null) {
checkField(reader, field, DocValuesType.SORTED_NUMERIC, DocValuesType.NUMERIC);
- return emptySortedNumeric(reader.maxDoc());
+ return emptySortedNumeric();
}
return singleton(single);
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java b/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
index b9ee2f58bb7..d515b6dfc9e 100644
--- a/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/index/MultiDocValues.java
@@ -434,7 +434,7 @@ public class MultiDocValues {
LeafReaderContext context = leaves.get(i);
SortedNumericDocValues v = context.reader().getSortedNumericDocValues(field);
if (v == null) {
- v = DocValues.emptySortedNumeric(context.reader().maxDoc());
+ v = DocValues.emptySortedNumeric();
} else {
anyReal = true;
}