use of com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface in project presto by prestodb.
the class SqlQueryExecution method getUserMemoryReservation.
@Override
public DataSize getUserMemoryReservation() {
// acquire reference to scheduler before checking finalQueryInfo, because
// state change listener sets finalQueryInfo and then clears scheduler when
// the query finishes.
SqlQuerySchedulerInterface scheduler = queryScheduler.get();
Optional<QueryInfo> finalQueryInfo = stateMachine.getFinalQueryInfo();
if (finalQueryInfo.isPresent()) {
return finalQueryInfo.get().getQueryStats().getUserMemoryReservation();
}
if (scheduler == null) {
return new DataSize(0, BYTE);
}
return succinctBytes(scheduler.getUserMemoryReservation());
}
use of com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface in project presto by prestodb.
the class SqlQueryExecution method fail.
@Override
public void fail(Throwable cause) {
requireNonNull(cause, "cause is null");
stateMachine.transitionToFailed(cause);
// acquire reference to scheduler before checking finalQueryInfo, because
// state change listener sets finalQueryInfo and then clears scheduler when
// the query finishes.
SqlQuerySchedulerInterface scheduler = queryScheduler.get();
stateMachine.updateQueryInfo(Optional.ofNullable(scheduler).map(SqlQuerySchedulerInterface::getStageInfo));
}
use of com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface in project presto by prestodb.
the class SqlQueryExecution method planDistribution.
private void planDistribution(PlanRoot plan) {
CloseableSplitSourceProvider splitSourceProvider = new CloseableSplitSourceProvider(splitManager::getSplits);
// ensure split sources are closed
stateMachine.addStateChangeListener(state -> {
if (state.isDone()) {
splitSourceProvider.close();
}
});
// if query was canceled, skip creating scheduler
if (stateMachine.isDone()) {
return;
}
SubPlan outputStagePlan = plan.getRoot();
// record output field
stateMachine.setColumns(((OutputNode) outputStagePlan.getFragment().getRoot()).getColumnNames(), outputStagePlan.getFragment().getTypes());
PartitioningHandle partitioningHandle = outputStagePlan.getFragment().getPartitioningScheme().getPartitioning().getHandle();
OutputBuffers rootOutputBuffers;
if (isSpoolingOutputBufferEnabled(getSession())) {
rootOutputBuffers = createSpoolingOutputBuffers();
} else {
rootOutputBuffers = createInitialEmptyOutputBuffers(partitioningHandle).withBuffer(OUTPUT_BUFFER_ID, BROADCAST_PARTITION_ID).withNoMoreBufferIds();
}
SplitSourceFactory splitSourceFactory = new SplitSourceFactory(splitSourceProvider, stateMachine.getWarningCollector());
// build the stage execution objects (this doesn't schedule execution)
SqlQuerySchedulerInterface scheduler = isUseLegacyScheduler(getSession()) ? LegacySqlQueryScheduler.createSqlQueryScheduler(locationFactory, executionPolicy, queryExecutor, schedulerStats, sectionExecutionFactory, remoteTaskFactory, splitSourceFactory, stateMachine.getSession(), metadata.getFunctionAndTypeManager(), stateMachine, outputStagePlan, rootOutputBuffers, plan.isSummarizeTaskInfos(), runtimePlanOptimizers, stateMachine.getWarningCollector(), idAllocator, variableAllocator.get(), planChecker, metadata, sqlParser, partialResultQueryManager) : SqlQueryScheduler.createSqlQueryScheduler(locationFactory, executionPolicy, queryExecutor, schedulerStats, sectionExecutionFactory, remoteTaskFactory, splitSourceFactory, internalNodeManager, stateMachine.getSession(), stateMachine, outputStagePlan, plan.isSummarizeTaskInfos(), metadata.getFunctionAndTypeManager(), runtimePlanOptimizers, stateMachine.getWarningCollector(), idAllocator, variableAllocator.get(), planChecker, metadata, sqlParser, partialResultQueryManager);
queryScheduler.set(scheduler);
// directly since the callback may have already fired
if (stateMachine.isDone()) {
scheduler.abort();
queryScheduler.set(null);
}
}
use of com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface in project presto by prestodb.
the class SqlQueryExecution method getRawInputDataSize.
@Override
public DataSize getRawInputDataSize() {
SqlQuerySchedulerInterface scheduler = queryScheduler.get();
Optional<QueryInfo> finalQueryInfo = stateMachine.getFinalQueryInfo();
if (finalQueryInfo.isPresent()) {
return finalQueryInfo.get().getQueryStats().getRawInputDataSize();
}
if (scheduler == null) {
return new DataSize(0, BYTE);
}
return scheduler.getRawInputDataSize();
}
use of com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface in project presto by prestodb.
the class SqlQueryExecution method getOutputDataSize.
@Override
public DataSize getOutputDataSize() {
SqlQuerySchedulerInterface scheduler = queryScheduler.get();
Optional<QueryInfo> finalQueryInfo = stateMachine.getFinalQueryInfo();
if (finalQueryInfo.isPresent()) {
return finalQueryInfo.get().getQueryStats().getOutputDataSize();
}
if (scheduler == null) {
return new DataSize(0, BYTE);
}
return scheduler.getOutputDataSize();
}
Aggregations