You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/11/09 18:50:42 UTC

[GitHub] [calcite] julianhyde commented on a change in pull request #2238: [CALCITE-4364] `a IN (1, 2) AND a = 1` should be simplified to `a = 1`

julianhyde commented on a change in pull request #2238:
URL: https://github.com/apache/calcite/pull/2238#discussion_r520039486



##########
File path: core/src/main/java/org/apache/calcite/util/RangeSets.java
##########
@@ -128,6 +129,14 @@ private RangeSets() {}
         && !range.isEmpty();
   }
 
+  /** Returns whether a range set is a single open interval. */
+  public static <C extends Comparable<C>> boolean isOpenInterval(RangeSet<C> rangeSet) {
+    final Set<Range<C>> ranges = rangeSet.asRanges();
+    final Range<C> range = ranges.iterator().next();
+    return ranges.size() == 1

Review comment:
       Will throw if `ranges.isEmpty()` because you iterate before you check `size`. Add a test where this is called on an empty range set.




----------------------------------------------------------------
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:
users@infra.apache.org