org.apache.pig
Class ResourceSchema

java.lang.Object
  extended by org.apache.pig.ResourceSchema
All Implemented Interfaces:
Serializable

@InterfaceAudience.Public
@InterfaceStability.Stable
public class ResourceSchema
extends Object
implements Serializable

A represenation of a schema used to communicate with load and store functions. This is separate from Schema, which is an internal Pig representation of a schema.

Since:
Pig 0.7
See Also:
Serialized Form

Nested Class Summary
static class ResourceSchema.Order
           
static class ResourceSchema.ResourceFieldSchema
           
 
Constructor Summary
ResourceSchema()
          Construct an empty ResourceSchema.
ResourceSchema(Schema pigSchema)
          Construct a ResourceSchema from a Schema
ResourceSchema(Schema pigSchema, SortInfo sortInfo)
          Only for use by Pig internal code.
 
Method Summary
static boolean equals(ResourceSchema rs1, ResourceSchema rs2)
          Test whether two ResourceSchemas are the same.
 String[] fieldNames()
          Get all field names.
 ResourceSchema.ResourceFieldSchema[] getFields()
          Get field schema for each field
 ResourceSchema.Order[] getSortKeyOrders()
          Get order for sort keys.
 int[] getSortKeys()
          Get the sort keys for this data.
 int getVersion()
          Get the version of this schema.
 ResourceSchema setFields(ResourceSchema.ResourceFieldSchema[] fields)
          Set all the fields.
 ResourceSchema setSortKeyOrders(ResourceSchema.Order[] sortKeyOrders)
          Set the order for each sort key.
 ResourceSchema setSortKeys(int[] sortKeys)
          Set the sort keys for htis data.
 ResourceSchema setVersion(int version)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceSchema

public ResourceSchema()
Construct an empty ResourceSchema.


ResourceSchema

public ResourceSchema(Schema pigSchema)
Construct a ResourceSchema from a Schema

Parameters:
pigSchema - Schema to use

ResourceSchema

@InterfaceAudience.Private
public ResourceSchema(Schema pigSchema,
                                                SortInfo sortInfo)
Only for use by Pig internal code. Construct a ResourceSchema from a Schema

Parameters:
pigSchema - Schema to use
sortInfo - information on how data is sorted
Method Detail

getVersion

public int getVersion()
Get the version of this schema.

Returns:
version

setVersion

public ResourceSchema setVersion(int version)

getFields

public ResourceSchema.ResourceFieldSchema[] getFields()
Get field schema for each field

Returns:
array of field schemas.

fieldNames

public String[] fieldNames()
Get all field names.

Returns:
array of field names

setFields

public ResourceSchema setFields(ResourceSchema.ResourceFieldSchema[] fields)
Set all the fields. If fields are not currently null the new fields will be silently ignored.

Parameters:
fields - to use as fields in this schema
Returns:
this

getSortKeys

public int[] getSortKeys()
Get the sort keys for this data.

Returns:
array of ints. Each integer in the array represents the field number. So if the schema of the data is (a, b, c, d) and the data is sorted on c, b, the returned sort keys will be [2, 1]. Field numbers are zero based. If the data is not sorted a zero length array will be returned.

setSortKeys

public ResourceSchema setSortKeys(int[] sortKeys)
Set the sort keys for htis data. If sort keys are not currently null the new sort keys will be silently ignored.

Parameters:
sortKeys - Each integer in the array represents the field number. So if the schema of the data is (a, b, c, d) and the data is sorted on c, b, the sort keys should be [2, 1]. Field numbers are zero based.
Returns:
this

getSortKeyOrders

public ResourceSchema.Order[] getSortKeyOrders()
Get order for sort keys.

Returns:
array of Order. This array will be the same length as the int[] array returned by getSortKeys().

setSortKeyOrders

public ResourceSchema setSortKeyOrders(ResourceSchema.Order[] sortKeyOrders)
Set the order for each sort key. If order is not currently null, new order will be silently ignored.

Parameters:
sortKeyOrders - array of Order. Should be the same length as int[] passed to setSortKeys(int[]).
Returns:
this

equals

public static boolean equals(ResourceSchema rs1,
                             ResourceSchema rs2)
Test whether two ResourceSchemas are the same. Two schemas are said to be the same if they are both null or have the same number of fields and for each field the name, type are the same. For fields that have may have schemas (i.e. tuples) both schemas be equal. Field descriptions are not used in testing equality.

Returns:
true if equal according to the above definition, otherwise false.

toString

public String toString()
Overrides:
toString in class Object


Copyright © ${year} The Apache Software Foundation