Search in sources :

Example 1 with JoinOperatorFactory

use of com.facebook.presto.operator.JoinOperatorFactory in project presto by prestodb.

the class LocalExecutionPlanner method addLookupOuterDrivers.

private static void addLookupOuterDrivers(LocalExecutionPlanContext context) {
    // driver to output the unused rows in the lookup source
    for (DriverFactory factory : context.getDriverFactories()) {
        List<OperatorFactory> operatorFactories = factory.getOperatorFactories();
        for (int i = 0; i < operatorFactories.size(); i++) {
            OperatorFactory operatorFactory = operatorFactories.get(i);
            if (!(operatorFactory instanceof JoinOperatorFactory)) {
                continue;
            }
            JoinOperatorFactory lookupJoin = (JoinOperatorFactory) operatorFactory;
            Optional<OuterOperatorFactoryResult> outerOperatorFactoryResult = lookupJoin.createOuterOperatorFactory();
            if (outerOperatorFactoryResult.isPresent()) {
                // Add a new driver to output the unmatched rows in an outer join.
                // We duplicate all of the factories above the JoinOperator (the ones reading from the joins),
                // and replace the JoinOperator with the OuterOperator (the one that produces unmatched rows).
                ImmutableList.Builder<OperatorFactory> newOperators = ImmutableList.builder();
                newOperators.add(outerOperatorFactoryResult.get().getOuterOperatorFactory());
                operatorFactories.subList(i + 1, operatorFactories.size()).stream().map(OperatorFactory::duplicate).forEach(newOperators::add);
                context.addDriverFactory(false, factory.isOutputDriver(), newOperators.build(), OptionalInt.of(1), outerOperatorFactoryResult.get().getBuildExecutionStrategy(), Optional.empty());
            }
        }
    }
}
Also used : DistinctLimitOperatorFactory(com.facebook.presto.operator.DistinctLimitOperator.DistinctLimitOperatorFactory) LookupOuterOperatorFactory(com.facebook.presto.operator.LookupOuterOperator.LookupOuterOperatorFactory) LimitOperatorFactory(com.facebook.presto.operator.LimitOperator.LimitOperatorFactory) LocalMergeSourceOperatorFactory(com.facebook.presto.operator.exchange.LocalMergeSourceOperator.LocalMergeSourceOperatorFactory) JoinOperatorFactory(com.facebook.presto.operator.JoinOperatorFactory) UnnestOperatorFactory(com.facebook.presto.operator.unnest.UnnestOperator.UnnestOperatorFactory) ScanFilterAndProjectOperatorFactory(com.facebook.presto.operator.ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory) MetadataDeleteOperatorFactory(com.facebook.presto.operator.MetadataDeleteOperator.MetadataDeleteOperatorFactory) TableScanOperatorFactory(com.facebook.presto.operator.TableScanOperator.TableScanOperatorFactory) HashBuilderOperatorFactory(com.facebook.presto.operator.HashBuilderOperator.HashBuilderOperatorFactory) SourceOperatorFactory(com.facebook.presto.operator.SourceOperatorFactory) MarkDistinctOperatorFactory(com.facebook.presto.operator.MarkDistinctOperator.MarkDistinctOperatorFactory) StreamingAggregationOperatorFactory(com.facebook.presto.operator.StreamingAggregationOperator.StreamingAggregationOperatorFactory) ExplainAnalyzeOperatorFactory(com.facebook.presto.operator.ExplainAnalyzeOperator.ExplainAnalyzeOperatorFactory) OperatorFactory(com.facebook.presto.operator.OperatorFactory) StatisticsWriterOperatorFactory(com.facebook.presto.operator.StatisticsWriterOperator.StatisticsWriterOperatorFactory) TableWriterOperatorFactory(com.facebook.presto.operator.TableWriterOperator.TableWriterOperatorFactory) TableWriterMergeOperatorFactory(com.facebook.presto.operator.TableWriterMergeOperator.TableWriterMergeOperatorFactory) NestedLoopBuildOperatorFactory(com.facebook.presto.operator.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory) LocalExchangeSinkOperatorFactory(com.facebook.presto.operator.exchange.LocalExchangeSinkOperator.LocalExchangeSinkOperatorFactory) LocalExchangeSourceOperatorFactory(com.facebook.presto.operator.exchange.LocalExchangeSourceOperator.LocalExchangeSourceOperatorFactory) FilterAndProjectOperatorFactory(com.facebook.presto.operator.FilterAndProjectOperator.FilterAndProjectOperatorFactory) NestedLoopJoinOperatorFactory(com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) TopNOperatorFactory(com.facebook.presto.operator.TopNOperator.TopNOperatorFactory) ValuesOperatorFactory(com.facebook.presto.operator.ValuesOperator.ValuesOperatorFactory) AggregationOperatorFactory(com.facebook.presto.operator.AggregationOperator.AggregationOperatorFactory) SpatialIndexBuilderOperatorFactory(com.facebook.presto.operator.SpatialIndexBuilderOperator.SpatialIndexBuilderOperatorFactory) TableFinishOperatorFactory(com.facebook.presto.operator.TableFinishOperator.TableFinishOperatorFactory) OrderByOperatorFactory(com.facebook.presto.operator.OrderByOperator.OrderByOperatorFactory) SpatialJoinOperatorFactory(com.facebook.presto.operator.SpatialJoinOperator.SpatialJoinOperatorFactory) HashAggregationOperatorFactory(com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory) SetBuilderOperatorFactory(com.facebook.presto.operator.SetBuilderOperator.SetBuilderOperatorFactory) DevNullOperatorFactory(com.facebook.presto.operator.DevNullOperator.DevNullOperatorFactory) HashSemiJoinOperatorFactory(com.facebook.presto.operator.HashSemiJoinOperator.HashSemiJoinOperatorFactory) WindowOperatorFactory(com.facebook.presto.operator.WindowOperator.WindowOperatorFactory) RemoteProjectOperatorFactory(com.facebook.presto.operator.RemoteProjectOperator.RemoteProjectOperatorFactory) DeleteOperatorFactory(com.facebook.presto.operator.DeleteOperator.DeleteOperatorFactory) JoinOperatorFactory(com.facebook.presto.operator.JoinOperatorFactory) NestedLoopJoinOperatorFactory(com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory) SpatialJoinOperatorFactory(com.facebook.presto.operator.SpatialJoinOperator.SpatialJoinOperatorFactory) HashSemiJoinOperatorFactory(com.facebook.presto.operator.HashSemiJoinOperator.HashSemiJoinOperatorFactory) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) DriverFactory(com.facebook.presto.operator.DriverFactory) OuterOperatorFactoryResult(com.facebook.presto.operator.JoinOperatorFactory.OuterOperatorFactoryResult)

