@Override public PlanNodeCostEstimate visitAggregation(AggregationNode node, Void context) { PlanNode source = node.getSource(); double inputSizeInBytes = getStats(source).getOutputSizeInBytes(source.getOutputSymbols(), types); PlanNodeCostEstimate remoteRepartitionCost = calculateRemoteRepartitionCost(inputSizeInBytes); PlanNodeCostEstimate localRepartitionCost = calculateLocalRepartitionCost(inputSizeInBytes); // TODO consider cost of aggregation itself, not only exchanges, based on aggregation's properties return remoteRepartitionCost.add(localRepartitionCost); }
private static PlanNodeCostEstimate calculateJoinExchangeCost( PlanNode probe, PlanNode build, StatsProvider stats, TypeProvider types, boolean replicated, int estimatedSourceDistributedTaskCount) { double probeSizeInBytes = stats.getStats(probe).getOutputSizeInBytes(probe.getOutputSymbols(), types); double buildSizeInBytes = stats.getStats(build).getOutputSizeInBytes(build.getOutputSymbols(), types); if (replicated) { // assuming the probe side of a replicated join is always source distributed PlanNodeCostEstimate replicateCost = calculateRemoteReplicateCost(buildSizeInBytes, estimatedSourceDistributedTaskCount); // cost of the copies repartitioning is added in CostCalculatorUsingExchanges#calculateJoinCost PlanNodeCostEstimate localRepartitionCost = calculateLocalRepartitionCost(buildSizeInBytes); return replicateCost.add(localRepartitionCost); } else { PlanNodeCostEstimate probeCost = calculateRemoteRepartitionCost(probeSizeInBytes); PlanNodeCostEstimate buildRemoteRepartitionCost = calculateRemoteRepartitionCost(buildSizeInBytes); PlanNodeCostEstimate buildLocalRepartitionCost = calculateLocalRepartitionCost(buildSizeInBytes); return probeCost .add(buildRemoteRepartitionCost) .add(buildLocalRepartitionCost); } }
return calculateRemoteGatherCost(inputSizeInBytes); case REPARTITION: return calculateRemoteRepartitionCost(inputSizeInBytes); case REPLICATE: