Search in sources :

Example 1 with SqlQuerySchedulerInterface

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());
}
Also used : SqlQuerySchedulerInterface(com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface) DataSize(io.airlift.units.DataSize) BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo)

Example 2 with SqlQuerySchedulerInterface

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));
}
Also used : SqlQuerySchedulerInterface(com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface)

Example 3 with SqlQuerySchedulerInterface

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);
    }
}
Also used : OutputBuffers.createInitialEmptyOutputBuffers(com.facebook.presto.execution.buffer.OutputBuffers.createInitialEmptyOutputBuffers) OutputBuffers.createSpoolingOutputBuffers(com.facebook.presto.execution.buffer.OutputBuffers.createSpoolingOutputBuffers) OutputBuffers(com.facebook.presto.execution.buffer.OutputBuffers) CloseableSplitSourceProvider(com.facebook.presto.split.CloseableSplitSourceProvider) SplitSourceFactory(com.facebook.presto.sql.planner.SplitSourceFactory) SqlQuerySchedulerInterface(com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface) PartitioningHandle(com.facebook.presto.sql.planner.PartitioningHandle) SubPlan(com.facebook.presto.sql.planner.SubPlan)

Example 4 with SqlQuerySchedulerInterface

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();
}
Also used : SqlQuerySchedulerInterface(com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface) DataSize(io.airlift.units.DataSize) BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo)

Example 5 with SqlQuerySchedulerInterface

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();
}
Also used : SqlQuerySchedulerInterface(com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface) DataSize(io.airlift.units.DataSize) BasicQueryInfo(com.facebook.presto.server.BasicQueryInfo)

Aggregations

SqlQuerySchedulerInterface (com.facebook.presto.execution.scheduler.SqlQuerySchedulerInterface)8 BasicQueryInfo (com.facebook.presto.server.BasicQueryInfo)5 DataSize (io.airlift.units.DataSize)4 SetThreadName (com.facebook.airlift.concurrent.SetThreadName)1 OutputBuffers (com.facebook.presto.execution.buffer.OutputBuffers)1 OutputBuffers.createInitialEmptyOutputBuffers (com.facebook.presto.execution.buffer.OutputBuffers.createInitialEmptyOutputBuffers)1 OutputBuffers.createSpoolingOutputBuffers (com.facebook.presto.execution.buffer.OutputBuffers.createSpoolingOutputBuffers)1 CloseableSplitSourceProvider (com.facebook.presto.split.CloseableSplitSourceProvider)1 PartitioningHandle (com.facebook.presto.sql.planner.PartitioningHandle)1 SplitSourceFactory (com.facebook.presto.sql.planner.SplitSourceFactory)1 SubPlan (com.facebook.presto.sql.planner.SubPlan)1 Duration (io.airlift.units.Duration)1