MCPcopy Create free account
hub / github.com/crate/crate / quickExec

Method quickExec

server/src/main/java/io/crate/session/Session.java:239–293  ·  view source on GitHub ↗

Execute a query in one step, avoiding the parse/bind/execute/sync procedure. Opposed to using parse/bind/execute/sync this method is thread-safe. This is used for system calls and statement_timeout is not accounted for here.

(String statement, ResultReceiver<?> resultReceiver, Row params)

Source from the content-addressed store, hash-verified

237 * This is used for system calls and statement_timeout is not accounted for here.
238 */
239 public void quickExec(String statement, ResultReceiver<?> resultReceiver, Row params) {
240 lastStmt = statement;
241 CoordinatorTxnCtx txnCtx = new CoordinatorTxnCtx(sessionSettings);
242 validateStatementLength(statement);
243 Statement parsedStmt = SqlParser.createStatement(statement);
244 AnalyzedStatement analyzedStatement = analyzer.analyze(
245 parsedStmt,
246 sessionSettings,
247 ParamTypeHints.EMPTY,
248 cursors
249 );
250 RoutingProvider routingProvider = new RoutingProvider(Randomness.get().nextInt(), planner.getAwarenessAttributes());
251 mostRecentJobID = UUIDs.dirtyUUID();
252 final UUID jobId = mostRecentJobID;
253 PlannerContext plannerContext = planner.createContext(
254 routingProvider,
255 jobId,
256 txnCtx,
257 0,
258 params,
259 cursors,
260 currentTransactionState,
261 TimeoutToken.noopToken()
262 );
263 Plan plan;
264 try {
265 plan = planner.plan(analyzedStatement, plannerContext);
266 } catch (Throwable t) {
267 jobsLogs.logPreExecutionFailure(jobId, id, statement, SQLExceptions.messageOf(t), sessionSettings.sessionUser());
268 throw t;
269 }
270
271 StatementClassifier.Classification classification = StatementClassifier.classify(plan);
272 jobsLogs.logExecutionStart(jobId, id, statement, sessionSettings.sessionUser(), classification);
273 JobsLogsUpdateListener jobsLogsUpdateListener = new JobsLogsUpdateListener(jobId, jobsLogs);
274 if (!analyzedStatement.isWriteOperation()) {
275 resultReceiver = new RetryOnFailureResultReceiver<>(
276 tempErrorRetryCount,
277 executor.clusterService(),
278 resultReceiver,
279 jobId,
280 (newJobId, retryResultReceiver) -> retryQuery(
281 newJobId,
282 analyzedStatement,
283 routingProvider,
284 new RowConsumerToResultReceiver(retryResultReceiver, 0, jobsLogsUpdateListener),
285 params,
286 txnCtx,
287 TimeoutToken.noopToken()
288 )
289 );
290 }
291 RowConsumerToResultReceiver consumer = new RowConsumerToResultReceiver(resultReceiver, 0, jobsLogsUpdateListener);
292 Plan.execute(plan, executor, plannerContext, consumer, params, SubQueryResults.EMPTY);
293 }
294
295 private void retryQuery(UUID jobId,
296 AnalyzedStatement stmt,

Callers 9

setupIndexerMethod · 0.95
executeBulkMethod · 0.80
updateStatsMethod · 0.80
getRowCountMethod · 0.80
setupMethod · 0.80

Calls 15

createStatementMethod · 0.95
getMethod · 0.95
dirtyUUIDMethod · 0.95
noopTokenMethod · 0.95
messageOfMethod · 0.95
classifyMethod · 0.95
isWriteOperationMethod · 0.95
retryQueryMethod · 0.95
executeMethod · 0.95