Aggregations

AggregationOperatorFactory (com.facebook.presto.operator.AggregationOperator.AggregationOperatorFactory)1 DeleteOperatorFactory (com.facebook.presto.operator.DeleteOperator.DeleteOperatorFactory)1 DevNullOperatorFactory (com.facebook.presto.operator.DevNullOperator.DevNullOperatorFactory)1 DistinctLimitOperatorFactory (com.facebook.presto.operator.DistinctLimitOperator.DistinctLimitOperatorFactory)1 DriverFactory (com.facebook.presto.operator.DriverFactory)1 ExplainAnalyzeOperatorFactory (com.facebook.presto.operator.ExplainAnalyzeOperator.ExplainAnalyzeOperatorFactory)1 FilterAndProjectOperatorFactory (com.facebook.presto.operator.FilterAndProjectOperator.FilterAndProjectOperatorFactory)1 HashAggregationOperatorFactory (com.facebook.presto.operator.HashAggregationOperator.HashAggregationOperatorFactory)1 HashBuilderOperatorFactory (com.facebook.presto.operator.HashBuilderOperator.HashBuilderOperatorFactory)1 HashSemiJoinOperatorFactory (com.facebook.presto.operator.HashSemiJoinOperator.HashSemiJoinOperatorFactory)1 JoinOperatorFactory (com.facebook.presto.operator.JoinOperatorFactory)1 OuterOperatorFactoryResult (com.facebook.presto.operator.JoinOperatorFactory.OuterOperatorFactoryResult)1 LimitOperatorFactory (com.facebook.presto.operator.LimitOperator.LimitOperatorFactory)1 LookupOuterOperatorFactory (com.facebook.presto.operator.LookupOuterOperator.LookupOuterOperatorFactory)1 MarkDistinctOperatorFactory (com.facebook.presto.operator.MarkDistinctOperator.MarkDistinctOperatorFactory)1 MetadataDeleteOperatorFactory (com.facebook.presto.operator.MetadataDeleteOperator.MetadataDeleteOperatorFactory)1 NestedLoopBuildOperatorFactory (com.facebook.presto.operator.NestedLoopBuildOperator.NestedLoopBuildOperatorFactory)1 NestedLoopJoinOperatorFactory (com.facebook.presto.operator.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory)1 OperatorFactory (com.facebook.presto.operator.OperatorFactory)1 OrderByOperatorFactory (com.facebook.presto.operator.OrderByOperator.OrderByOperatorFactory)1