Class Sort
- java.lang.Object
-
- org.apache.calcite.rel.AbstractRelNode
-
- org.apache.calcite.rel.SingleRel
-
- org.apache.calcite.rel.core.Sort
-
- All Implemented Interfaces:
java.lang.Cloneable
,RelOptNode
,RelNode
- Direct Known Subclasses:
Bindables.BindableSort
,CassandraSort
,ElasticsearchSort
,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
-
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
-
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
All Methods Instance Methods Abstract Methods Concrete Methods 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, java.util.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.java.util.List<RexNode>
getChildExps()
Returns a list of this relational expression's child expressions.RelCollation
getCollation()
Returns the array ofRelFieldCollation
s asked for by the sort specification, from most significant to least significant.java.util.List<RelCollation>
getCollationList()
Returns a description of the physical ordering (or orderings) of this relational expression.-
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, computeDigest, computeSelfCost, explain, getCluster, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getQuery, getRelTypeName, getRows, getRowType, getTable, getTraitSet, getVariablesSet, getVariablesStopped, isDistinct, isKey, isValid, isValid, metadata, onRegister, recomputeDigest, register, sole, toString
-
-
-
-
Field Detail
-
collation
public final RelCollation collation
-
fieldExps
protected final com.google.common.collect.ImmutableList<RexNode> fieldExps
-
offset
public final RexNode offset
-
fetch
public final RexNode fetch
-
-
Constructor Detail
-
Sort
public Sort(RelOptCluster cluster, RelTraitSet traits, RelNode child, RelCollation collation)
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
public Sort(RelInput input)
Creates a Sort by parsing serialized output.
-
-
Method Detail
-
copy
public final Sort copy(RelTraitSet traitSet, java.util.List<RelNode> inputs)
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
public final Sort copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation)
-
copy
public abstract Sort copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, RexNode offset, RexNode fetch)
-
computeSelfCost
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
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)
-
getChildExps
public java.util.List<RexNode> getChildExps()
Description copied from interface:RelNode
Returns a list of this relational expression's child expressions. (These are scalar expressions, and so do not include the relational inputs that are returned byRelNode.getInputs()
.The caller should treat the list as unmodifiable; typical implementations will return an immutable list. If there are no child expressions, returns an empty list, not
null
.- Specified by:
getChildExps
in interfaceRelNode
- Overrides:
getChildExps
in classAbstractRelNode
- Returns:
- List of this relational expression's child expressions
- See Also:
RelNode.accept(org.apache.calcite.rex.RexShuttle)
-
accept
public RelNode accept(RexShuttle shuttle)
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.- 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
-
getCollation
public RelCollation 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] ]
.
-
getCollationList
public java.util.List<RelCollation> getCollationList()
Description copied from interface:RelNode
Returns a description of the physical ordering (or orderings) of this relational expression. Never null.- Specified by:
getCollationList
in interfaceRelNode
- Overrides:
getCollationList
in classAbstractRelNode
- Returns:
- Description of the physical ordering (or orderings) of this relational expression. Never null
-
explainTerms
public RelWriter explainTerms(RelWriter pw)
Description copied from class:AbstractRelNode
Describes the inputs and attributes of this relational expression. Each node should callsuper.explainTerms
, then call theRelWriterImpl.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
-
-