org.apache.pig.newplan.logical.expression
Class ProjectExpression

java.lang.Object
  extended by org.apache.pig.newplan.Operator
      extended by org.apache.pig.newplan.logical.expression.LogicalExpression
          extended by org.apache.pig.newplan.logical.expression.ColumnExpression
              extended by org.apache.pig.newplan.logical.expression.ProjectExpression

public class ProjectExpression
extends ColumnExpression

Projection of columns in an expression.


Field Summary
 
Fields inherited from class org.apache.pig.newplan.logical.expression.LogicalExpression
fieldSchema, uidOnlyFieldSchema
 
Fields inherited from class org.apache.pig.newplan.Operator
annotations, hashPrime, location, name, plan
 
Constructor Summary
ProjectExpression(OperatorPlan plan, int inputNum, int colNum, LogicalRelationalOperator attachedRelationalOp)
          Adds projection to the plan.
ProjectExpression(OperatorPlan plan, int inputNum, LogicalRelationalOperator attachedRelationalOp)
          Constructor for range projection Adds projection to the plan.
ProjectExpression(OperatorPlan plan, int inputNum, String alias, Operator projectedOp, LogicalRelationalOperator attachedRelationalOp)
          Adds projection to the plan.
ProjectExpression(ProjectExpression projExpr, OperatorPlan plan)
          like a copy constructor, but with a plan argument
 
Method Summary
 void accept(PlanVisitor v)
          Accept a visitor at this node in the graph.
 LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan)
          Create the deep copy of this expression and add that into the passed LogicalExpressionPlan Return the copy of this expression with updated logical expression plan.
 LogicalRelationalOperator findReferent()
          Find the LogicalRelationalOperator that this projection refers to.
 LogicalRelationalOperator getAttachedRelationalOp()
           
 String getColAlias()
           
 int getColNum()
          Column number this project references.
 int getEndCol()
           
 LogicalSchema.LogicalFieldSchema getFieldSchema()
          Get the field schema for the output of this expression operator.
 int getInputNum()
          Input number this project references.
 Operator getProjectedOperator()
           
 int getStartCol()
           
 byte getType()
          Get the data type for this expression.
 boolean isEqual(Operator other)
          This is like a shallow equals comparison.
 boolean isProjectStar()
           
 boolean isRangeOrStarProject()
           
 boolean isRangeProject()
           
 void setAttachedRelationalOp(LogicalRelationalOperator attachedRelationalOp)
           
 void setColNum(int colNum)
          Set the column number for this project.
 void setColumnNumberFromAlias()
          If there is an alias, finds the column number from it.
 void setEndAlias(String endAlias)
           
 void setEndCol(int endCol)
           
 void setInputNum(int inputNum)
           
 void setStartAlias(String startAlias)
           
 void setStartCol(int startCol)
           
 String toString()
           
 
Methods inherited from class org.apache.pig.newplan.logical.expression.LogicalExpression
getNextUid, hasFieldSchema, neverUseForRealSetFieldSchema, resetFieldSchema, resetNextUid, resetUid
 
Methods inherited from class org.apache.pig.newplan.Operator
annotate, getAnnotation, getLocation, getName, getPlan, removeAnnotation, setLocation, setPlan
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProjectExpression

public ProjectExpression(OperatorPlan plan,
                         int inputNum,
                         int colNum,
                         LogicalRelationalOperator attachedRelationalOp)
Adds projection to the plan.

Parameters:
plan - LogicalExpressionPlan this projection will be a part of
inputNum - Input number this project references.
colNum - Column number this project references.
attachedRelationalOp -

ProjectExpression

public ProjectExpression(OperatorPlan plan,
                         int inputNum,
                         String alias,
                         Operator projectedOp,
                         LogicalRelationalOperator attachedRelationalOp)
Adds projection to the plan.

Parameters:
plan -
inputNum -
alias -
attachedRelationalOp -
Throws:
FrontendException

ProjectExpression

public ProjectExpression(OperatorPlan plan,
                         int inputNum,
                         LogicalRelationalOperator attachedRelationalOp)
Constructor for range projection Adds projection to the plan. The start and end alias/column-number should be set separately.

