org.apache.pig.impl.logicalLayer.schema
Class Schema.FieldSchema

java.lang.Object
  extended by org.apache.pig.impl.logicalLayer.schema.Schema.FieldSchema
All Implemented Interfaces:
Serializable, Cloneable
Enclosing class:
Schema

public static class Schema.FieldSchema
extends Object
implements Serializable, Cloneable

See Also:
Serialized Form

Field Summary
 String alias
          Alias for this field.
 String canonicalName
          Canonical name.
static CanonicalNamer canonicalNamer
          Canonical namer object to generate new canonical names on request.
 Schema schema
          If this is a tuple itself, it can have a schema.
 byte type
          Datatype, using codes from DataType.
 
Constructor Summary
Schema.FieldSchema(Schema.FieldSchema fs)
          Copy Constructor.
Schema.FieldSchema(String a, byte t)
          Constructor for any type.
Schema.FieldSchema(String a, Schema s)
          Constructor for tuple fields.
Schema.FieldSchema(String a, Schema s, byte t)
          Constructor for tuple fields.
 
Method Summary
static boolean castable(Schema.FieldSchema castFs, Schema.FieldSchema inputFs)
          Recursively compare two schemas to check if the input schema can be cast to the cast schema
 Schema.FieldSchema clone()
          Make a deep copy of this FieldSchema and return it.
 boolean equals(Object other)
          Two field schemas are equal if types and schemas are equal in all levels.
static boolean equals(Schema.FieldSchema fschema, Schema.FieldSchema fother, boolean relaxInner, boolean relaxAlias)
          Compare two field schema for equality
 Schema.FieldSchema findFieldSchema(String canonicalName)
          Find a field schema instance in this FieldSchema hierarchy (including "this") that matches the given canonical name.
 int hashCode()
           
 Schema.FieldSchema mergePrefixFieldSchema(Schema.FieldSchema otherFs)
          Recursively prefix merge two schemas
 Schema.FieldSchema mergePrefixFieldSchema(Schema.FieldSchema otherFs, boolean otherTakesAliasPrecedence)
          Recursively prefix merge two schemas
 Schema.FieldSchema mergePrefixFieldSchema(Schema.FieldSchema otherFs, boolean otherTakesAliasPrecedence, boolean allowMergeableTypes)
          Recursively prefix merge two schemas
static void setFieldSchemaDefaultType(Schema.FieldSchema fs, byte t)
          Recursively set NULL type to the specifid type
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

alias

public String alias
Alias for this field.


type

public byte type
Datatype, using codes from DataType.


schema

public Schema schema
If this is a tuple itself, it can have a schema. Otherwise this field must be null.


canonicalName

public String canonicalName
Canonical name. This name uniquely identifies a field throughout the query. Unlike a an alias, it cannot be changed. It will change when the field is transformed in some way (such as being used in an arithmetic expression or passed to a udf). At that point a new canonical name will be generated for the field.


canonicalNamer

public static final CanonicalNamer canonicalNamer
Canonical namer object to generate new canonical names on request. In order to ensure unique and consistent names, across all field schema objects, the object is made static.

Constructor Detail

Schema.FieldSchema

public Schema.FieldSchema(String a,
                          byte t)
Constructor for any type.

Parameters:
a - Alias, if known. If unknown leave null.
t - Type, using codes from DataType.

Schema.FieldSchema

public Schema.FieldSchema(String a,
                          Schema s)
Constructor for tuple fields.

Parameters:
a - Alias, if known. If unknown leave null.
s - Schema of this tuple.

Schema.FieldSchema

public Schema.FieldSchema(String a,
                          Schema s,
                          byte t)
                   throws FrontendException
Constructor for tuple fields.

Parameters:
a - Alias, if known. If unknown leave null.
s - Schema of this tuple.
t - Type, using codes from DataType.
Throws:
FrontendException

Schema.FieldSchema

