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