001/*
002 * Copyright (c) 2016 Chris K Wensel <chris@wensel.net>. All Rights Reserved.
003 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved.
004 *
005 * Project and contact information: http://www.cascading.org/
006 *
007 * This file is part of the Cascading project.
008 *
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *     http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 */
021
022package cascading.flow.tez.planner;
023
024import cascading.flow.planner.rule.RuleRegistry;
025import cascading.flow.planner.rule.annotator.LogicalMergeAnnotator;
026import cascading.flow.planner.rule.assertion.BufferAfterEveryAssert;
027import cascading.flow.planner.rule.assertion.EveryAfterBufferAssert;
028import cascading.flow.planner.rule.assertion.LoneGroupAssert;
029import cascading.flow.planner.rule.assertion.MissingGroupAssert;
030import cascading.flow.planner.rule.assertion.SplitBeforeEveryAssert;
031import cascading.flow.planner.rule.partitioner.WholeGraphStepPartitioner;
032import cascading.flow.planner.rule.transformer.ApplyAssertionLevelTransformer;
033import cascading.flow.planner.rule.transformer.ApplyDebugLevelTransformer;
034import cascading.flow.planner.rule.transformer.RemoveNoOpPipeTransformer;
035import cascading.flow.tez.planner.rule.assertion.NoHashJoinAssert;
036import cascading.flow.tez.planner.rule.partitioner.ConsecutiveGroupOrMergesNodePartitioner;
037import cascading.flow.tez.planner.rule.partitioner.SplitJoinBoundariesNodeRePartitioner;
038import cascading.flow.tez.planner.rule.partitioner.TopDownBoundariesNodePartitioner;
039import cascading.flow.tez.planner.rule.transformer.BoundaryBalanceCheckpointTransformer;
040import cascading.flow.tez.planner.rule.transformer.BoundaryBalanceGroupSplitSpliceTransformer;
041
042/**
043 * The NoHashJoinHadoop2TezRuleRegistry assumes the plan has no {@link cascading.pipe.HashJoin} Pipes in the
044 * assembly, otherwise an planner failure will be thrown.
045 * <p/>
046 * This rule registry can be used if the default registry is failing or producing less than optimal plans.
047 *
048 * @see cascading.flow.tez.planner.HashJoinHadoop2TezRuleRegistry
049 */
050public class NoHashJoinHadoop2TezRuleRegistry extends RuleRegistry
051  {
052  public NoHashJoinHadoop2TezRuleRegistry()
053    {
054//    enableDebugLogging();
055
056    // PreBalance
057    addRule( new NoHashJoinAssert() ); // fail if we encounter a HashJoin
058
059    addRule( new LoneGroupAssert() );
060    addRule( new MissingGroupAssert() );
061    addRule( new BufferAfterEveryAssert() );
062    addRule( new EveryAfterBufferAssert() );
063    addRule( new SplitBeforeEveryAssert() );
064
065    addRule( new BoundaryBalanceGroupSplitSpliceTransformer() ); // prevents AssemblyHelpersPlatformTest#testSameSourceMerge deadlock
066    addRule( new BoundaryBalanceCheckpointTransformer() );
067
068    // PreResolve
069    addRule( new RemoveNoOpPipeTransformer() );
070    addRule( new ApplyAssertionLevelTransformer() );
071    addRule( new ApplyDebugLevelTransformer() );
072    addRule( new LogicalMergeAnnotator() ); // MergePipesPlatformTest#testSameSourceMergeHashJoin
073
074    // PostResolve
075
076    // PartitionSteps
077    addRule( new WholeGraphStepPartitioner() );
078
079    // PostSteps
080
081    // PartitionNodes
082    addRule( new TopDownBoundariesNodePartitioner() );
083    addRule( new ConsecutiveGroupOrMergesNodePartitioner() );
084    addRule( new SplitJoinBoundariesNodeRePartitioner() ); // testCoGroupSelf - compensates for tez-1190
085
086    // PostNodes
087    }
088  }