Parameters:
plan -
inputNum -
attachedRelationalOp -

ProjectExpression

public ProjectExpression(ProjectExpression projExpr,
                         OperatorPlan plan)
like a copy constructor, but with a plan argument

Parameters:
projExpr -
plan -
Method Detail

setColumnNumberFromAlias

public void setColumnNumberFromAlias()
                              throws FrontendException
If there is an alias, finds the column number from it.

Throws:
FrontendException - if there is no such alias

accept

public void accept(PlanVisitor v)
            throws FrontendException
Description copied from class: Operator
Accept a visitor at this node in the graph.

Specified by:
accept in class Operator
Parameters:
v - Visitor to accept.
Throws:
FrontendException

getInputNum

public int getInputNum()
Input number this project references. This is the input number for the relational operator that contains this expression. The count is zero based.

Returns:
input number

setInputNum

public void setInputNum(int inputNum)

getColNum

public int getColNum()
Column number this project references. The column number is the column in the relational operator that contains this expression. The count is zero based.

Returns:
column number

getColAlias

public String getColAlias()

getProjectedOperator

public Operator getProjectedOperator()

setColNum

public void setColNum(int colNum)
Set the column number for this project. This should only be called by ProjectionPatcher. Stupid Java needs friends.

Parameters:
colNum - new column number for projection

isProjectStar

public boolean isProjectStar()

isRangeProject

public boolean isRangeProject()

isRangeOrStarProject

public boolean isRangeOrStarProject()

getFieldSchema

public LogicalSchema.LogicalFieldSchema getFieldSchema()
                                                throws FrontendException
Description copied from class: LogicalExpression
Get the field schema for the output of this expression operator. This does not merely return the field schema variable. If schema is not yet set, this will attempt to construct it. Therefore it is abstract since each operator will need to construct its field schema differently.

Specified by:
getFieldSchema in class LogicalExpression
Returns:
the FieldSchema
Throws:
FrontendException

findReferent

public LogicalRelationalOperator findReferent()
                                       throws FrontendException
Find the LogicalRelationalOperator that this projection refers to.

Returns:
LRO this projection refers to
Throws:
FrontendException

isEqual

public boolean isEqual(Operator other)
                throws FrontendException
Description copied from class: Operator
This is like a shallow equals comparison. It returns true if two operators have equivalent properties even if they are different objects. Here properties mean equivalent plan and equivalent name.

Specified by:
isEqual in class Operator
Returns:
true if two object have equivalent properties, else false
Throws:
FrontendException

toString

public String toString()
Overrides:
toString in class LogicalExpression

getAttachedRelationalOp

public LogicalRelationalOperator getAttachedRelationalOp()

setAttachedRelationalOp

public void setAttachedRelationalOp(LogicalRelationalOperator attachedRelationalOp)

getType

public byte getType()
             throws FrontendException
Description copied from class: LogicalExpression
Get the data type for this expression.

Overrides:
getType in class LogicalExpression
Returns:
data type, one of the static bytes of DataType
Throws:
FrontendException

getStartCol

public int getStartCol()
Returns:
the startCol

setStartCol

public void setStartCol(int startCol)
Parameters:
startCol - the startCol to set

getEndCol

public int getEndCol()
Returns:
the endCol

setEndCol

public void setEndCol(int endCol)
Parameters:
endCol - the endCol to set

setStartAlias

public void setStartAlias(String startAlias)
                   throws FrontendException
Parameters:
startAlias -
Throws:
FrontendException

setEndAlias

public void setEndAlias(String endAlias)
                 throws FrontendException
Parameters:
endAlias -
Throws:
FrontendException

deepCopy

public LogicalExpression deepCopy(LogicalExpressionPlan lgExpPlan)
                           throws FrontendException
Description copied from class: LogicalExpression
Create the deep copy of this expression and add that into the passed LogicalExpressionPlan Return the copy of this expression with updated logical expression plan.

Specified by:
deepCopy in class LogicalExpression
Parameters:
lgExpPlan - LogicalExpressionPlan in which this expression will be added.
Returns:
LogicalExpression with its own logical expression plan.
Throws:
FrontendException


Copyright © 2007-2012 The Apache Software Foundation