Class CassandraSort
- All Implemented Interfaces:
Cloneable
,CassandraRel
,RelOptNode
,Hintable
,RelNode
Sort
relational expression in Cassandra.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.adapter.cassandra.CassandraRel
CassandraRel.Implementor
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
Field Summary
Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet
Fields inherited from interface org.apache.calcite.adapter.cassandra.CassandraRel
CONVENTION
-
Constructor Summary
ConstructorDescriptionCassandraSort
(RelOptCluster cluster, RelTraitSet traitSet, RelNode child, RelCollation collation) -
Method Summary
Modifier and TypeMethodDescription@Nullable RelOptCost
computeSelfCost
(RelOptPlanner planner, RelMetadataQuery mq) Returns the cost of this plan (not including children).copy
(RelTraitSet traitSet, RelNode input, RelCollation newCollation, @Nullable RexNode offset, @Nullable RexNode fetch) void
implement
(CassandraRel.Implementor implementor) Methods inherited from class org.apache.calcite.rel.core.Sort
accept, copy, copy, explainTerms, getCollation, getHints, getSortExps, isEnforcer
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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.calcite.rel.hint.Hintable
attachHints, withHints
Methods inherited from interface org.apache.calcite.rel.RelNode
accept, accept, childrenAccept, collectVariablesSet, collectVariablesUsed, copy, deepEquals, deepHashCode, estimateRowCount, explain, explain, fieldIsNullable, getConvention, getCorrelVariable, getDigest, getExpectedInputRowType, getInput, getInputs, getRelDigest, getRelTypeName, getRowType, getTable, getVariablesSet, isEnforcer, isValid, metadata, onRegister, recomputeDigest, register, replaceInput, stripped
Methods inherited from interface org.apache.calcite.plan.RelOptNode
getCluster, getDescription, getId, getTraitSet
-
Constructor Details
-
CassandraSort
public CassandraSort(RelOptCluster cluster, RelTraitSet traitSet, RelNode child, RelCollation collation)
-
-
Method Details
-
computeSelfCost
Description copied from class:Sort
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.The CPU cost of a Sort has three main cases:
- If
fetch
is zero, CPU cost is zero; otherwise, - if the sort keys are empty, we don't need to sort, only step over
the rows, and therefore the CPU cost is
min(fetch + offset, inputRowCount) * bytesPerRow
; otherwise - we need to read and sort
inputRowCount
rows, with at mostmin(fetch + offset, inputRowCount)
of them in the sort data structure at a time, giving a CPU cost ofinputRowCount * log(min(fetch + offset, inputRowCount)) * bytesPerRow
.
The cost model factors in row width via
bytesPerRow
, because sorts need to move rows around, not just compare them; by making the cost higher if rows are wider, we discourage pushing a Project through a Sort. We assume that each field is 4 bytes, and we add 3 'virtual fields' to represent the per-row overhead. Thus a 1-field row is (3 + 1) * 4 = 16 bytes; a 5-field row is (3 + 5) * 4 = 32 bytes.The cost model does not consider a 5-field sort to be more expensive than, say, a 2-field sort, because both sorts will compare just one field most of the time.
- Specified by:
computeSelfCost
in interfaceRelNode
- Overrides:
computeSelfCost
in classSort
- Parameters:
planner
- Planner for cost calculationmq
- Metadata query- Returns:
- Cost of this plan (not including children)
- If
-
copy
public Sort copy(RelTraitSet traitSet, RelNode input, RelCollation newCollation, @Nullable RexNode offset, @Nullable RexNode fetch) -
implement
- Specified by:
implement
in interfaceCassandraRel
-