Search in sources :

Example 1 with Memo

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;
}
Also used : Memo(io.trino.sql.planner.iterative.Memo)

Example 2 with Memo

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)));
}
Also used : SymbolAllocator(io.trino.sql.planner.SymbolAllocator) PlanNode(io.trino.sql.planner.plan.PlanNode) Lookup(io.trino.sql.planner.iterative.Lookup) Memo(io.trino.sql.planner.iterative.Memo)

Example 3 with Memo

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;
}
Also used : Memo(io.trino.sql.planner.iterative.Memo)

Aggregations

Memo (io.trino.sql.planner.iterative.Memo)3 SymbolAllocator (io.trino.sql.planner.SymbolAllocator)1 Lookup (io.trino.sql.planner.iterative.Lookup)1 PlanNode (io.trino.sql.planner.plan.PlanNode)1