use of io.trino.sql.planner.iterative.Memo in project trino by trinodb.
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).isEmpty(), "Group cost already set");
memo.storeCost(group, cost);
return cost;
}
use of io.trino.sql.planner.iterative.Memo in project trino by trinodb.
the class RuleAssert method applyRule.
private RuleApplication applyRule() {
SymbolAllocator symbolAllocator = new SymbolAllocator(types.allTypes());
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, symbolAllocator, memo, lookup, session)));
}
use of io.trino.sql.planner.iterative.Memo in project trino by trinodb.
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).isEmpty(), "Group stats already set");
memo.storeStats(group, groupStats);
return groupStats;
}
Aggregations