Class JdbcRules.JdbcSort
- All Implemented Interfaces:
Cloneable,JdbcRel,RelOptNode,Hintable,RelNode
- Enclosing class:
JdbcRules
-
Nested Class Summary
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 -
Constructor Summary
ConstructorsConstructorDescriptionJdbcSort(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, RelCollation collation, @Nullable RexNode offset, @Nullable RexNode fetch) -
Method Summary
Modifier and TypeMethodDescription@Nullable RelOptCostcomputeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) Returns the cost of this plan (not including children).copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, @Nullable RexNode offset, @Nullable RexNode fetch) implement(JdbcImplementor implementor) Methods inherited from class org.apache.calcite.rel.core.Sort
accept, copy, copy, explainTerms, getCollation, getHints, getSortExps, isEnforcerMethods inherited from class org.apache.calcite.rel.SingleRel
childrenAccept, deriveRowType, estimateRowCount, getInput, getInputs, replaceInputMethods 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, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.calcite.rel.hint.Hintable
attachHints, withHintsMethods 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, strippedMethods inherited from interface org.apache.calcite.plan.RelOptNode
getCluster, getDescription, getId, getTraitSet
-
Constructor Details
-
JdbcSort
public JdbcSort(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, RelCollation collation, @Nullable RexNode offset, @Nullable RexNode fetch)
-
-
Method Details
-
copy
public JdbcRules.JdbcSort copy(RelTraitSet traitSet, RelNode newInput, RelCollation newCollation, @Nullable RexNode offset, @Nullable RexNode fetch) -
computeSelfCost
Description copied from class:SortReturns 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
fetchis 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
inputRowCountrows, 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:
computeSelfCostin interfaceRelNode- Overrides:
computeSelfCostin classSort- Parameters:
planner- Planner for cost calculationmq- Metadata query- Returns:
- Cost of this plan (not including children)
- If
-
implement
-