dsmiley commented on a change in pull request #1343: LUCENE-8103: Use two-phase iteration in Query- and DoubleValuesSource URL: https://github.com/apache/lucene-solr/pull/1343#discussion_r392387868
########## File path: lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java ########## @@ -156,42 +135,38 @@ public float floatVal(int doc) { @Override public boolean exists(int doc) { try { - if (doc < lastDocRequested) { - if (noMatches) return false; + if (noMatches) return false; + if (scorer == null) { scorer = weight.scorer(readerContext); - scorerDoc = -1; - if (scorer==null) { + if (scorer == null) { noMatches = true; return false; } - it = scorer.iterator(); + tpi = scorer.twoPhaseIterator(); + disi = tpi==null ? scorer.iterator() : tpi.approximation(); + thisDocMatches = false; } + assert doc >= lastDocRequested : "values requested out of order; last=" + lastDocRequested + ", requested=" + doc; Review comment: Hmm; I wasn't sure about this but the more I look, it appears that the ValueSource API (here) also has a forward-only requirement. A few years ago this was not the case. So we can assume this and throw an exception. See JoinDocFreqValueSource for an example. I think this check you added here should be way up front at this method, thus clearly showing as a pre-condition, not down here. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org