use of com.facebook.presto.sql.planner.iterative.Memo in project presto by prestodb.
the class RuleAssert method applyRule.
private RuleApplication applyRule() {
PlanVariableAllocator variableAllocator = new PlanVariableAllocator(types.allVariables());
Memo memo = new Memo(idAllocator, plan);
Lookup lookup = Lookup.from(planNode -> Stream.of(memo.resolve(planNode)));
PlanNode memoRoot = memo.getNode(memo.getRootGroup());
return inTransaction(session -> applyRule(rule, memoRoot, ruleContext(statsCalculator, costCalculator, variableAllocator, memo, lookup, session)));
}
use of com.facebook.presto.sql.planner.iterative.Memo in project presto by prestodb.
the class CachingCostProvider method getGroupCost.
private PlanCostEstimate getGroupCost(GroupReference groupReference) {
int group = groupReference.getGroupId();
Memo memo = this.memo.orElseThrow(() -> new IllegalStateException("CachingCostProvider without memo cannot handle GroupReferences"));
Optional<PlanCostEstimate> knownCost = memo.getCost(group);
if (knownCost.isPresent()) {
return knownCost.get();
}
PlanCostEstimate cost = calculateCost(memo.getNode(group));
verify(!memo.getCost(group).isPresent(), "Group cost already set");
memo.storeCost(group, cost);
return cost;
}
use of com.facebook.presto.sql.planner.iterative.Memo in project presto by prestodb.
the class CachingStatsProvider method getGroupStats.
private PlanNodeStatsEstimate getGroupStats(GroupReference groupReference) {
int group = groupReference.getGroupId();
Memo memo = this.memo.orElseThrow(() -> new IllegalStateException("CachingStatsProvider without memo cannot handle GroupReferences"));
Optional<PlanNodeStatsEstimate> stats = memo.getStats(group);
if (stats.isPresent()) {
return stats.get();
}
PlanNodeStatsEstimate groupStats = statsCalculator.calculateStats(memo.getNode(group), this, lookup, session, types);
verify(!memo.getStats(group).isPresent(), "Group stats already set");
memo.storeStats(group, groupStats);
return groupStats;
}
Aggregations