use of org.neo4j.fabric.planning.FabricPlan in project neo4j by neo4j.
the class FabricExecutor method run.
public StatementResult run(FabricTransaction fabricTransaction, String statement, MapValue parameters) {
StatementLifecycle lifecycle = statementLifecycles.create(fabricTransaction.getTransactionInfo(), statement, parameters);
lifecycle.startProcessing();
fabricTransaction.setLastSubmittedStatement(lifecycle);
try {
String defaultGraphName = fabricTransaction.getTransactionInfo().getSessionDatabaseId().name();
FabricPlanner.PlannerInstance plannerInstance = planner.instance(statement, parameters, defaultGraphName);
UseEvaluation.Instance useEvaluator = useEvaluation.instance(statement);
FabricPlan plan = plannerInstance.plan();
Fragment query = plan.query();
lifecycle.doneFabricProcessing(plan);
AccessMode accessMode = fabricTransaction.getTransactionInfo().getAccessMode();
RoutingContext routingContext = fabricTransaction.getTransactionInfo().getRoutingContext();
if (plan.debugOptions().logPlan()) {
log.debug(String.format("Fabric plan: %s", Fragment.pretty().asString(query)));
}
var statementResult = fabricTransaction.execute(ctx -> {
FabricStatementExecution execution;
if (plan.debugOptions().logRecords()) {
execution = new FabricLoggingStatementExecution(plan, plannerInstance, useEvaluator, parameters, accessMode, routingContext, ctx, log, lifecycle, dataStreamConfig);
} else {
execution = new FabricStatementExecution(plan, plannerInstance, useEvaluator, parameters, accessMode, routingContext, ctx, lifecycle, dataStreamConfig);
}
return execution.run();
});
var resultWithErrorMapping = withErrorMapping(statementResult, FabricSecondaryException.class, FabricSecondaryException::getPrimaryException);
return new FabricExecutionStatementResultImpl(resultWithErrorMapping, failure -> rollbackOnFailure(fabricTransaction, failure));
} catch (RuntimeException e) {
lifecycle.endFailure(e);
rollbackOnFailure(fabricTransaction, e);
throw e;
}
}
Aggregations