Class PigRelExVisitor


  • class PigRelExVisitor
    extends org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
    Visits pig expression plans and converts them into corresponding RexNodes.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private PigRelBuilder builder
      The relational algebra builder customized for Pig.
      private int inputCount
      Number of inputs
      private int inputOrdinal
      Input ordinal
      private java.util.Deque<RexNode> stack
      Stack used during post order walking process when processing a Pig expression plan
      • Fields inherited from class org.apache.pig.newplan.PlanVisitor

        currentWalker, DEFAULT_SCOPE, plan
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PigRelExVisitor​(org.apache.pig.newplan.OperatorPlan expressionPlan, org.apache.pig.newplan.PlanWalker walker, PigRelBuilder builder, int inputCount, int inputOrdinal)
      Creates a PigRelExVisitor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private com.google.common.collect.ImmutableList<RexNode> buildBinaryOperands()
      Builds operands for a binary operator.
      private com.google.common.collect.ImmutableList<RexNode> buildOperands​(int numOps)
      Builds operands for an operator from expressions on the top of the visitor stack.
      private int optSize​(java.util.List<org.apache.pig.newplan.Operator> list)  
      private RexNode replacePatternIfPossible​(RexNode rexNode)
      Replaces Pig regular expressions with SQL regular expressions in a string.
      private java.util.List<RexNode> translate()
      Translates the given pig expression plan into a list of relational algebra expressions.
      (package private) static RexNode translatePigEx​(PigRelBuilder builder, org.apache.pig.newplan.logical.expression.LogicalExpressionPlan pigEx)
      Translates a Pig expression plans into relational algebra expressions.
      (package private) static RexNode translatePigEx​(PigRelBuilder builder, org.apache.pig.newplan.logical.expression.LogicalExpressionPlan pigEx, int inputCount, int inputOrdinal)
      Translates a Pig expression plans into relational algebra expressions.
      void visit​(org.apache.pig.newplan.logical.expression.AddExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.AndExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.BinCondExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.CastExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.ConstantExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.DereferenceExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.DivideExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.EqualExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.GreaterThanEqualExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.GreaterThanExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.IsNullExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.LessThanEqualExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.LessThanExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.MapLookupExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.ModExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.MultiplyExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.NegativeExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.NotEqualExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.NotExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.OrExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.ProjectExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.RegexExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.ScalarExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.SubtractExpression op)  
      void visit​(org.apache.pig.newplan.logical.expression.UserFuncExpression op)  
      • 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

      • stack

        private final java.util.Deque<RexNode> stack
        Stack used during post order walking process when processing a Pig expression plan
      • builder

        private final PigRelBuilder builder
        The relational algebra builder customized for Pig.
      • inputCount

        private final int inputCount
        Number of inputs
      • inputOrdinal

        private final int inputOrdinal
        Input ordinal
    • Constructor Detail

      • PigRelExVisitor

        private PigRelExVisitor​(org.apache.pig.newplan.OperatorPlan expressionPlan,
                                org.apache.pig.newplan.PlanWalker walker,
                                PigRelBuilder builder,
                                int inputCount,
                                int inputOrdinal)
                         throws org.apache.pig.impl.logicalLayer.FrontendException
        Creates a PigRelExVisitor.
        Parameters:
        expressionPlan - Pig expression plan
        walker - The walker over Pig expression plan.
        builder - Relational algebra builder
        inputCount - Number of inputs
        inputOrdinal - Input ordinal
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operators
    • Method Detail

      • translate

        private java.util.List<RexNode> translate()
                                           throws org.apache.pig.impl.logicalLayer.FrontendException
        Translates the given pig expression plan into a list of relational algebra expressions.
        Returns:
        Relational algebra expressions
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operators
      • translatePigEx

        static RexNode translatePigEx​(PigRelBuilder builder,
                                      org.apache.pig.newplan.logical.expression.LogicalExpressionPlan pigEx,
                                      int inputCount,
                                      int inputOrdinal)
                               throws org.apache.pig.impl.logicalLayer.FrontendException
        Translates a Pig expression plans into relational algebra expressions.
        Parameters:
        builder - Relational algebra builder
        pigEx - Pig expression plan
        inputCount - Number of inputs
        inputOrdinal - Input ordinal
        Returns:
        Relational algebra expressions
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operators
      • translatePigEx

        static RexNode translatePigEx​(PigRelBuilder builder,
                                      org.apache.pig.newplan.logical.expression.LogicalExpressionPlan pigEx)
                               throws org.apache.pig.impl.logicalLayer.FrontendException
        Translates a Pig expression plans into relational algebra expressions.
        Parameters:
        builder - Relational algebra builder
        pigEx - Pig expression plan
        Returns:
        Relational algebra expressions
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException - Exception during processing Pig operators
      • buildOperands

        private com.google.common.collect.ImmutableList<RexNode> buildOperands​(int numOps)
        Builds operands for an operator from expressions on the top of the visitor stack.
        Parameters:
        numOps - number of operands
        Returns:
        List of operand expressions
      • buildBinaryOperands

        private com.google.common.collect.ImmutableList<RexNode> buildBinaryOperands()
        Builds operands for a binary operator.
        Returns:
        List of two operand expressions
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.ConstantExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.ProjectExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.NegativeExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.EqualExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.NotEqualExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.LessThanExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.LessThanEqualExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.GreaterThanExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.GreaterThanEqualExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.RegexExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • replacePatternIfPossible

        private RexNode replacePatternIfPossible​(RexNode rexNode)
        Replaces Pig regular expressions with SQL regular expressions in a string.
        Parameters:
        rexNode - The string literal
        Returns:
        New string literal with Pig regular expressions replaced by SQL regular expressions
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.IsNullExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.NotExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.AndExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.OrExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.AddExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.SubtractExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.MultiplyExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.ModExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.DivideExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.BinCondExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.UserFuncExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • optSize

        private int optSize​(java.util.List<org.apache.pig.newplan.Operator> list)
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.DereferenceExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.CastExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.MapLookupExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException
      • visit

        public void visit​(org.apache.pig.newplan.logical.expression.ScalarExpression op)
                   throws org.apache.pig.impl.logicalLayer.FrontendException
        Overrides:
        visit in class org.apache.pig.newplan.logical.expression.LogicalExpressionVisitor
        Throws:
        org.apache.pig.impl.logicalLayer.FrontendException