Skip to content

Apache Lucene open-source search software

LUCENE-10603: Mark SortedSetDocValues#NO_MORE_ORDS deprecated (#969)

Greg Miller8f459eb0f9d2
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 12c9c784af6..dc6bceb6672 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -71,7 +71,9 @@ Other
API Changes
---------------------
-(No changes)
+
+* LUCENE-10603: SortedSetDocValues#NO_MORE_ORDS marked @deprecated in favor of iterating with
+ SortedSetDocValues#docValueCount(). (Greg Miller)
New Features
---------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValues.java b/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValues.java
index 422964c46df..cdcbcf96cea 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValues.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SortedSetDocValues.java
@@ -32,13 +32,22 @@ public abstract class SortedSetDocValues extends DocValuesIterator {
/** Sole constructor. (For invocation by subclass constructors, typically implicit.) */
protected SortedSetDocValues() {}
- /** When returned by {@link #nextOrd()} it means there are no more ordinals for the document. */
- public static final long NO_MORE_ORDS = -1;
+ /**
+ * When returned by {@link #nextOrd()} it means there are no more ordinals for the document.
+ *
+ * @deprecated Will be removed in a future version. Please use {@link #docValueCount()} to know
+ * the number of doc values for the current document up-front.
+ */
+ @Deprecated public static final long NO_MORE_ORDS = -1;
/**
* Returns the next ordinal for the current document. It is illegal to call this method after
* {@link #advanceExact(int)} returned {@code false}.
*
+ * <p>Note: Returns {@link #NO_MORE_ORDS} when the current document has no more ordinals. This
+ * behavior will be removed in a future version. Callers should use {@link #docValueCount()} to
+ * determine the number of values for the current document up-front.
+ *
* @return next ordinal for the document, or {@link #NO_MORE_ORDS}. ordinals are dense, start at
* 0, then increment by 1 for the next value in sorted order.
*/