vlsi commented on a change in pull request #2212:
URL: https://github.com/apache/calcite/pull/2212#discussion_r504307063
##########
File path: core/src/main/java/org/apache/calcite/util/Sarg.java
##########
@@ -149,4 +150,33 @@ public boolean isComplementedPoints() {
&& rangeSet.complement().asRanges().stream()
.allMatch(RangeSets::isPoint);
}
+
+ /** Returns a measure of the complexity of this expression.
+ *
+ * <p>It is basically the number of values that need to be checked against
+ * (including NULL).
+ *
+ * <p>Examples:
+ * <ul>
+ * <li>{@code x = 1}, {@code x <> 1}, {@code x > 1} have complexity 1
+ * <li>{@code x > 1 or x is null} has complexity 2
+ * <li>{@code x in (2, 4, 6) or x > 20} has complexity 4
+ * <li>{@code x between 3 and 8 or x between 10 and 20} has complexity 2
+ * </ul>
+ */
+ public int complexity() {
+ int complexity;
+ if (rangeSet.asRanges().size() == 2
+ && rangeSet.complement().asRanges().size() == 1
+ && RangeSets.isPoint(
+ Iterables.getOnlyElement(rangeSet.complement().asRanges()))) {
Review comment:
Is this computation important for something?
Please add the relevant comment: if it is important, then clarify so. If it
is just a fine detail, then comment so. The intention behind the conditions is
not really visible.
----------------------------------------------------------------
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:
[email protected]