use of io.prestosql.cost.CachingStatsProvider in project hetu-core by openlookeng.
the class RuleAssert method ruleContext.
private Rule.Context ruleContext(StatsCalculator statsCalculator, CostCalculator costCalculator, PlanSymbolAllocator planSymbolAllocator, Memo memo, Lookup lookup, Session session) {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, Optional.of(memo), lookup, session, planSymbolAllocator.getTypes());
CostProvider costProvider = new CachingCostProvider(costCalculator, statsProvider, Optional.of(memo), session, planSymbolAllocator.getTypes());
return new Rule.Context() {
@Override
public Lookup getLookup() {
return lookup;
}
@Override
public PlanNodeIdAllocator getIdAllocator() {
return idAllocator;
}
@Override
public PlanSymbolAllocator getSymbolAllocator() {
return planSymbolAllocator;
}
@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.prestosql.cost.CachingStatsProvider in project hetu-core by openlookeng.
the class TestJoinEnumerator method createContext.
private Rule.Context createContext() {
PlanNodeIdAllocator planNodeIdAllocator = new PlanNodeIdAllocator();
Map<Symbol, Type> symbols = new HashMap<>();
symbols.put(new Symbol("A1"), BIGINT);
symbols.put(new Symbol("B1"), BIGINT);
PlanSymbolAllocator planSymbolAllocator = new PlanSymbolAllocator(symbols);
CachingStatsProvider statsProvider = new CachingStatsProvider(queryRunner.getStatsCalculator(), Optional.empty(), noLookup(), queryRunner.getDefaultSession(), planSymbolAllocator.getTypes());
CachingCostProvider costProvider = new CachingCostProvider(queryRunner.getCostCalculator(), statsProvider, Optional.empty(), queryRunner.getDefaultSession(), planSymbolAllocator.getTypes());
return new Rule.Context() {
@Override
public Lookup getLookup() {
return noLookup();
}
@Override
public PlanNodeIdAllocator getIdAllocator() {
return planNodeIdAllocator;
}
@Override
public PlanSymbolAllocator getSymbolAllocator() {
return planSymbolAllocator;
}
@Override
public Session getSession() {
return queryRunner.getDefaultSession();
}
@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.prestosql.cost.CachingStatsProvider in project hetu-core by openlookeng.
the class HetuLogicalPlanner method plan.
@Override
public Plan plan(Analysis analysis, boolean skipStatsWithPlan, Stage stage) {
PlanNode root = planStatement(analysis, analysis.getStatement());
PlanNode.SkipOptRuleLevel optimizationLevel = APPLY_ALL_RULES;
planSanityChecker.validateIntermediatePlan(root, session, metadata, typeAnalyzer, planSymbolAllocator.getTypes(), warningCollector);
if (stage.ordinal() >= Stage.OPTIMIZED.ordinal()) {
for (PlanOptimizer optimizer : planOptimizers) {
if (OptimizerUtils.isEnabledLegacy(optimizer, session, root)) {
// We run it separately in the SqlQueryExecution
if (optimizer instanceof BeginTableWrite) {
continue;
}
if (OptimizerUtils.canApplyOptimizer(optimizer, optimizationLevel)) {
root = optimizer.optimize(root, session, planSymbolAllocator.getTypes(), planSymbolAllocator, idAllocator, warningCollector);
requireNonNull(root, format("%s returned a null plan", optimizer.getClass().getName()));
optimizationLevel = optimizationLevel == APPLY_ALL_RULES ? root.getSkipOptRuleLevel() : optimizationLevel;
}
}
}
}
if (stage.ordinal() >= Stage.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, metadata, typeAnalyzer, planSymbolAllocator.getTypes(), warningCollector);
}
TypeProvider types = planSymbolAllocator.getTypes();
// we calculate stats here only if need to show as part of EXPLAIN, otherwise not needed.
if (skipStatsWithPlan && isSkipAttachingStatsWithPlan(session)) {
return new Plan(root, types, StatsAndCosts.empty());
} else {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, types);
CostProvider costProvider = new CachingCostProvider(costCalculator, statsProvider, Optional.empty(), session, types);
return new Plan(root, types, StatsAndCosts.create(root, statsProvider, costProvider));
}
}
use of io.prestosql.cost.CachingStatsProvider in project hetu-core by openlookeng.
the class RemoveUnsupportedDynamicFilters method optimize.
@Override
public PlanNode optimize(PlanNode plan, Session session, TypeProvider types, PlanSymbolAllocator planSymbolAllocator, PlanNodeIdAllocator idAllocator, WarningCollector warningCollector) {
this.removedDynamicFilterIds = new HashSet<>();
this.statsProvider = new CachingStatsProvider(statsCalculator, session, planSymbolAllocator.getTypes());
PlanWithConsumedDynamicFilters result = plan.accept(new RemoveUnsupportedDynamicFilters.Rewriter(session, metadata, removedDynamicFilterIds), ImmutableSet.of());
return SimplePlanRewriter.rewriteWith(new RemoveFilterVisitor(removedDynamicFilterIds, this.metadata), result.getNode(), null);
}
use of io.prestosql.cost.CachingStatsProvider in project hetu-core by openlookeng.
the class PlanAssert method assertPlan.
public static void assertPlan(Session session, Metadata metadata, StatsCalculator statsCalculator, Plan actual, Lookup lookup, PlanMatchPattern pattern) {
StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, actual.getTypes());
assertPlan(session, metadata, statsProvider, actual, lookup, pattern);
}
Aggregations