C - Value typepublic class Sarg<C extends Comparable<C>> extends Object implements Comparable<Sarg<C>>
The name is derived from Search argument, an ancient concept in database implementation; see Access Path Selection in a Relational Database Management System — Selinger et al. 1979 or the "morning paper summary.
In RexNode, a Sarg only occur as the right-hand operand in a call to
SqlStdOperatorTable.SEARCH, wrapped in a
RexLiteral. Lifecycle methods:
RexUtil.expandSearch(org.apache.calcite.rex.RexBuilder, org.apache.calcite.rex.RexProgram, org.apache.calcite.rex.RexNode) removes
calls to SEARCH and the included Sarg, converting them to comparisons;
RexSimplify converts complex comparisons
on the same argument into SEARCH calls with an included Sarg;
RelBuilder methods,
including RelBuilder.in(org.apache.calcite.rex.RexNode, org.apache.calcite.rex.RexNode...)
and RelBuilder.between(org.apache.calcite.rex.RexNode, org.apache.calcite.rex.RexNode, org.apache.calcite.rex.RexNode)
call RexBuilder
methods RexBuilder.makeIn(org.apache.calcite.rex.RexNode, java.util.List<? extends org.apache.calcite.rex.RexNode>)
and RexBuilder.makeBetween(org.apache.calcite.rex.RexNode, org.apache.calcite.rex.RexNode, org.apache.calcite.rex.RexNode)
that create Sarg instances directly;
SqlImplementor converts
RexCalls
to SEARCH into SqlNode AST expressions
such as comparisons, BETWEEN and IN.
SqlStdOperatorTable.SEARCH| Modifier and Type | Field and Description |
|---|---|
boolean |
containsNull |
int |
pointCount |
com.google.common.collect.RangeSet<C> |
rangeSet |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Sarg<C> o) |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isComplementedPoints()
Returns whether this Sarg, when negated, is a collection of 1 or more
points (and perhaps an
IS NULL if containsNull). |
boolean |
isPoints()
Returns whether this Sarg is a collection of 1 or more points (and perhaps
an
IS NULL if containsNull). |
static <C extends Comparable<C>> |
of(boolean containsNull,
com.google.common.collect.RangeSet<C> rangeSet)
Creates a search argument.
|
StringBuilder |
printTo(StringBuilder sb,
BiConsumer<StringBuilder,C> valuePrinter)
Prints this Sarg to a StringBuilder, using the given printer to deal
with each embedded value.
|
String |
toString()
Produces a similar result to
RangeSet, but adds ", null"
if nulls are matched, and simplifies point ranges. |
public final com.google.common.collect.RangeSet<C extends Comparable<C>> rangeSet
public final boolean containsNull
public final int pointCount
public static <C extends Comparable<C>> Sarg<C> of(boolean containsNull, com.google.common.collect.RangeSet<C> rangeSet)
public String toString()
Produces a similar result to RangeSet, but adds ", null"
if nulls are matched, and simplifies point ranges. For example,
the Sarg that allows the range set
[[7‥7], [9‥9],
(10‥+∞)]
and also null is printed as
Sarg[7, 9, (10‥+∞), null]public StringBuilder printTo(StringBuilder sb, BiConsumer<StringBuilder,C> valuePrinter)
public int compareTo(Sarg<C> o)
compareTo in interface Comparable<Sarg<C extends Comparable<C>>>public boolean isPoints()
IS NULL if containsNull).
Such sargs could be translated as ref = value
or ref IN (value1, ...).
public boolean isComplementedPoints()
IS NULL if containsNull).
Such sargs could be translated as ref <> value
or ref NOT IN (value1, ...).
Copyright © 2012-2020 Apache Software Foundation. All Rights Reserved.