use of io.crate.action.sql.BatchConsumerToResultReceiver in project crate by crate.
the class BatchPortal method sync.
@Override
public CompletableFuture<Void> sync(Planner planner, JobsLogs jobsLogs) {
CountdownFutureCallback completionCallback = new CountdownFutureCallback(analysis.size());
for (int i = 0; i < analysis.size(); i++) {
UUID jobId = UUID.randomUUID();
Plan plan;
String stmt = queries.get(i);
try {
plan = planner.plan(analysis.get(i), jobId, 0, 0);
} catch (Throwable t) {
jobsLogs.logPreExecutionFailure(jobId, stmt, SQLExceptions.messageOf(t));
throw t;
}
ResultReceiver resultReceiver = resultReceivers.get(i);
jobsLogs.logExecutionStart(jobId, stmt);
JobsLogsUpdateListener jobsLogsUpdateListener = new JobsLogsUpdateListener(jobId, jobsLogs);
resultReceiver.completionFuture().whenComplete(jobsLogsUpdateListener).whenComplete(completionCallback);
BatchConsumer consumer = new BatchConsumerToResultReceiver(resultReceiver, 0);
portalContext.getExecutor().execute(plan, consumer, new RowN(batchParams.toArray()));
}
synced = true;
return completionCallback;
}
use of io.crate.action.sql.BatchConsumerToResultReceiver in project crate by crate.
the class SimplePortal method sync.
@Override
public CompletableFuture<?> sync(Planner planner, JobsLogs jobsLogs) {
UUID jobId = UUID.randomUUID();
Plan plan;
try {
plan = planner.plan(analysis, jobId, defaultLimit, maxRows);
} catch (Throwable t) {
jobsLogs.logPreExecutionFailure(jobId, query, SQLExceptions.messageOf(t));
throw t;
}
if (!analysis.analyzedStatement().isWriteOperation()) {
resultReceiver = new ResultReceiverRetryWrapper(resultReceiver, this, portalContext.getAnalyzer(), planner, portalContext.getExecutor(), jobId, sessionContext);
}
jobsLogs.logExecutionStart(jobId, query);
JobsLogsUpdateListener jobsLogsUpdateListener = new JobsLogsUpdateListener(jobId, jobsLogs);
CompletableFuture completableFuture = resultReceiver.completionFuture().whenComplete(jobsLogsUpdateListener);
if (!resumeIfSuspended()) {
consumer = new BatchConsumerToResultReceiver(resultReceiver, maxRows);
portalContext.getExecutor().execute(plan, consumer, this.rowParams);
}
synced = true;
return completableFuture;
}
Aggregations