org.apache.hadoop.zebra.types
Class TypesUtils

java.lang.Object
  extended by org.apache.hadoop.zebra.types.TypesUtils

public class TypesUtils
extends Object

Utility methods manipulating Table types (specifically, Tuple objects).


Nested Class Summary
static class TypesUtils.TupleReader
          Reading a tuple from disk with projection.
static class TypesUtils.TupleWriter
          Writing a tuple to disk.
 
Constructor Summary
TypesUtils()
           
 
Method Summary
static void checkCompatible(Tuple tuple, Schema schema)
          Check whether the input row object is compatible with the expected schema
static void checkNumberColumnCompatible(Tuple tuple, Schema schema)
          Check whether the input row object is compatible with the expected schema on number of Columns;
static DataBag createBag()
          Create a PIG Bag object.
static DataBag createBag(Schema schema)
           
static Tuple createTuple(int size)
          create a tuple based on number of columns
static Tuple createTuple(Schema schema)
          Create a tuple based on a schema
static void formatTuple(Tuple tuple, int ncols)
          Checking and formatting an input tuple to conform to the input schema.
The current implementation always create a new tuple because PIG expects Slice.next(tuple) always returning a brand new tuple.
static void resetTuple(Tuple tuple)
          Reset the Tuple so that all fields are NULL field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypesUtils

public TypesUtils()
Method Detail

createTuple

public static Tuple createTuple(Schema schema)
                         throws IOException
Create a tuple based on a schema

Parameters:
schema - The schema that the tuple will conform to.
Returns:
A suitable Tuple object that can be used to read or write a Table with the same input or output schema.
Throws:
IOException

createTuple

public static Tuple createTuple(int size)
                         throws IOException
create a tuple based on number of columns

Throws:
IOException

createBag

public static DataBag createBag()
Create a PIG Bag object.

Returns:
A Pig DataBag object.

createBag

public static DataBag createBag(Schema schema)

resetTuple

public static void resetTuple(Tuple tuple)
Reset the Tuple so that all fields are NULL field. This is different from clearing the tuple, in which case the size of the tuple will become zero.

Parameters:
tuple - Input tuple.

checkCompatible

public static void checkCompatible(Tuple tuple,
                                   Schema schema)
                            throws IOException
Check whether the input row object is compatible with the expected schema

Parameters:
tuple - Input Tuple object
schema - Table schema
Throws:
IOException

checkNumberColumnCompatible

public static void checkNumberColumnCompatible(Tuple tuple,
                                               Schema schema)
                                        throws IOException
Check whether the input row object is compatible with the expected schema on number of Columns;

Parameters:
tuple - Input Tuple object
schema - Table schema
Throws:
IOException

formatTuple

public static void formatTuple(Tuple tuple,
                               int ncols)
                        throws IOException
Checking and formatting an input tuple to conform to the input schema.
The current implementation always create a new tuple because PIG expects Slice.next(tuple) always returning a brand new tuple.

Parameters:
tuple -
Throws:
IOException


Copyright © ${year} The Apache Software Foundation