Search in sources :

Example 1 with StreamProperties

use of com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties in project presto by prestodb.

the class RuntimeReorderJoinSides method checkBuildSidePropertySatisfied.

// Check if the property of a planNode satisfies the requirements for directly feeding as the build side of a JoinNode.
private boolean checkBuildSidePropertySatisfied(PlanNode node, List<VariableReferenceExpression> partitioningColumns, Context context) {
    StreamPreferredProperties requiredBuildProperty;
    if (getTaskConcurrency(context.getSession()) > 1) {
        requiredBuildProperty = exactlyPartitionedOn(partitioningColumns);
    } else {
        requiredBuildProperty = singleStream();
    }
    StreamProperties nodeProperty = derivePropertiesRecursively(node, metadata, parser, context);
    return requiredBuildProperty.isSatisfiedBy(nodeProperty);
}
Also used : StreamPreferredProperties(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties) StreamProperties(com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties)

Example 2 with StreamProperties

use of com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties in project presto by prestodb.

the class RuntimeReorderJoinSides method derivePropertiesRecursively.

private StreamProperties derivePropertiesRecursively(PlanNode node, Metadata metadata, SqlParser parser, Context context) {
    PlanNode actual = context.getLookup().resolve(node);
    List<StreamProperties> inputProperties = actual.getSources().stream().map(source -> derivePropertiesRecursively(source, metadata, parser, context)).collect(toImmutableList());
    return StreamPropertyDerivations.deriveProperties(actual, inputProperties, metadata, context.getSession(), context.getVariableAllocator().getTypes(), parser);
}
Also used : ExchangeNode.systemPartitionedExchange(com.facebook.presto.sql.planner.plan.ExchangeNode.systemPartitionedExchange) Logger(com.facebook.airlift.log.Logger) StreamPropertyDerivations(com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations) Captures(com.facebook.presto.matching.Captures) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) StreamPreferredProperties.exactlyPartitionedOn(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.exactlyPartitionedOn) Patterns.join(com.facebook.presto.sql.planner.plan.Patterns.join) Pattern(com.facebook.presto.matching.Pattern) StreamPreferredProperties.fixedParallelism(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.fixedParallelism) LOCAL(com.facebook.presto.sql.planner.plan.ExchangeNode.Scope.LOCAL) Objects.requireNonNull(java.util.Objects.requireNonNull) SystemSessionProperties.isJoinSpillingEnabled(com.facebook.presto.SystemSessionProperties.isJoinSpillingEnabled) StreamPreferredProperties.singleStream(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.singleStream) SystemSessionProperties.getTaskConcurrency(com.facebook.presto.SystemSessionProperties.getTaskConcurrency) PlanNodeSearcher.searchFrom(com.facebook.presto.sql.planner.optimizations.PlanNodeSearcher.searchFrom) ExchangeNode.gatheringExchange(com.facebook.presto.sql.planner.plan.ExchangeNode.gatheringExchange) JoinNode(com.facebook.presto.sql.planner.plan.JoinNode) Rule(com.facebook.presto.sql.planner.iterative.Rule) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) StatsProvider(com.facebook.presto.cost.StatsProvider) String.format(java.lang.String.format) SqlParser(com.facebook.presto.sql.parser.SqlParser) StreamPreferredProperties.defaultParallelism(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.defaultParallelism) RIGHT(com.facebook.presto.sql.planner.plan.JoinNode.Type.RIGHT) SystemSessionProperties.isSpillEnabled(com.facebook.presto.SystemSessionProperties.isSpillEnabled) PlanNode(com.facebook.presto.spi.plan.PlanNode) List(java.util.List) REPLICATED(com.facebook.presto.sql.planner.plan.JoinNode.DistributionType.REPLICATED) LEFT(com.facebook.presto.sql.planner.plan.JoinNode.Type.LEFT) TableScanNode(com.facebook.presto.spi.plan.TableScanNode) StreamProperties(com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties) StreamPreferredProperties(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties) Optional(java.util.Optional) PARTITIONED(com.facebook.presto.sql.planner.plan.JoinNode.DistributionType.PARTITIONED) Metadata(com.facebook.presto.metadata.Metadata) ExchangeNode(com.facebook.presto.sql.planner.plan.ExchangeNode) PlanNode(com.facebook.presto.spi.plan.PlanNode) StreamProperties(com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties)

Example 3 with StreamProperties

use of com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties in project presto by prestodb.

the class RuntimeReorderJoinSides method checkProbeSidePropertySatisfied.

// Check if the new probe side after removing unnecessary local exchange is valid.
private boolean checkProbeSidePropertySatisfied(PlanNode node, Context context) {
    StreamPreferredProperties requiredProbeProperty;
    if (isSpillEnabled(context.getSession()) && isJoinSpillingEnabled(context.getSession())) {
        requiredProbeProperty = fixedParallelism();
    } else {
        requiredProbeProperty = defaultParallelism(context.getSession());
    }
    StreamProperties nodeProperty = derivePropertiesRecursively(node, metadata, parser, context);
    return requiredProbeProperty.isSatisfiedBy(nodeProperty);
}
Also used : StreamPreferredProperties(com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties) StreamProperties(com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties)

Aggregations

StreamPreferredProperties (com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties)3 StreamProperties (com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.StreamProperties)3 Logger (com.facebook.airlift.log.Logger)1 SystemSessionProperties.getTaskConcurrency (com.facebook.presto.SystemSessionProperties.getTaskConcurrency)1 SystemSessionProperties.isJoinSpillingEnabled (com.facebook.presto.SystemSessionProperties.isJoinSpillingEnabled)1 SystemSessionProperties.isSpillEnabled (com.facebook.presto.SystemSessionProperties.isSpillEnabled)1 StatsProvider (com.facebook.presto.cost.StatsProvider)1 Captures (com.facebook.presto.matching.Captures)1 Pattern (com.facebook.presto.matching.Pattern)1 Metadata (com.facebook.presto.metadata.Metadata)1 PlanNode (com.facebook.presto.spi.plan.PlanNode)1 TableScanNode (com.facebook.presto.spi.plan.TableScanNode)1 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)1 SqlParser (com.facebook.presto.sql.parser.SqlParser)1 Rule (com.facebook.presto.sql.planner.iterative.Rule)1 PlanNodeSearcher.searchFrom (com.facebook.presto.sql.planner.optimizations.PlanNodeSearcher.searchFrom)1 StreamPreferredProperties.defaultParallelism (com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.defaultParallelism)1 StreamPreferredProperties.exactlyPartitionedOn (com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.exactlyPartitionedOn)1 StreamPreferredProperties.fixedParallelism (com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.fixedParallelism)1 StreamPreferredProperties.singleStream (com.facebook.presto.sql.planner.optimizations.StreamPreferredProperties.singleStream)1