gsmiller commented on code in PR #12560: URL: https://github.com/apache/lucene/pull/12560#discussion_r1327725540
########## lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionFunctionValues.java: ########## @@ -39,21 +39,21 @@ class ExpressionFunctionValues extends DoubleValues { } @Override - public boolean advanceExact(int doc) { + public boolean advanceExact(int doc) throws IOException { if (currentDoc == doc) { return true; } + for (DoubleValues v : functionValues) { + v.advanceExact(doc); Review Comment: If you have an expression like `a == 0 ? b : c` where `a`, `b` and `c` are all other references in your bindings, only `b` or `c` need to be evaluated for any given doc, not both. But today, we greedily call `advanceExact` on all three up-front, for every doc. So we're doing wasted advancing work for one of `b` or `c` for every single doc. I added a similar example in a test case. Depending on what the advancing is doing, this could come with significant cost (e.g., if `b` or `c` is another complex expression tree that ends up propagating the advance down all of its dependencies) -- 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