org.apache.pig.impl.logicalLayer
Class LogicalOperator

java.lang.Object
  extended by org.apache.pig.impl.plan.Operator<LOVisitor>
      extended by org.apache.pig.impl.logicalLayer.LogicalOperator
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Operator>
Direct Known Subclasses:
ExpressionOperator, LOCogroup, LOCross, LODefine, LODistinct, LOFilter, LOForEach, LOFRJoin, LOGenerate, LOLimit, LOLoad, LOSort, LOSplit, LOSplitOutput, LOStore, LOStream, LOUnion

public abstract class LogicalOperator
extends Operator<LOVisitor>

Parent for all Logical operators.

See Also:
Serialized Form

Field Summary
protected  String mAlias
          Name of the record set that results from this operator.
protected  boolean mIsSchemaComputed
          A boolean variable to remember if the schema has been computed
protected  LogicalPlan mPlan
          Logical plan that this operator is a part of.
protected  int mRequestedParallelism
          Requested level of parallelism for this operation.
protected  Schema mSchema
          Schema that defines the output of this operator.
protected  byte mType
          Datatype of this output of this operator.
 
Fields inherited from class org.apache.pig.impl.plan.Operator
mKey
 
Constructor Summary
LogicalOperator(LogicalPlan plan, OperatorKey k)
          Equivalent to LogicalOperator(k, 0).
LogicalOperator(LogicalPlan plan, OperatorKey k, int rp)
           
 
Method Summary
protected  Object clone()
           
 void forceSchema(Schema schema)
          Directly force the schema without reconcilation Please use with great care
 String getAlias()
           
 OperatorKey getOperatorKey()
          Get the operator key for this operator.
 LogicalPlan getPlan()
           
 ProjectionMap getProjectionMap()
          Produce a map describing how this operator modifies its projection.
 int getRequestedParallelism()
           
 List<RequiredFields> getRequiredFields()
          Get a list of fields that this operator requires.
abstract  Schema getSchema()
          Get a copy of the schema for the output of this operator.
 byte getType()
          Get the type of this operator.
protected  void reconcileSchema(Schema schema)
          Given a schema, reconcile it with our existing schema.
 Schema regenerateSchema()
           
 void setAlias(String newAlias)
           
 void setCanonicalNames()
          Calculate canonical names for all fields in the schema.
 void setPlan(LogicalPlan plan)
          Change the reference to the plan for this operator.
 void setRequestedParallelism(int newRequestedParallelism)
           
 void setSchema(Schema schema)
          Set the output schema for this operator.
 void setSchemaComputed(boolean computed)
          IMPORTANT: This method is only used for unit testing purpose.
 void setType(byte t)
          Set the type of this operator.
 boolean supportsMultipleOutputs()
          Indicates whether this operator supports multiple outputs.
 String toString()
           
 void unsetSchema()
          Unset the schema as if it had not been calculated.
abstract  void visit(LOVisitor v)
          Visit this node with the provided visitor.
 
Methods inherited from class org.apache.pig.impl.plan.Operator
compareTo, equals, hashCode, name, supportsMultipleInputs
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mSchema

protected Schema mSchema
Schema that defines the output of this operator.


mIsSchemaComputed

protected boolean mIsSchemaComputed
A boolean variable to remember if the schema has been computed


mType

protected byte mType
Datatype of this output of this operator. Operators start out with data type set to UNKNOWN, and have it set for them by the type checker.


mRequestedParallelism

protected int mRequestedParallelism
Requested level of parallelism for this operation.


mAlias

protected String mAlias
Name of the record set that results from this operator.


mPlan

protected LogicalPlan mPlan
Logical plan that this operator is a part of.

Constructor Detail

LogicalOperator

public LogicalOperator(LogicalPlan plan,
                       OperatorKey k)
Equivalent to LogicalOperator(k, 0).

Parameters:
plan - Logical plan this operator is a part of.
k - Operator key to assign to this node.

LogicalOperator

public LogicalOperator(LogicalPlan plan,
                       OperatorKey k,
                       int rp)
