use of io.trino.cost.PlanCostEstimate in project trino by trinodb.
the class TestMemo method testEvictCostOnReplace.
@Test
public void testEvictCostOnReplace() {
PlanNode y = node();
PlanNode x = node(y);
Memo memo = new Memo(idAllocator, x);
int xGroup = memo.getRootGroup();
int yGroup = getChildGroup(memo, memo.getRootGroup());
PlanCostEstimate yCost = new PlanCostEstimate(42, 0, 0, 0);
PlanCostEstimate xCost = new PlanCostEstimate(42, 0, 0, 37);
memo.storeCost(yGroup, yCost);
memo.storeCost(xGroup, xCost);
assertEquals(memo.getCost(yGroup), Optional.of(yCost));
assertEquals(memo.getCost(xGroup), Optional.of(xCost));
memo.replace(yGroup, node(), "rule");
assertEquals(memo.getCost(yGroup), Optional.empty());
assertEquals(memo.getCost(xGroup), Optional.empty());
}
use of io.trino.cost.PlanCostEstimate in project trino by trinodb.
the class TextRenderer method printEstimates.
private String printEstimates(PlanRepresentation plan, NodeRepresentation node) {
if (node.getEstimatedStats().stream().allMatch(PlanNodeStatsEstimate::isOutputRowCountUnknown) && node.getEstimatedCost().stream().allMatch(c -> c.equals(PlanCostEstimate.unknown()))) {
return "";
}
StringBuilder output = new StringBuilder();
int estimateCount = node.getEstimatedStats().size();
output.append("Estimates: ");
for (int i = 0; i < estimateCount; i++) {
PlanNodeStatsEstimate stats = node.getEstimatedStats().get(i);
PlanCostEstimate cost = node.getEstimatedCost().get(i);
List<Symbol> outputSymbols = node.getOutputs().stream().map(TypedSymbol::getSymbol).collect(toList());
output.append(format("{rows: %s (%s), cpu: %s, memory: %s, network: %s}", formatAsLong(stats.getOutputRowCount()), formatAsDataSize(stats.getOutputSizeInBytes(outputSymbols, plan.getTypes())), formatAsCpuCost(cost.getCpuCost()), formatAsDataSize(cost.getMaxMemory()), formatAsDataSize(cost.getNetworkCost())));
if (i < estimateCount - 1) {
output.append("/");
}
}
output.append("\n");
return output.toString();
}
Aggregations