msokolov commented on a change in pull request #1444:
URL: https://github.com/apache/lucene-solr/pull/1444#discussion_r413907462



##########
File path: 
lucene/expressions/src/java/org/apache/lucene/expressions/SimpleBindings.java
##########
@@ -96,24 +90,51 @@ public DoubleValuesSource getDoubleValuesSource(String 
name) {
       case SCORE:
         return DoubleValuesSource.SCORES;
       default:
-        throw new UnsupportedOperationException(); 
+        throw new UnsupportedOperationException();
     }
   }
   
-  /** 
-   * Traverses the graph of bindings, checking there are no cycles or missing 
references 
-   * @throws IllegalArgumentException if the bindings is inconsistent 
+  @Override
+  public DoubleValuesSource getDoubleValuesSource(String name) {
+    if (map.containsKey(name) == false) {
+      throw new IllegalArgumentException("Invalid reference '" + name + "'");
+    }
+    return map.get(name).apply(this);
+  }
+
+  /**
+   * Traverses the graph of bindings, checking there are no cycles or missing 
references
+   * @throws IllegalArgumentException if the bindings is inconsistent
    */
   public void validate() {

Review comment:
       Have you considered returning the map, or an immutable view on it, so 
that callers can use this to enumerate all the dependencies? In a similar 
framework, I've found this to be pretty helpful for analyzing query patterns. 
It's also nice to know if the same name occurs multiple times in the dependency 
tree; maybe one should cache its value in that case.




----------------------------------------------------------------
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



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

Reply via email to