Class ElasticsearchSort
- All Implemented Interfaces:
Cloneable,ElasticsearchRel,RelOptNode,Hintable,RelNode
Sort
relational expression in Elasticsearch.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.adapter.elasticsearch.ElasticsearchRel
ElasticsearchRel.ImplementorNested 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, traitSetFields inherited from interface org.apache.calcite.adapter.elasticsearch.ElasticsearchRel
CONVENTION -
Method Summary
Modifier and TypeMethodDescription@Nullable RelOptCostcomputeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) Returns the cost of this plan (not including children).copy(RelTraitSet traitSet, RelNode input, RelCollation relCollation, @Nullable RexNode offset, @Nullable RexNode fetch) voidimplement(ElasticsearchRel.Implementor 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
-
Method Details
-
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
-
copy
public Sort copy(RelTraitSet traitSet, RelNode input, RelCollation relCollation, @Nullable RexNode offset, @Nullable RexNode fetch) -
implement
- Specified by:
implementin interfaceElasticsearchRel
-