risdenk commented on code in PR #840:
URL: https://github.com/apache/lucene/pull/840#discussion_r859065937


##########
lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/DoubleFieldSource.java:
##########
@@ -52,55 +50,32 @@ public SortField getSortField(boolean reverse) {
   public FunctionValues getValues(Map<Object, Object> context, 
LeafReaderContext readerContext)
       throws IOException {
 
-    final NumericDocValues values = getNumericDocValues(context, 
readerContext);
+    final NumericDocValues arr = getNumericDocValues(context, readerContext);

Review Comment:
   This is only a cosmetic change to make `DoubleFieldSource` match the other 
`*FieldSource` implementations using `arr`.



##########
lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/EnumFieldSource.java:
##########
@@ -136,8 +121,16 @@ public String strVal(int doc) throws IOException {
 
       @Override
       public boolean exists(int doc) throws IOException {
-        getValueForDoc(doc);
-        return arr.docID() == doc;
+        if (doc < lastDocID) {
+          throw new IllegalArgumentException(
+              "docs were sent out-of-order: lastDocID=" + lastDocID + " vs 
docID=" + doc);
+        }
+        lastDocID = doc;
+        int curDocID = arr.docID();
+        if (doc > curDocID) {
+          curDocID = arr.advance(doc);
+        }
+        return doc == curDocID;

Review Comment:
   `exists` is the same for all of these `*FieldSource` implementations now, 
but I didn't know a good way to remove the duplication. So I left the 
duplication for now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to