adjust distribution stats derive, fix bug in join estimation (#17916)
This commit is contained in:
@ -60,8 +60,12 @@ class CostModelV1 extends PlanVisitor<Cost, PlanContext> {
|
||||
|
||||
public static Cost addChildCost(Plan plan, Cost planCost, Cost childCost, int index) {
|
||||
Preconditions.checkArgument(childCost instanceof CostV1 && planCost instanceof CostV1);
|
||||
double cost = planCost.getValue() + childCost.getValue();
|
||||
return new CostV1(cost);
|
||||
CostV1 childCostV1 = (CostV1) childCost;
|
||||
CostV1 planCostV1 = (CostV1) planCost;
|
||||
return new CostV1(childCostV1.getCpuCost() + planCostV1.getCpuCost(),
|
||||
childCostV1.getMemoryCost() + planCostV1.getMemoryCost(),
|
||||
childCostV1.getNetworkCost() + planCostV1.getNetworkCost(),
|
||||
childCostV1.getPenalty() + planCostV1.getPenalty());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -170,22 +174,17 @@ class CostModelV1 extends PlanVisitor<Cost, PlanContext> {
|
||||
|| childStatistics.getRowCount() > rowsLimit) {
|
||||
return CostV1.of(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
|
||||
}
|
||||
/*
|
||||
TODO:
|
||||
srcBeNum and destBeNum are not available, assume destBeNum/srcBeNum = 1
|
||||
1. cpu: row * destBeNum/srcBeNum
|
||||
2. network: rows send = rows/srcBeNum * destBeNum.
|
||||
*/
|
||||
return CostV1.of(
|
||||
childStatistics.getRowCount(), // TODO:should multiply by destBeNum/srcBeNum
|
||||
childStatistics.getRowCount(), // only consider one BE, not the whole system.
|
||||
childStatistics.getRowCount() * instanceNumber); // TODO: remove instanceNumber when BE updated
|
||||
0,
|
||||
0,
|
||||
childStatistics.getRowCount());
|
||||
|
||||
}
|
||||
|
||||
// gather
|
||||
if (spec instanceof DistributionSpecGather) {
|
||||
return CostV1.of(
|
||||
childStatistics.getRowCount(),
|
||||
0,
|
||||
0,
|
||||
childStatistics.getRowCount());
|
||||
}
|
||||
|
||||
@ -105,8 +105,9 @@ class CostV1 implements Cost {
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append((long) cpuCost).append("/").append((long) memoryCost).append("/").append((long) networkCost)
|
||||
.append("/").append((long) penalty);
|
||||
sb.append(cost).append("[").append((long) cpuCost).append("/")
|
||||
.append((long) memoryCost).append("/").append((long) networkCost)
|
||||
.append("/").append((long) penalty).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,9 +39,9 @@ public class JoinEstimation {
|
||||
.sorted((a, b) -> {
|
||||
double sub = a.second - b.second;
|
||||
if (sub > 0) {
|
||||
return -1;
|
||||
} else if (sub < 0) {
|
||||
return 1;
|
||||
} else if (sub < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user