public Schema.FieldSchema(Schema.FieldSchema fs)
Copy Constructor.

Parameters:
fs - Source FieldSchema
Method Detail

equals

public boolean equals(Object other)
Two field schemas are equal if types and schemas are equal in all levels. In order to relax alias equivalent requirement, instead use equals(FieldSchema fschema, FieldSchema fother, boolean relaxInner, boolean relaxAlias)

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

castable

public static boolean castable(Schema.FieldSchema castFs,
                               Schema.FieldSchema inputFs)
Recursively compare two schemas to check if the input schema can be cast to the cast schema

Parameters:
castFs - schema of the cast operator
inputFs - schema of the cast input
Returns:
true or falsew!

equals

public static boolean equals(Schema.FieldSchema fschema,
                             Schema.FieldSchema fother,
                             boolean relaxInner,
                             boolean relaxAlias)
Compare two field schema for equality

Parameters:
fschema -
fother -
relaxInner - If true, we don't check inner tuple schemas
relaxAlias - If true, we don't check aliases
Returns:
true if FieldSchemas are equal, false otherwise

toString

public String toString()
Overrides:
toString in class Object

clone

public Schema.FieldSchema clone()
                         throws CloneNotSupportedException
Make a deep copy of this FieldSchema and return it.

Overrides:
clone in class Object
Returns:
clone of the this FieldSchema.
Throws:
CloneNotSupportedException

mergePrefixFieldSchema

public Schema.FieldSchema mergePrefixFieldSchema(Schema.FieldSchema otherFs)
                                          throws SchemaMergeException
Recursively prefix merge two schemas

Parameters:
otherFs - the other field schema to be merged with
Returns:
the prefix merged field schema this can be null if one schema is null and allowIncompatibleTypes is true
Throws:
SchemaMergeException - if they cannot be merged

mergePrefixFieldSchema

public Schema.FieldSchema mergePrefixFieldSchema(Schema.FieldSchema otherFs,
                                                 boolean otherTakesAliasPrecedence)
                                          throws SchemaMergeException
Recursively prefix merge two schemas

Parameters:
otherFs - the other field schema to be merged with
otherTakesAliasPrecedence - true if aliases from the other field schema take precedence
Returns:
the prefix merged field schema this can be null if one schema is null and allowIncompatibleTypes is true
Throws:
SchemaMergeException - if they cannot be merged

mergePrefixFieldSchema

public Schema.FieldSchema mergePrefixFieldSchema(Schema.FieldSchema otherFs,
                                                 boolean otherTakesAliasPrecedence,
                                                 boolean allowMergeableTypes)
                                          throws SchemaMergeException
Recursively prefix merge two schemas

Parameters:
otherFs - the other field schema to be merged with
otherTakesAliasPrecedence - true if aliases from the other field schema take precedence
allowMergeableTypes - true if "mergeable" types should be allowed. Two types are mergeable if any of the following conditions is true IN THE BELOW ORDER of checks: 1) if either one has a type null or unknown and other has a type OTHER THAN null or unknown, the result type will be the latter non null/unknown type 2) If either type is bytearray, then result type will be the other (possibly non BYTEARRAY) type 3) If current type can be cast to the other type, then the result type will be the other type
Returns:
the prefix merged field schema this can be null.
Throws:
SchemaMergeException - if they cannot be merged

setFieldSchemaDefaultType

public static void setFieldSchemaDefaultType(Schema.FieldSchema fs,
                                             byte t)
Recursively set NULL type to the specifid type

Parameters:
fs - the field schema whose NULL type has to be set
t - the specified type

findFieldSchema

public Schema.FieldSchema findFieldSchema(String canonicalName)
Find a field schema instance in this FieldSchema hierarchy (including "this") that matches the given canonical name.

Parameters:
canonicalName - canonical name
Returns:
the FieldSchema instance found


Copyright © 2007-2012 The Apache Software Foundation