hsyuan commented on a change in pull request #1959:
URL: https://github.com/apache/calcite/pull/1959#discussion_r422712608



##########
File path: core/src/main/java/org/apache/calcite/util/mapping/Mappings.java
##########
@@ -1245,12 +1271,30 @@ public void set(int source, int target) {
       assert isValid();
     }
 
+    /**
+     * Returns the source that a target maps to, or -1 if it is not mapped.
+     *
+     *  @throws NoElementException if target is out of sources range.
+     */
     public int getSourceOpt(int target) {
-      return sources[target];
+      try {
+        return sources[target];
+      } catch (ArrayIndexOutOfBoundsException e) {
+        throw new Mappings.NoElementException("invalid target " + target);

Review comment:
       I don't mind throwing `NoElementException`, if the desc in the javadoc 
is misleading. @julianhyde Can you confirm?




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


Reply via email to