Search in sources :

Example 1 with BucketNodeMap

use of io.trino.execution.scheduler.BucketNodeMap in project trino by trinodb.

the class PlanFragmenter method analyzeGroupedExecution.

private SubPlan analyzeGroupedExecution(Session session, SubPlan subPlan) {
    PlanFragment fragment = subPlan.getFragment();
    GroupedExecutionProperties properties = fragment.getRoot().accept(new GroupedExecutionTagger(session, metadata, nodePartitioningManager), null);
    if (properties.isSubTreeUseful()) {
        boolean preferDynamic = fragment.getRemoteSourceNodes().stream().allMatch(node -> node.getExchangeType() == REPLICATE) && isDynamicScheduleForGroupedExecution(session);
        BucketNodeMap bucketNodeMap = nodePartitioningManager.getBucketNodeMap(session, fragment.getPartitioning(), preferDynamic);
        if (bucketNodeMap.isDynamic()) {
            fragment = fragment.withDynamicLifespanScheduleGroupedExecution(properties.getCapableTableScanNodes());
        } else {
            fragment = fragment.withFixedLifespanScheduleGroupedExecution(properties.getCapableTableScanNodes());
        }
    }
    ImmutableList.Builder<SubPlan> result = ImmutableList.builder();
    for (SubPlan child : subPlan.getChildren()) {
        result.add(analyzeGroupedExecution(session, child));
    }
    return new SubPlan(fragment, result.build());
}
Also used : BucketNodeMap(io.trino.execution.scheduler.BucketNodeMap) TableWriterNode(io.trino.sql.planner.plan.TableWriterNode) PlanNode(io.trino.sql.planner.plan.PlanNode) RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Predicates.in(com.google.common.base.Predicates.in) SystemSessionProperties.getRetryPolicy(io.trino.SystemSessionProperties.getRetryPolicy) SystemSessionProperties.isDynamicScheduleForGroupedExecution(io.trino.SystemSessionProperties.isDynamicScheduleForGroupedExecution) ConnectorPartitionHandle(io.trino.spi.connector.ConnectorPartitionHandle) TableDeleteNode(io.trino.sql.planner.plan.TableDeleteNode) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) PlanPrinter.jsonFragmentPlan(io.trino.sql.planner.planprinter.PlanPrinter.jsonFragmentPlan) Map(java.util.Map) OutputNode(io.trino.sql.planner.plan.OutputNode) SINGLE_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.SINGLE_DISTRIBUTION) JoinNode(io.trino.sql.planner.plan.JoinNode) TableScanNode(io.trino.sql.planner.plan.TableScanNode) ExplainAnalyzeNode(io.trino.sql.planner.plan.ExplainAnalyzeNode) ImmutableSet(com.google.common.collect.ImmutableSet) StatisticsWriterNode(io.trino.sql.planner.plan.StatisticsWriterNode) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) QUERY_HAS_TOO_MANY_STAGES(io.trino.spi.StandardErrorCode.QUERY_HAS_TOO_MANY_STAGES) SchedulingOrderVisitor.scheduleOrder(io.trino.sql.planner.SchedulingOrderVisitor.scheduleOrder) Set(java.util.Set) TrinoException(io.trino.spi.TrinoException) SystemSessionProperties.getQueryMaxStageCount(io.trino.SystemSessionProperties.getQueryMaxStageCount) PatternRecognitionNode(io.trino.sql.planner.plan.PatternRecognitionNode) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) QueryManagerConfig(io.trino.execution.QueryManagerConfig) SimplePlanRewriter(io.trino.sql.planner.plan.SimplePlanRewriter) List(java.util.List) NOT_PARTITIONED(io.trino.spi.connector.NotPartitionedPartitionHandle.NOT_PARTITIONED) ConnectorPartitioningHandle(io.trino.spi.connector.ConnectorPartitioningHandle) TrinoWarning(io.trino.spi.TrinoWarning) COORDINATOR_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.COORDINATOR_DISTRIBUTION) TopNRankingNode(io.trino.sql.planner.plan.TopNRankingNode) Optional(java.util.Optional) ExchangeNode(io.trino.sql.planner.plan.ExchangeNode) PlanFragmentId(io.trino.sql.planner.plan.PlanFragmentId) ValuesNode(io.trino.sql.planner.plan.ValuesNode) WindowNode(io.trino.sql.planner.plan.WindowNode) Session(io.trino.Session) Type(io.trino.spi.type.Type) RetryPolicy(io.trino.operator.RetryPolicy) REPLICATE(io.trino.sql.planner.plan.ExchangeNode.Type.REPLICATE) StatsAndCosts(io.trino.cost.StatsAndCosts) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) RowNumberNode(io.trino.sql.planner.plan.RowNumberNode) Objects.requireNonNull(java.util.Objects.requireNonNull) SystemSessionProperties(io.trino.SystemSessionProperties) RefreshMaterializedViewNode(io.trino.sql.planner.plan.RefreshMaterializedViewNode) AggregationNode(io.trino.sql.planner.plan.AggregationNode) StageExecutionDescriptor.ungroupedExecution(io.trino.operator.StageExecutionDescriptor.ungroupedExecution) TablePartitioning(io.trino.metadata.TableProperties.TablePartitioning) SystemSessionProperties.isForceSingleNodeOutput(io.trino.SystemSessionProperties.isForceSingleNodeOutput) PlanVisitor(io.trino.sql.planner.plan.PlanVisitor) TOO_MANY_STAGES(io.trino.spi.connector.StandardWarningCode.TOO_MANY_STAGES) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) Maps(com.google.common.collect.Maps) FunctionManager(io.trino.metadata.FunctionManager) TableHandle(io.trino.metadata.TableHandle) REMOTE(io.trino.sql.planner.plan.ExchangeNode.Scope.REMOTE) SOURCE_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.SOURCE_DISTRIBUTION) WarningCollector(io.trino.execution.warnings.WarningCollector) Metadata(io.trino.metadata.Metadata) TableFinishNode(io.trino.sql.planner.plan.TableFinishNode) BucketNodeMap(io.trino.execution.scheduler.BucketNodeMap) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Predicates.in (com.google.common.base.Predicates.in)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)1 Maps (com.google.common.collect.Maps)1 Session (io.trino.Session)1 SystemSessionProperties (io.trino.SystemSessionProperties)1 SystemSessionProperties.getQueryMaxStageCount (io.trino.SystemSessionProperties.getQueryMaxStageCount)1 SystemSessionProperties.getRetryPolicy (io.trino.SystemSessionProperties.getRetryPolicy)1 SystemSessionProperties.isDynamicScheduleForGroupedExecution (io.trino.SystemSessionProperties.isDynamicScheduleForGroupedExecution)1 SystemSessionProperties.isForceSingleNodeOutput (io.trino.SystemSessionProperties.isForceSingleNodeOutput)1 StatsAndCosts (io.trino.cost.StatsAndCosts)1 QueryManagerConfig (io.trino.execution.QueryManagerConfig)1 BucketNodeMap (io.trino.execution.scheduler.BucketNodeMap)1 WarningCollector (io.trino.execution.warnings.WarningCollector)1 FunctionManager (io.trino.metadata.FunctionManager)1 Metadata (io.trino.metadata.Metadata)1