Package org.apache.calcite.rel.core
Class Sort
java.lang.Object
org.apache.calcite.rel.AbstractRelNode
org.apache.calcite.rel.SingleRel
org.apache.calcite.rel.core.Sort
- All Implemented Interfaces:
Cloneable
,RelOptNode
,RelNode
- Direct Known Subclasses:
Bindables.BindableSort
,CassandraSort
,ElasticsearchSort
,EnumerableLimitSort
,EnumerableSort
,GeodeSort
,JdbcRules.JdbcSort
,LogicalSort
,MongoSort
public abstract class Sort extends SingleRel
Relational expression that imposes a particular sort order on its input
without otherwise changing its content.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Sort(RelOptCluster cluster, RelTraitSet traits, RelNode child, RelCollation collation)
Creates a Sort.Sort(RelOptCluster cluster, RelTraitSet traits, RelNode child, RelCollation collation, RexNode offset, RexNode fetch)
Creates a Sort.Sort(RelInput input)
Creates a Sort by parsing serialized output. -
Method Summary
Modifier and Type Method Description RelNode
accept(RexShuttle shuttle)
Accepts a visit from a shuttle.RelOptCost
computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
Returns the cost of this plan (not including children).Sort
copy(RelTraitSet traitSet, List<RelNode> inputs)
Creates a copy of this relational expression, perhaps changing traits and inputs.Sort
copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation)
abstract Sort
copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch)
RelWriter
explainTerms(RelWriter pw)
Describes the inputs and attributes of this relational expression.RelCollation
getCollation()
Returns the array ofRelFieldCollation
s asked for by the sort specification, from most significant to least significant.List<RexNode>
getSortExps()
Returns the sort expressions.boolean
isEnforcer()
Indicates whether it is an enforcer operator, e.g.Methods inherited from class org.apache.calcite.rel.SingleRel
childrenAccept, deriveRowType, estimateRowCount, getInput, getInputs, replaceInput
Methods inherited from class org.apache.calcite.rel.AbstractRelNode
accept, collectVariablesSet, collectVariablesUsed, deepEquals, deepHashCode, equals, explain, getCluster, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getRelDigest, getRelTypeName, getRowType, getTable, getTraitSet, getVariablesSet, hashCode, isValid, metadata, onRegister, recomputeDigest, register, sole, toString
-
Field Details
-
Constructor Details
-
Sort
Creates a Sort.- Parameters:
cluster
- Cluster this relational expression belongs totraits
- Traitschild
- input relational expressioncollation
- array of sort specifications
-
Sort
public Sort(RelOptCluster cluster, RelTraitSet traits, RelNode child, RelCollation collation, RexNode offset, RexNode fetch)Creates a Sort.- Parameters:
cluster
- Cluster this relational expression belongs totraits
- Traitschild
- input relational expressioncollation
- array of sort specificationsoffset
- Expression for number of rows to discard before returning first rowfetch
- Expression for number of rows to fetch
-
Sort
Creates a Sort by parsing serialized output.
-
-
Method Details
-
copy
Description copied from interface:RelNode
Creates a copy of this relational expression, perhaps changing traits and inputs.Sub-classes with other important attributes are encouraged to create variants of this method with more parameters.
- Specified by:
copy
in interfaceRelNode
- Overrides:
copy
in classAbstractRelNode
- Parameters:
traitSet
- Trait setinputs
- Inputs- Returns:
- Copy of this relational expression, substituting traits and inputs
-
copy
-
copy
public abstract Sort copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch) -
computeSelfCost
Description copied from interface:RelNode
Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use
RelMetadataQuery.getNonCumulativeCost(org.apache.calcite.rel.RelNode)
, which gives plugins a chance to override the rel's default ideas about cost.- Specified by:
computeSelfCost
in interfaceRelNode
- Overrides:
computeSelfCost
in classAbstractRelNode
- Parameters:
planner
- Planner for cost calculationmq
- Metadata query- Returns:
- Cost of this plan (not including children)
-
accept
Description copied from interface:RelNode
Accepts a visit from a shuttle. If the shuttle updates expression, then a copy of the relation should be created. This new relation might have a different row-type.- Specified by:
accept
in interfaceRelNode
- Overrides:
accept
in classAbstractRelNode
- Parameters:
shuttle
- Shuttle- Returns:
- A copy of this node incorporating changes made by the shuttle to this node's children
-
isEnforcer
public boolean isEnforcer()Description copied from interface:RelNode
Indicates whether it is an enforcer operator, e.g. PhysicalSort, PhysicalHashDistribute, etc. As an enforcer, the operator must be created only when required traitSet is not satisfied by its input.- Specified by:
isEnforcer
in interfaceRelNode
- Overrides:
isEnforcer
in classAbstractRelNode
- Returns:
- Whether it is an enforcer operator
-
getCollation
Returns the array ofRelFieldCollation
s asked for by the sort specification, from most significant to least significant.See also
RelMetadataQuery.collations(RelNode)
, which lists all known collations. For example,ORDER BY time_id
might also be sorted bythe_year, the_month
because of a known monotonicity constraint among the columns.getCollation
would return[time_id]
andcollations
would return[ [time_id], [the_year, the_month] ]
. -
getSortExps
Returns the sort expressions. -
explainTerms
Description copied from class:AbstractRelNode
Describes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms
, then call theRelWriter.input(String, RelNode)
andRelWriterImpl.item(String, Object)
methods for each input and attribute.- Overrides:
explainTerms
in classSingleRel
- Parameters:
pw
- Plan writer- Returns:
- Plan writer for fluent-explain pattern
-