use of io.crate.planner.PlannerContext in project crate by crate.
the class PreExecutionBenchmark method measure_parse_analyze_and_plan_simple_select.
@Benchmark
public Plan measure_parse_analyze_and_plan_simple_select() throws Exception {
String sql = "select name from users";
CoordinatorTxnCtx systemTransactionContext = CoordinatorTxnCtx.systemTransactionContext();
Analysis analysis = new Analysis(systemTransactionContext, ParamTypeHints.EMPTY);
AnalyzedStatement analyzedStatement = analyzer.analyzedStatement(SqlParser.createStatement(sql), analysis);
var jobId = UUID.randomUUID();
var routingProvider = new RoutingProvider(Randomness.get().nextInt(), planner.getAwarenessAttributes());
var clusterState = clusterService.state();
var txnCtx = CoordinatorTxnCtx.systemTransactionContext();
var plannerContext = new PlannerContext(clusterState, routingProvider, jobId, txnCtx, nodeCtx, 0, null);
return planner.plan(analyzedStatement, plannerContext);
}
use of io.crate.planner.PlannerContext in project crate by crate.
the class SetSessionPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier executor, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(plannerContext.transactionContext(), plannerContext.nodeContext(), x, params, subQueryResults);
SessionContext sessionContext = plannerContext.transactionContext().sessionContext();
Assignment<Symbol> assignment = settings.get(0);
String settingName = eval.apply(assignment.columnName()).toString();
validateSetting(settingName);
SessionSetting<?> sessionSetting = sessionSettingRegistry.settings().get(settingName);
if (sessionSetting == null) {
LOGGER.info("SET SESSION STATEMENT WILL BE IGNORED: {}", settingName);
} else {
sessionSetting.apply(sessionContext, assignment.expressions(), eval);
}
consumer.accept(InMemoryBatchIterator.empty(SENTINEL), null);
}
use of io.crate.planner.PlannerContext in project crate by crate.
the class MultiPhaseExecutor method execute.
public static CompletableFuture<SubQueryResults> execute(Map<LogicalPlan, SelectSymbol> dependencies, DependencyCarrier executor, PlannerContext plannerContext, Row params) {
List<CompletableFuture<?>> dependencyFutures = new ArrayList<>(dependencies.size());
IdentityHashMap<SelectSymbol, Object> valueBySubQuery = new IdentityHashMap<>();
for (Map.Entry<LogicalPlan, SelectSymbol> entry : dependencies.entrySet()) {
LogicalPlan depPlan = entry.getKey();
SelectSymbol selectSymbol = entry.getValue();
CollectingRowConsumer<?, ?> rowConsumer = getConsumer(selectSymbol.getResultType());
depPlan.execute(executor, PlannerContext.forSubPlan(plannerContext), rowConsumer, params, SubQueryResults.EMPTY);
dependencyFutures.add(rowConsumer.completionFuture().thenAccept(val -> {
synchronized (valueBySubQuery) {
valueBySubQuery.put(selectSymbol, val);
}
}));
}
return CompletableFuture.allOf(dependencyFutures.toArray(new CompletableFuture[0])).thenApply(ignored -> new SubQueryResults(valueBySubQuery));
}
use of io.crate.planner.PlannerContext in project crate by crate.
the class CreateTablePlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
BoundCreateTable boundCreateTable = bind(createTable, plannerContext.transactionContext(), dependencies.nodeContext(), params, subQueryResults, numberOfShards, schemas, dependencies.fulltextAnalyzerResolver());
if (boundCreateTable.noOp()) {
consumer.accept(InMemoryBatchIterator.empty(SENTINEL), null);
return;
}
tableCreator.create(boundCreateTable).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
use of io.crate.planner.PlannerContext in project crate by crate.
the class AlterTableOpenClosePlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(plannerContext.transactionContext(), plannerContext.nodeContext(), x, params, subQueryResults);
DocTableInfo tableInfo = analyzedAlterTable.tableInfo();
Table<Object> table = analyzedAlterTable.table().map(eval);
PartitionName partitionName = null;
if (tableInfo.isPartitioned()) {
partitionName = PartitionPropertiesAnalyzer.createPartitionName(table.partitionProperties(), tableInfo);
}
dependencies.alterTableOperation().executeAlterTableOpenClose(tableInfo, analyzedAlterTable.isOpenTable(), partitionName).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
Aggregations