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) {
PlanNodeCostEstimate replicateCost = calculateRemoteReplicateCost(buildSizeInBytes, estimatedSourceDistributedTaskCount);
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);
}
}