Search in sources :

Example 6 with CachingCostProvider

use of io.prestosql.cost.CachingCostProvider in project hetu-core by openlookeng.

the class PredicatePushDown method optimize.

@Override
public PlanNode optimize(PlanNode plan, Session session, TypeProvider types, PlanSymbolAllocator planSymbolAllocator, PlanNodeIdAllocator idAllocator, WarningCollector warningCollector) {
    requireNonNull(plan, "plan is null");
    requireNonNull(session, "session is null");
    requireNonNull(types, "types is null");
    requireNonNull(idAllocator, "idAllocator is null");
    RowExpressionPredicateExtractor predicateExtractor = new RowExpressionPredicateExtractor(new RowExpressionDomainTranslator(metadata), metadata, planSymbolAllocator, useTableProperties);
    Memo memo = new Memo(idAllocator, plan);
    Lookup lookup = Lookup.from(planNode -> Stream.of(memo.resolve(planNode)));
    StatsProvider statsProvider = new CachingStatsProvider(costCalculationHandle.getStatsCalculator(), Optional.of(memo), lookup, session, planSymbolAllocator.getTypes(), true);
    CostProvider costProvider = new CachingCostProvider(costCalculationHandle.getCostCalculator(), statsProvider, Optional.of(memo), session, planSymbolAllocator.getTypes());
    FilterPushdownForCTEHandler filterPushdownForCTEHandler = new FilterPushdownForCTEHandler(pushdownForCTE, costProvider, costCalculationHandle.getCostComparator());
    Rewriter rewriter = new Rewriter(planSymbolAllocator, idAllocator, metadata, predicateExtractor, typeAnalyzer, session, dynamicFiltering, filterPushdownForCTEHandler);
    PlanNode rewrittenNode = SimplePlanRewriter.rewriteWith(rewriter, plan, TRUE_CONSTANT);
    if (rewriter.isSecondTraverseRequired()) {
        return SimplePlanRewriter.rewriteWith(rewriter, rewrittenNode, TRUE_CONSTANT);
    }
    return rewrittenNode;
}
Also used : CachingStatsProvider(io.prestosql.cost.CachingStatsProvider) PlanNode(io.prestosql.spi.plan.PlanNode) StatsProvider(io.prestosql.cost.StatsProvider) CachingStatsProvider(io.prestosql.cost.CachingStatsProvider) CachingCostProvider(io.prestosql.cost.CachingCostProvider) RowExpressionDomainTranslator(io.prestosql.sql.relational.RowExpressionDomainTranslator) CostProvider(io.prestosql.cost.CostProvider) CachingCostProvider(io.prestosql.cost.CachingCostProvider) SimplePlanRewriter(io.prestosql.sql.planner.plan.SimplePlanRewriter) Lookup(io.prestosql.sql.planner.iterative.Lookup) Memo(io.prestosql.sql.planner.iterative.Memo) RowExpressionPredicateExtractor(io.prestosql.sql.planner.RowExpressionPredicateExtractor)

Example 7 with CachingCostProvider

use of io.prestosql.cost.CachingCostProvider in project hetu-core by openlookeng.

the class RuleAssert method formatPlan.

private String formatPlan(PlanNode plan, TypeProvider types) {
    StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, types);
    CostProvider costProvider = new CachingCostProvider(costCalculator, statsProvider, session, types);
    return inTransaction(session -> textLogicalPlan(translateExpressions(plan, types), types, metadata, StatsAndCosts.create(plan, statsProvider, costProvider), session, 2, false));
}
Also used : CachingStatsProvider(io.prestosql.cost.CachingStatsProvider) CachingStatsProvider(io.prestosql.cost.CachingStatsProvider) StatsProvider(io.prestosql.cost.StatsProvider) CachingCostProvider(io.prestosql.cost.CachingCostProvider) CostProvider(io.prestosql.cost.CostProvider) CachingCostProvider(io.prestosql.cost.CachingCostProvider)

Aggregations

CachingCostProvider (io.prestosql.cost.CachingCostProvider)7 CachingStatsProvider (io.prestosql.cost.CachingStatsProvider)7 CostProvider (io.prestosql.cost.CostProvider)6 StatsProvider (io.prestosql.cost.StatsProvider)6 PlanNode (io.prestosql.spi.plan.PlanNode)3 SystemSessionProperties.isSkipAttachingStatsWithPlan (io.prestosql.SystemSessionProperties.isSkipAttachingStatsWithPlan)2 PlanOptimizer (io.prestosql.sql.planner.optimizations.PlanOptimizer)2 PlanNodeIdAllocator (io.prestosql.spi.plan.PlanNodeIdAllocator)1 Symbol (io.prestosql.spi.plan.Symbol)1 Type (io.prestosql.spi.type.Type)1 Plan (io.prestosql.sql.planner.Plan)1 PlanSymbolAllocator (io.prestosql.sql.planner.PlanSymbolAllocator)1 RowExpressionPredicateExtractor (io.prestosql.sql.planner.RowExpressionPredicateExtractor)1 TypeProvider (io.prestosql.sql.planner.TypeProvider)1 Lookup (io.prestosql.sql.planner.iterative.Lookup)1 Memo (io.prestosql.sql.planner.iterative.Memo)1 BeginTableWrite (io.prestosql.sql.planner.optimizations.BeginTableWrite)1 SimplePlanRewriter (io.prestosql.sql.planner.plan.SimplePlanRewriter)1 RowExpressionDomainTranslator (io.prestosql.sql.relational.RowExpressionDomainTranslator)1 HashMap (java.util.HashMap)1