You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2023/09/16 22:13:40 UTC
[lucene] branch main updated: Add more detailed documentation related to GH#12560
This is an automated email from the ASF dual-hosted git repository.
gsmiller pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new 43c0d72b94c Add more detailed documentation related to GH#12560
43c0d72b94c is described below
commit 43c0d72b94cf0050ed161302d5b517e87e20c7d5
Author: Greg Miller <gs...@gmail.com>
AuthorDate: Sat Sep 16 14:50:18 2023 -0700
Add more detailed documentation related to GH#12560
---
.../apache/lucene/expressions/ExpressionValueSource.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionValueSource.java b/lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionValueSource.java
index 8208d134a7c..0138d279870 100644
--- a/lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionValueSource.java
+++ b/lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionValueSource.java
@@ -87,6 +87,19 @@ class ExpressionValueSource extends DoubleValuesSource {
return new ExpressionFunctionValues(expression, externalValues);
}
+ /**
+ * Create a wrapper around all the expression arguments to do two things:
+ *
+ * <ol>
+ * <li>Default to 0 for any argument that doesn't have a value for a given doc (i.e.,
+ * #advanceExact returns false)
+ * <li>Be as lazy as possible about actually advancing to the given doc until the argument value
+ * is actually needed by the expression. For a given doc, some arguments may not actually be
+ * needed, e.g., because of condition short-circuiting (<code>(true || X)</code> doesn't
+ * need to evaluate <code>X</code>) or ternary branching (<code>true ? X : Y</code> doesn't
+ * need to evaluate <code>Y</code>).
+ * </ol>
+ */
static DoubleValues zeroWhenUnpositioned(DoubleValues in) {
return new DoubleValues() {
@@ -105,9 +118,6 @@ class ExpressionValueSource extends DoubleValuesSource {
@Override
public boolean advanceExact(int doc) {
- // This implementation wraps all expression arguments, so we lazily advance it in case the
- // value is never needed by the expression for a given doc (e.g., ternary branch or
- // condition short-circuit):
if (currentDoc == doc) {
return true;
}