public class LogicalSchema
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
LogicalSchema.LogicalFieldSchema |
static class |
LogicalSchema.MergeMode |
Constructor and Description |
---|
LogicalSchema() |
Modifier and Type | Method and Description |
---|---|
void |
addField(LogicalSchema.LogicalFieldSchema field)
Add a field to this schema.
|
static boolean |
castable(LogicalSchema inSch,
LogicalSchema outSch)
Recursively compare two schemas to check if the input schema
can be cast to the cast schema
|
LogicalSchema |
deepCopy() |
static boolean |
equals(LogicalSchema schema,
LogicalSchema other,
boolean relaxInner,
boolean relaxAlias)
Recursively compare two schemas for equality
|
int |
findField(long uid)
Look for the index of the field that contains the specified uid
|
LogicalSchema.LogicalFieldSchema |
getField(int fieldNum)
Fetch a field by field number
|
LogicalSchema.LogicalFieldSchema |
getField(java.lang.String alias)
Fetch a field by alias
|
int |
getFieldPosition(java.lang.String alias) |
java.util.List<LogicalSchema.LogicalFieldSchema> |
getFields()
Get all fields
|
LogicalSchema.LogicalFieldSchema |
getFieldSubNameMatch(java.lang.String alias)
Given an alias name, find the associated LogicalFieldSchema.
|
boolean |
isEqual(java.lang.Object other)
Two schemas are equal if they are of equal size and their fields
schemas considered in order are equal.
|
boolean |
isEqual(java.lang.Object other,
boolean compareAlias)
Two schemas are equal if they are of equal size and their fields
schemas considered in order are equal.
|
static LogicalSchema |
merge(LogicalSchema s1,
LogicalSchema s2,
LogicalSchema.MergeMode mode)
Merge two schemas.
|
static LogicalSchema |
mergeSchemaByAlias(LogicalSchema schema1,
LogicalSchema schema2)
Merges two schemas using their column aliases
(unlike mergeSchema(..) functions which merge using positions)
Schema will not be merged if types are incompatible,
as per DataType.mergeType(..)
For Tuples and Bags, SubSchemas have to be equal be considered compatible
|
static LogicalSchema |
mergeSchemasByAlias(java.util.List<LogicalSchema> schemas)
Merges collection of schemas using their column aliases
(unlike mergeSchema(..) functions which merge using positions)
Schema will not be merged if types are incompatible,
as per DataType.mergeType(..)
For Tuples and Bags, SubSchemas have to be equal be considered compatible
|
LogicalSchema |
mergeUid(LogicalSchema uidOnlySchema) |
void |
normalize()
Old Pig schema does not require a tuple schema inside a bag;
Now it is required to have that; this method is to fill the gap
|
void |
resetUid()
Reset uids of all fieldschema that the schema contains
|
int |
size()
Get the size of the schema.
|
java.lang.String |
toString() |
java.lang.String |
toString(boolean verbose) |
public void resetUid()
public static boolean castable(LogicalSchema inSch, LogicalSchema outSch)
inSch
- schema of the cast inputoutSch
- schema of the cast operatorpublic void addField(LogicalSchema.LogicalFieldSchema field)
field
- to be added to the schemapublic LogicalSchema.LogicalFieldSchema getField(java.lang.String alias) throws FrontendException
alias
- FrontendException
public LogicalSchema.LogicalFieldSchema getFieldSubNameMatch(java.lang.String alias) throws FrontendException
alias
- Alias to look up.FrontendException
public int getFieldPosition(java.lang.String alias)
public LogicalSchema.LogicalFieldSchema getField(int fieldNum)
fieldNum
- field number to fetchpublic java.util.List<LogicalSchema.LogicalFieldSchema> getFields()
public int size()
public boolean isEqual(java.lang.Object other)
public boolean isEqual(java.lang.Object other, boolean compareAlias)
other
- compareAlias
- public int findField(long uid)
uid
- the uid to look forpublic static LogicalSchema merge(LogicalSchema s1, LogicalSchema s2, LogicalSchema.MergeMode mode) throws FrontendException
s1
- In Load/ForEach, s1 is user declared schema; In Union, s1 is left side.s2
- In Load/ForEach, s2 is infered schema; In Union, s2 is right side.mode
- We merge schema in Load/Foreach/Union. In Load/Foreach, we always take s1 if compatible (s1 is set to be user defined schema),
In union, we take more specific type (between numeric and string, we take string). In the case type mismatch in s1/s2,
we expect TypeCheckingVisitor will fill the gap later.FrontendException
public java.lang.String toString(boolean verbose)
public java.lang.String toString()
toString
in class java.lang.Object
public LogicalSchema mergeUid(LogicalSchema uidOnlySchema) throws FrontendException
FrontendException
public LogicalSchema deepCopy()
public static LogicalSchema mergeSchemasByAlias(java.util.List<LogicalSchema> schemas) throws FrontendException
schemas
- - list of schemas to be merged using their column aliasFrontendException
public static LogicalSchema mergeSchemaByAlias(LogicalSchema schema1, LogicalSchema schema2) throws FrontendException
FrontendException
public static boolean equals(LogicalSchema schema, LogicalSchema other, boolean relaxInner, boolean relaxAlias)
schema
- other
- relaxInner
- if true, inner schemas will not be checkedrelaxAlias
- if true, aliases will not be checkedpublic void normalize()
Copyright © 2007-2012 The Apache Software Foundation