Parameters:
plan - Logical plan this operator is a part of.
k - Operator key to assign to this node.
rp - degree of requested parallelism with which to execute this node.
Method Detail

getOperatorKey

public OperatorKey getOperatorKey()
Get the operator key for this operator.

Overrides:
getOperatorKey in class Operator<LOVisitor>

setSchema

public void setSchema(Schema schema)
               throws FrontendException
Set the output schema for this operator. If a schema already exists, an attempt will be made to reconcile it with this new schema.

Parameters:
schema - Schema to set.
Throws:
org.apache.pig.impl.logicalLayer.parser.ParseException - if there is already a schema and the existing schema cannot be reconciled with this new schema.
FrontendException

forceSchema

public void forceSchema(Schema schema)
Directly force the schema without reconcilation Please use with great care

Parameters:
schema -

unsetSchema

public void unsetSchema()
                 throws VisitorException
Unset the schema as if it had not been calculated. This is used by anyone who reorganizes the tree and needs to have schemas recalculated.

Throws:
VisitorException

regenerateSchema

public Schema regenerateSchema()
                        throws FrontendException,
                               VisitorException
Throws:
FrontendException
VisitorException

setCanonicalNames

public void setCanonicalNames()
Calculate canonical names for all fields in the schema. This should only be used for loads or other operators that create all new fields.


getSchema

public abstract Schema getSchema()
                          throws FrontendException
Get a copy of the schema for the output of this operator.

Throws:
FrontendException

setType

public final void setType(byte t)
Set the type of this operator. This should only be called by the type checking routines.

Parameters:
t - Type to set this operator to.

getType

public byte getType()
Get the type of this operator.


getAlias

public String getAlias()

setAlias

public void setAlias(String newAlias)

getRequestedParallelism

public int getRequestedParallelism()

setRequestedParallelism

public void setRequestedParallelism(int newRequestedParallelism)

toString

public String toString()
Overrides:
toString in class Operator<LOVisitor>

reconcileSchema

protected void reconcileSchema(Schema schema)
                        throws org.apache.pig.impl.logicalLayer.parser.ParseException
Given a schema, reconcile it with our existing schema.

Parameters:
schema - Schema to reconcile with the existing.
Throws:
org.apache.pig.impl.logicalLayer.parser.ParseException - if the reconciliation is not possible.

visit

public abstract void visit(LOVisitor v)
                    throws VisitorException
Visit this node with the provided visitor. This should only be called by the visitor class itself, never directly.

Specified by:
visit in class Operator<LOVisitor>
Parameters:
v - Visitor to visit with.
Throws:
VisitException - if the visitor has a problem.
VisitorException - if the visitor has a problem.

getPlan

public LogicalPlan getPlan()

setPlan

public void setPlan(LogicalPlan plan)
Change the reference to the plan for this operator. Don't use this unless you're sure you know what you're doing.


setSchemaComputed

public void setSchemaComputed(boolean computed)
IMPORTANT: This method is only used for unit testing purpose.


supportsMultipleOutputs

public boolean supportsMultipleOutputs()
Description copied from class: Operator
Indicates whether this operator supports multiple outputs.

Specified by:
supportsMultipleOutputs in class Operator<LOVisitor>
Returns:
true if it does, otherwise false.

clone

protected Object clone()
                throws CloneNotSupportedException
Overrides:
clone in class Operator<LOVisitor>
Throws:
CloneNotSupportedException
See Also:
Do not use the clone method directly. Operators are cloned when logical plans are cloned using {@link LogicalPlanCloner}

getProjectionMap

public ProjectionMap getProjectionMap()
Produce a map describing how this operator modifies its projection.

Returns:
ProjectionMap null indicates it does not know how the projection changes, for example a join of two inputs where one input does not have a schema.

getRequiredFields

public List<RequiredFields> getRequiredFields()
Get a list of fields that this operator requires. This is not necessarily equivalent to the list of fields the operator projects. For example, a filter will project anything passed to it, but requires only the fields explicitly referenced in its filter expression.

Returns:
list of RequiredFields null indicates that the operator does not need any fields from its input.


Copyright © ${year} The Apache Software Foundation