use of io.trino.cost.CostProvider in project trino by trinodb.
the class RuleAssert method formatPlan.
private String formatPlan(PlanNode plan, TypeProvider types) {
return inTransaction(session -> {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, types);
CostProvider costProvider = new CachingCostProvider(costCalculator, statsProvider, session, types);
return textLogicalPlan(plan, types, metadata, functionManager, StatsAndCosts.create(plan, statsProvider, costProvider), session, 2, false);
});
}
use of io.trino.cost.CostProvider in project trino by trinodb.
the class IterativeOptimizer method ruleContext.
private Rule.Context ruleContext(Context context) {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, Optional.of(context.memo), context.lookup, context.session, context.symbolAllocator.getTypes());
CostProvider costProvider = new CachingCostProvider(costCalculator, statsProvider, Optional.of(context.memo), context.session, context.symbolAllocator.getTypes());
return new Rule.Context() {
@Override
public Lookup getLookup() {
return context.lookup;
}
@Override
public PlanNodeIdAllocator getIdAllocator() {
return context.idAllocator;
}
@Override
public SymbolAllocator getSymbolAllocator() {
return context.symbolAllocator;
}
@Override
public Session getSession() {
return context.session;
}
@Override
public StatsProvider getStatsProvider() {
return statsProvider;
}
@Override
public CostProvider getCostProvider() {
return costProvider;
}
@Override
public void checkTimeoutNotExhausted() {
context.checkTimeoutNotExhausted();
}
@Override
public WarningCollector getWarningCollector() {
return context.warningCollector;
}
};
}
use of io.trino.cost.CostProvider in project trino by trinodb.
the class RuleAssert method ruleContext.
private Rule.Context ruleContext(StatsCalculator statsCalculator, CostCalculator costCalculator, SymbolAllocator symbolAllocator, Memo memo, Lookup lookup, Session session) {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, Optional.of(memo), lookup, session, symbolAllocator.getTypes());
CostProvider costProvider = new CachingCostProvider(costCalculator, statsProvider, Optional.of(memo), session, symbolAllocator.getTypes());
return new Rule.Context() {
@Override
public Lookup getLookup() {
return lookup;
}
@Override
public PlanNodeIdAllocator getIdAllocator() {
return idAllocator;
}
@Override
public SymbolAllocator getSymbolAllocator() {
return symbolAllocator;
}
@Override
public Session getSession() {
return session;
}
@Override
public StatsProvider getStatsProvider() {
return statsProvider;
}
@Override
public CostProvider getCostProvider() {
return costProvider;
}
@Override
public void checkTimeoutNotExhausted() {
}
@Override
public WarningCollector getWarningCollector() {
return WarningCollector.NOOP;
}
};
}
use of io.trino.cost.CostProvider in project trino by trinodb.
the class LogicalPlanner method plan.
public Plan plan(Analysis analysis, Stage stage, boolean collectPlanStatistics) {
PlanNode root = planStatement(analysis, analysis.getStatement());
if (LOG.isDebugEnabled()) {
LOG.debug("Initial plan:\n%s", PlanPrinter.textLogicalPlan(root, symbolAllocator.getTypes(), metadata, plannerContext.getFunctionManager(), StatsAndCosts.empty(), session, 0, false));
}
planSanityChecker.validateIntermediatePlan(root, session, plannerContext, typeAnalyzer, symbolAllocator.getTypes(), warningCollector);
if (stage.ordinal() >= OPTIMIZED.ordinal()) {
for (PlanOptimizer optimizer : planOptimizers) {
root = optimizer.optimize(root, session, symbolAllocator.getTypes(), symbolAllocator, idAllocator, warningCollector);
requireNonNull(root, format("%s returned a null plan", optimizer.getClass().getName()));
if (LOG.isDebugEnabled()) {
LOG.debug("%s:\n%s", optimizer.getClass().getName(), PlanPrinter.textLogicalPlan(root, symbolAllocator.getTypes(), metadata, plannerContext.getFunctionManager(), StatsAndCosts.empty(), session, 0, false));
}
}
}
if (stage.ordinal() >= OPTIMIZED_AND_VALIDATED.ordinal()) {
// make sure we produce a valid plan after optimizations run. This is mainly to catch programming errors
planSanityChecker.validateFinalPlan(root, session, plannerContext, typeAnalyzer, symbolAllocator.getTypes(), warningCollector);
}
TypeProvider types = symbolAllocator.getTypes();
StatsAndCosts statsAndCosts = StatsAndCosts.empty();
if (collectPlanStatistics) {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, types);
CostProvider costProvider = new CachingCostProvider(costCalculator, statsProvider, Optional.empty(), session, types);
statsAndCosts = StatsAndCosts.create(root, statsProvider, costProvider);
}
return new Plan(root, types, statsAndCosts);
}
Aggregations