use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamSortRel method beamComputeSelfCost.
@Override
public BeamCostModel beamComputeSelfCost(RelOptPlanner planner, BeamRelMetadataQuery mq) {
NodeStats inputEstimates = BeamSqlRelUtils.getNodeStats(this.input, mq);
final double rowSize = getRowType().getFieldCount();
final double cpu = inputEstimates.getRowCount() * inputEstimates.getRowCount() * rowSize;
final double cpuRate = inputEstimates.getRate() * inputEstimates.getWindow() * rowSize;
return BeamCostModel.FACTORY.makeCost(cpu, cpuRate);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamTableFunctionScanRel method beamComputeSelfCost.
@Override
public BeamCostModel beamComputeSelfCost(RelOptPlanner planner, BeamRelMetadataQuery mq) {
NodeStats inputEstimates = BeamSqlRelUtils.getNodeStats(getInput(0), mq);
final double rowSize = getRowType().getFieldCount();
final double cpu = inputEstimates.getRowCount() * rowSize;
final double cpuRate = inputEstimates.getRate() * inputEstimates.getWindow() * rowSize;
return BeamCostModel.FACTORY.makeCost(cpu, cpuRate);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamUnionRel method estimateNodeStats.
@Override
public NodeStats estimateNodeStats(BeamRelMetadataQuery mq) {
// The summation of the input stats
NodeStats summationOfEstimates = inputs.stream().map(input -> BeamSqlRelUtils.getNodeStats(input, mq)).reduce(NodeStats.create(0, 0, 0), NodeStats::plus);
// If all is set then we propagate duplicated values. Otherwise we assume a constant factor of
// them are duplicate.
summationOfEstimates = all ? summationOfEstimates : summationOfEstimates.multiply(0.5);
return summationOfEstimates;
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamJoinRel method estimateNodeStats.
@Override
public NodeStats estimateNodeStats(BeamRelMetadataQuery mq) {
double selectivity = Preconditions.checkArgumentNotNull(mq.getSelectivity(this, getCondition()), "Attempted to estimate node stats for BeamJoinRel '%s', but selectivity is null.", this);
NodeStats leftEstimates = BeamSqlRelUtils.getNodeStats(this.left, mq);
NodeStats rightEstimates = BeamSqlRelUtils.getNodeStats(this.right, mq);
if (leftEstimates.isUnknown() || rightEstimates.isUnknown()) {
return NodeStats.UNKNOWN;
}
// other.
return NodeStats.create(leftEstimates.getRowCount() * rightEstimates.getRowCount() * selectivity, (leftEstimates.getRate() * rightEstimates.getWindow() + rightEstimates.getRate() * leftEstimates.getWindow()) * selectivity, leftEstimates.getWindow() * rightEstimates.getWindow() * selectivity);
}
use of org.apache.beam.sdk.extensions.sql.impl.planner.NodeStats in project beam by apache.
the class BeamJoinRel method beamComputeSelfCost.
@Override
public BeamCostModel beamComputeSelfCost(RelOptPlanner planner, BeamRelMetadataQuery mq) {
NodeStats leftEstimates = BeamSqlRelUtils.getNodeStats(this.left, mq);
NodeStats rightEstimates = BeamSqlRelUtils.getNodeStats(this.right, mq);
NodeStats selfEstimates = BeamSqlRelUtils.getNodeStats(this, mq);
NodeStats summation = selfEstimates.plus(leftEstimates).plus(rightEstimates);
return BeamCostModel.FACTORY.makeCost(summation.getRowCount(), summation.getRate());
}
Aggregations