Class PigRelOpVisitor

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  PigRelOpVisitor.GroupType
      Type of Pig groups
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected PigRelBuilder builder  
      private org.apache.pig.newplan.Operator currentRoot  
      private static java.lang.String RANK_PREFIX  
      • Fields inherited from class org.apache.pig.newplan.PlanVisitor

        currentWalker, DEFAULT_SCOPE, plan
    • Constructor Summary

      Constructors 
      Constructor Description
      PigRelOpVisitor​(org.apache.pig.newplan.OperatorPlan plan, org.apache.pig.newplan.PlanWalker walker, PigRelBuilder builder)
      Creates a PigRelOpVisitor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void adjustCubeInput()
      Adjusts the rel input for Pig Cube operator.
      private RexNode buildRankField​(org.apache.pig.newplan.logical.relational.LORank loRank)
      Builds a window function for LORank.
      (package private) org.apache.pig.newplan.Operator getCurrentRoot()  
      private java.util.List<RexNode> getGroupRowOperands​(java.util.List<RexNode> fieldRels, boolean isCubeRollup)
      Gets the operands for the ROW operator to construct the group column.
      private RelDataType getGroupRowType​(java.util.List<RexNode> groupFields, boolean isCubeRollup)  
      private static PigRelOpVisitor.GroupType getGroupType​(org.apache.pig.newplan.logical.relational.LOCogroup pigGroup)
      Checks the group type of a group.
      private static JoinRelType getJoinType​(boolean leftInner, boolean rightInner)
      Decides the join type from the inner types of both relation.
      private void joinInternal​(org.apache.pig.impl.util.MultiMap<java.lang.Integer,​org.apache.pig.newplan.logical.expression.LogicalExpressionPlan> joinPlans, boolean[] innerFlags)
      Joins a list of relations (previously pushed into the builder).
      private void preprocessCogroup​(org.apache.pig.newplan.logical.relational.LOCogroup loCogroup, boolean isCubeRollup)
      Projects out group key and the row for each relation
      boolean preVisit​(org.apache.pig.newplan.logical.relational.LogicalRelationalOperator root)
      Called before a node.
      private void processCube​(PigRelOpVisitor.GroupType groupType, org.apache.pig.newplan.logical.relational.LOCogroup loCogroup)
      Processes a CUBE/ROLLUP group type.
      private void processRegularGroup​(org.apache.pig.newplan.logical.relational.LOCogroup loCogroup)
      Processes regular a group/group.
      private void projectGroup​(int groupCount)
      Projects group key with 'group' alias so that upstream operator can refer to, along with other aggregate columns.
      (package private) java.util.List<RelNode> translate()
      Translates the given pig logical plan into a list of relational algebra plans.
      void visit​(org.apache.pig.newplan.logical.relational.LOCogroup loCogroup)  
      void visit​(org.apache.pig.newplan.logical.relational.LOCross loCross)  
      void visit​(org.apache.pig.newplan.logical.relational.LOCube cube)  
      void visit​(org.apache.pig.newplan.logical.relational.LODistinct loDistinct)  
      void visit​(org.apache.pig.newplan.logical.relational.LOFilter filter)  
      void visit​(org.apache.pig.newplan.logical.relational.LOForEach foreach)  
      void visit​(org.apache.pig.newplan.logical.relational.LOGenerate gen)  
      void visit​(org.apache.pig.newplan.logical.relational.LOInnerLoad load)  
      void visit​(org.apache.pig.newplan.logical.relational.LOJoin join)  
      void visit​(org.apache.pig.newplan.logical.relational.LOLimit loLimit)  
      void visit​(org.apache.pig.newplan.logical.relational.LOLoad load)  
      void visit​(org.apache.pig.newplan.logical.relational.LONative nativeMR)  
      void visit​(org.apache.pig.newplan.logical.relational.LORank loRank)  
      void visit​(org.apache.pig.newplan.logical.relational.LOSort loSort)  
      void visit​(org.apache.pig.newplan.logical.relational.LOSplit loSplit)  
      void visit​(org.apache.pig.newplan.logical.relational.LOSplitOutput loSplitOutput)  
      void visit​(org.apache.pig.newplan.logical.relational.LOStore store)  
      void visit​(org.apache.pig.newplan.logical.relational.LOStream loStream)  
      void visit​(org.apache.pig.newplan.logical.relational.LOUnion loUnion)  
      • Methods inherited from class org.apache.pig.newplan.PlanVisitor

        getPlan, popWalker, pushWalker, visit
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • currentRoot

        private org.apache.pig.newplan.Operator currentRoot
    • Constructor Detail

      • PigRelOpVisitor

        PigRelOpVisitor​(org.apache.pig.newplan.OperatorPlan plan,
                        org.apache.pig.newplan.PlanWalker walker,
                        PigRelBuilder builder)
                 throws org.apache.pig.impl.logicalLayer.FrontendException
        Creates a PigRelOpVisitor.
        Parameters:
        plan - Pig logical plan
        walker - The walker over Pig logical plan
        builder - Relational algebra builder
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operators
    • Method Detail

      • getCurrentRoot

        org.apache.pig.newplan.Operator getCurrentRoot()
      • translate

        java.util.List<RelNode> translate()
                                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Translates the given pig logical plan into a list of relational algebra plans.
        Returns:
        The list of roots of translated plans, each corresponding to a sink operator in the Pig plan
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operators
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOLoad load)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOFilter filter)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOForEach foreach)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOCogroup loCogroup)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • projectGroup

        private void projectGroup​(int groupCount)
        Projects group key with 'group' alias so that upstream operator can refer to, along with other aggregate columns. If group consists of multiple group keys, construct a composite tuple/struct type to make it compatible with PIG group semantic.
        Parameters:
        groupCount - Number of group keys.
      • processRegularGroup

        private void processRegularGroup​(org.apache.pig.newplan.logical.relational.LOCogroup loCogroup)
                                  throws org.apache.pig.impl.logicalLayer.FrontendException
        Processes regular a group/group.
        Parameters:
        loCogroup - Pig logical group operator
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operators
      • processCube

        private void processCube​(PigRelOpVisitor.GroupType groupType,
                                 org.apache.pig.newplan.logical.relational.LOCogroup loCogroup)
                          throws org.apache.pig.impl.logicalLayer.FrontendException
        Processes a CUBE/ROLLUP group type.
        Parameters:
        groupType - type of the group, either ROLLUP or CUBE
        loCogroup - Pig logical group operator
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operator
      • adjustCubeInput

        private void adjustCubeInput()
        Adjusts the rel input for Pig Cube operator.
      • preprocessCogroup

        private void preprocessCogroup​(org.apache.pig.newplan.logical.relational.LOCogroup loCogroup,
                                       boolean isCubeRollup)
                                throws org.apache.pig.impl.logicalLayer.FrontendException
        Projects out group key and the row for each relation
        Parameters:
        loCogroup - Pig logical group operator
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operator
      • getGroupRowType

        private RelDataType getGroupRowType​(java.util.List<RexNode> groupFields,
                                            boolean isCubeRollup)
      • getGroupRowOperands

        private java.util.List<RexNode> getGroupRowOperands​(java.util.List<RexNode> fieldRels,
                                                            boolean isCubeRollup)
        Gets the operands for the ROW operator to construct the group column.
      • getGroupType

        private static PigRelOpVisitor.GroupType getGroupType​(org.apache.pig.newplan.logical.relational.LOCogroup pigGroup)
        Checks the group type of a group.
        Parameters:
        pigGroup - Pig logical group operator
        Returns:
        The group type, either CUBE, ROLLUP, or REGULAR
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOLimit loLimit)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOSort loSort)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOJoin join)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOCross loCross)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • joinInternal

        private void joinInternal​(org.apache.pig.impl.util.MultiMap<java.lang.Integer,​org.apache.pig.newplan.logical.expression.LogicalExpressionPlan> joinPlans,
                                  boolean[] innerFlags)
                           throws org.apache.pig.impl.logicalLayer.FrontendException
        Joins a list of relations (previously pushed into the builder).
        Parameters:
        joinPlans - Join keys
        innerFlags - Join type
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operator
      • getJoinType

        private static JoinRelType getJoinType​(boolean leftInner,
                                               boolean rightInner)
        Decides the join type from the inner types of both relation.
        Parameters:
        leftInner - true if the left requires inner
        rightInner - true if the right requires inner
        Returns:
        The join type, either INNER, LEFT, RIGHT, or FULL
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOUnion loUnion)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LODistinct loDistinct)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOCube cube)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOInnerLoad load)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOSplit loSplit)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOSplitOutput loSplitOutput)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOStore store)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOGenerate gen)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LORank loRank)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • buildRankField

        private RexNode buildRankField​(org.apache.pig.newplan.logical.relational.LORank loRank)
                                throws org.apache.pig.impl.logicalLayer.FrontendException
        Builds a window function for LORank.
        Parameters:
        loRank - Pig logical rank operator
        Returns:
        The window function
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operator
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LOStream loStream)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.relational.LONative nativeMR)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.relational.LogicalRelationalNodesVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • preVisit

        public boolean preVisit​(org.apache.pig.newplan.logical.relational.LogicalRelationalOperator root)
        Description copied from class: PigRelOpWalker.PlanPreVisitor
        Called before a node.
        Specified by:
        preVisit in class PigRelOpWalker.PlanPreVisitor
        Parameters:
        root - Pig logical operator to check
        Returns:
        Returns whether the node has been visited before