org.apache.pig.data
Class SchemaTuple<T extends SchemaTuple<T>>

java.lang.Object
  extended by org.apache.pig.data.AbstractTuple
      extended by org.apache.pig.data.SchemaTuple<T>
All Implemented Interfaces:
Serializable, Comparable, Iterable<Object>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable, Tuple, TypeAwareTuple
Direct Known Subclasses:
AppendableSchemaTuple

@InterfaceAudience.Public
@InterfaceStability.Unstable
public abstract class SchemaTuple<T extends SchemaTuple<T>>
extends AbstractTuple
implements TypeAwareTuple

A SchemaTuple is a type aware tuple that is much faster and more memory efficient. In our implementation, given a Schema, code generation is used to extend this class. This class provides a broad range of functionality that minimizes the complexity of the code that must be generated. The odd looking generic signature allows for certain optimizations, such as "setSpecific(T t)", which allows us to do much faster sets and comparisons when types match (since the code is generated, there is no other way to know).

See Also:
Serialized Form

Nested Class Summary
static class SchemaTuple.SchemaTupleQuickGenerator<A>
           
 
Field Summary
 
Fields inherited from interface org.apache.pig.data.Tuple
NOTNULL, NULL
 
Constructor Summary
SchemaTuple()
           
 
Method Summary
 void append(Object val)
          Append a field to a tuple.
protected  BigDecimal box(BigDecimal v)
           
protected  BigInteger box(BigInteger v)
           
protected  Boolean box(boolean v)
           
protected  DataByteArray box(byte[] v)
           
protected  DataBag box(DataBag v)
           
protected  org.joda.time.DateTime box(org.joda.time.DateTime v)
           
protected  Double box(double v)
           
protected  Float box(float v)
           
protected  Integer box(int v)
           
protected  Long box(long v)
           
protected  Map<String,Object> box(Map<String,Object> v)
           
protected  String box(String v)
           
protected  Tuple box(Tuple t)
           
protected  int compare(BigDecimal val, BigDecimal themVal)
           
protected  int compare(BigInteger val, BigInteger themVal)
           
protected  int compare(boolean usNull, BigDecimal usVal, boolean themNull, BigDecimal themVal)
           
protected  int compare(boolean usNull, BigInteger usVal, boolean themNull, BigInteger themVal)
           
protected  int compare(boolean val, boolean themVal)
           
protected  int compare(boolean usNull, boolean usVal, boolean themNull, boolean themVal)
           
protected  int compare(boolean usNull, byte[] usVal, boolean themNull, byte[] themVal)
           
protected  int compare(boolean usNull, DataBag usVal, boolean themNull, DataBag themVal)
           
protected  int compare(boolean usNull, org.joda.time.DateTime usVal, boolean themNull, org.joda.time.DateTime themVal)
           
protected  int compare(boolean usNull, double usVal, boolean themNull, double themVal)
           
protected  int compare(boolean usNull, float usVal, boolean themNull, float themVal)
           
protected  int compare(boolean usNull, int usVal, boolean themNull, int themVal)
           
protected  int compare(boolean usNull, long usVal, boolean themNull, long themVal)
           
protected  int compare(boolean usNull, Map<String,Object> usVal, boolean themNull, Map<String,Object> themVal)
           
protected  int compare(boolean usNull, SchemaTuple<?> usVal, boolean themNull, Object themVal)
           
protected  int compare(boolean usNull, String usVal, boolean themNull, String themVal)
           
protected  int compare(byte[] val, byte[] themVal)
           
protected  int compare(DataBag val, DataBag themVal)
           
protected  int compare(org.joda.time.DateTime val, org.joda.time.DateTime themVal)
           
protected  int compare(double val, double themVal)
           
 int compare(float val, float themVal)
           
protected  int compare(int val, int themVal)
           
protected  int compare(long val, long themVal)
           
protected  int compare(Map<String,Object> val, Map<String,Object> themVal)
           
protected  int compare(String val, String themVal)
           
protected  int compareElementAtPos(int val, SchemaTuple<?> t, int pos)
           
protected  int compareNull(boolean usNull, boolean themNull)
           
protected  int compareNull(boolean usNull, Tuple t, int pos)
           
protected  int compareSize(Tuple t)
           
 int compareTo(Object other)
           
 int compareTo(SchemaTuple<?> t)
           
protected  int compareTo(SchemaTuple<?> t, boolean checkType)
           
 int compareTo(Tuple t)
           
protected  int compareTo(Tuple t, boolean checkType)
           
protected  int compareToSpecific(T t)
           
protected  int compareWithElementAtPos(boolean isNull, BigDecimal val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, BigInteger val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, boolean val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, byte[] val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, DataBag val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, org.joda.time.DateTime val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, double val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, float val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, int val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, long val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, Map<String,Object> val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, SchemaTuple<?> val, SchemaTuple<?> t, int pos)
           
protected  int compareWithElementAtPos(boolean isNull, String val, SchemaTuple<?> t, int pos)
           
 boolean equals(Object other)
           
protected abstract  int generatedCodeCompareTo(SchemaTuple<?> t, boolean checkType)
           
protected abstract  int generatedCodeCompareToSpecific(T t)
           
protected abstract  BigDecimal generatedCodeGetBigDecimal(int fieldNum)
           
protected abstract  BigInteger generatedCodeGetBigInteger(int fieldNum)
           
protected abstract  boolean generatedCodeGetBoolean(int fieldNum)
           
protected abstract  byte[] generatedCodeGetBytes(int fieldNum)
           
protected abstract  DataBag generatedCodeGetDataBag(int fieldNum)
           
protected abstract  org.joda.time.DateTime generatedCodeGetDateTime(int fieldNum)
           
protected abstract  double generatedCodeGetDouble(int fieldNum)
           
abstract  Object generatedCodeGetField(int fieldNum)
           
protected abstract  float generatedCodeGetFloat(int fieldNum)
           
protected abstract  int generatedCodeGetInt(int fieldNum)
           
protected abstract  long generatedCodeGetLong(int fieldNum)
           
protected abstract  Map<String,Object> generatedCodeGetMap(int fieldNum)
           
protected abstract  String generatedCodeGetString(int fieldNum)
           
protected abstract  Tuple generatedCodeGetTuple(int fieldNum)
           
protected abstract  int generatedCodeHashCode()
           
protected abstract  boolean[] generatedCodeNullsArray()
           
protected abstract  void generatedCodeReadFields(DataInput in, boolean[] nulls)
           
protected abstract  SchemaTuple<T> generatedCodeSet(SchemaTuple<?> t, boolean checkType)
           
protected abstract  void generatedCodeSetBigDecimal(int fieldNum, BigDecimal val)
           
protected abstract  void generatedCodeSetBigInteger(int fieldNum, BigInteger val)
           
protected abstract  void generatedCodeSetBoolean(int fieldNum, boolean val)
           
protected abstract  void generatedCodeSetBytes(int fieldNum, byte[] val)
           
protected abstract  void generatedCodeSetDataBag(int fieldNum, DataBag val)
           
protected abstract  void generatedCodeSetDateTime(int fieldNum, org.joda.time.DateTime val)
           
protected abstract  void generatedCodeSetDouble(int fieldNum, double val)
           
abstract  void generatedCodeSetField(int fieldNum, Object val)
           
protected abstract  void generatedCodeSetFloat(int fieldNum, float val)
           
protected abstract  void generatedCodeSetInt(int fieldNum, int val)
           
protected abstract  void generatedCodeSetIterator(Iterator<Object> l)
           
protected abstract  void generatedCodeSetLong(int fieldNum, long val)
           
protected abstract  void generatedCodeSetMap(int fieldNum, Map<String,Object> val)
           
protected abstract  SchemaTuple<T> generatedCodeSetSpecific(T t)
           
protected abstract  void generatedCodeSetString(int fieldNum, String val)
           
protected abstract  void generatedCodeSetTuple(int fieldNum, Tuple val)
           
protected abstract  int generatedCodeSize()
           
protected abstract  void generatedCodeWriteElements(DataOutput out)
           
 Object get(int fieldNum)
          Get the value in a given field.
 List<Object> getAll()
          Get all of the fields in the tuple as a list.
 BigDecimal getBigDecimal(int fieldNum)
           
 BigInteger getBigInteger(int fieldNum)
           
 boolean getBoolean(int fieldNum)
           
 byte[] getBytes(int fieldNum)
           
 DataBag getDataBag(int fieldNum)
           
 org.joda.time.DateTime getDateTime(int fieldNum)
           
 double getDouble(int fieldNum)
           
 float getFloat(int fieldNum)
           
abstract  byte getGeneratedCodeFieldType(int fieldNum)
           
protected abstract  long getGeneratedCodeMemorySize()
           
 int getInt(int fieldNum)
           
 long getLong(int fieldNum)
           
 Map<String,Object> getMap(int fieldNum)
           
 long getMemorySize()
          This only accounts for the size of members (adjusting for word alignment).
abstract  SchemaTuple.SchemaTupleQuickGenerator<T> getQuickGenerator()
          This is a mechanism which allows the SchemaTupleFactory to get around having to use reflection.
 String getSchemaString()
           
abstract  int getSchemaTupleIdentifier()
          This method will return the identifier that the generated code was generated with.
 String getString(int fieldNum)
           
 Tuple getTuple(int fieldNum)
           
 byte getType(int fieldNum)
          Find the type of a given field.
protected  Object getTypeAwareBase(int fieldNum, String type)
           
 int hashCode()
           
protected  int hashCodePiece(int hash, BigDecimal v, boolean isNull)
           
protected  int hashCodePiece(int hash, BigInteger v, boolean isNull)
           
protected  int hashCodePiece(int hash, boolean v, boolean isNull)
           
protected  int hashCodePiece(int hash, byte[] v, boolean isNull)
           
protected  int hashCodePiece(int hash, DataBag v, boolean isNull)
           
protected  int hashCodePiece(int hash, org.joda.time.DateTime v, boolean isNull)
           
protected  int hashCodePiece(int hash, double v, boolean isNull)
           
protected  int hashCodePiece(int hash, float v, boolean isNull)
           
protected  int hashCodePiece(int hash, int v, boolean isNull)
           
protected  int hashCodePiece(int hash, long v, boolean isNull)
           
protected  int hashCodePiece(int hash, Map<String,Object> v, boolean isNull)
           
protected  int hashCodePiece(int hash, String v, boolean isNull)
           
protected  int hashCodePiece(int hash, Tuple v, boolean isNull)
           
abstract  boolean isGeneratedCodeFieldNull(int fieldNum)
           
 boolean isNull(int fieldNum)
          Find out if a given field is null.
abstract  boolean isSpecificSchemaTuple(Object o)
           
protected static BigDecimal read(DataInput in, BigDecimal v)
           
protected static BigInteger read(DataInput in, BigInteger v)
           
protected static byte[] read(DataInput in, byte[] v)
           
protected static DataBag read(DataInput in, DataBag v)
           
protected static org.joda.time.DateTime read(DataInput in, org.joda.time.DateTime v)
           
protected static double read(DataInput in, double v)
           
protected static float read(DataInput in, float v)
           
protected static int read(DataInput in, int v)
           
protected static long read(DataInput in, long v)
           
protected static Map<String,Object> read(DataInput in, Map<String,Object> v)
           
protected static String read(DataInput in, String v)
           
 void readFields(DataInput in)
           
 void reference(Tuple t)
          Make this tuple reference the contents of another.
protected  BigDecimal returnUnlessNull(boolean isNull, BigDecimal val)
           
protected  BigInteger returnUnlessNull(boolean isNull, BigInteger val)
           
protected  boolean returnUnlessNull(boolean isNull, boolean val)
           
protected  byte[] returnUnlessNull(boolean isNull, byte[] val)
           
protected  DataBag returnUnlessNull(boolean isNull, DataBag val)
           
protected  org.joda.time.DateTime returnUnlessNull(boolean isNull, org.joda.time.DateTime val)
           
protected  double returnUnlessNull(boolean isNull, double val)
           
protected  float returnUnlessNull(boolean isNull, float val)
           
protected  int returnUnlessNull(boolean isNull, int val)
           
protected  long returnUnlessNull(boolean isNull, long val)
           
protected  Map<String,Object> returnUnlessNull(boolean isNull, Map<String,Object> val)
           
protected  String returnUnlessNull(boolean isNull, String val)
           
protected  Tuple returnUnlessNull(boolean isNull, Tuple val)
           
protected abstract  int schemaSize()
           
 void set(int fieldNum, Object val)
          Set the value in a given field.
 SchemaTuple<T> set(List<Object> l)
           
 SchemaTuple<T> set(SchemaTuple<?> t)
           
protected  SchemaTuple<T> set(SchemaTuple<?> t, boolean checkType)
           
 SchemaTuple<T> set(Tuple t)
           
protected  SchemaTuple<T> set(Tuple t, boolean checkType)
           
 void setAndCatch(SchemaTuple<?> t)
           
 void setAndCatch(Tuple t)
           
 void setBigDecimal(int fieldNum, BigDecimal val)
           
 void setBigInteger(int fieldNum, BigInteger val)
           
 void setBoolean(int fieldNum, boolean val)
           
 void setBytes(int fieldNum, byte[] val)
           
 void setDataBag(int fieldNum, DataBag val)
           
 void setDateTime(int fieldNum, org.joda.time.DateTime val)
           
 void setDouble(int fieldNum, double val)
           
 void setFloat(int fieldNum, float val)
           
 void setInt(int fieldNum, int val)
           
 void setLong(int fieldNum, long val)
           
 void setMap(int fieldNum, Map<String,Object> val)
           
protected  SchemaTuple<T> setSpecific(T t)
           
 void setString(int fieldNum, String val)
           
 void setTuple(int fieldNum, Tuple val)
           
protected  void setTypeAwareBase(int fieldNum, Object val, String type)
           
 int size()
          Find the size of the tuple.
protected static Schema staticSchemaGen(String s)
           
protected  boolean unbox(Boolean v)
           
protected  DataBag unbox(DataBag v)
           
protected  byte[] unbox(DataByteArray v)
           
protected  org.joda.time.DateTime unbox(org.joda.time.DateTime v)
           
protected  double unbox(Double v)
           
protected  float unbox(Float v)
           
protected  int unbox(Integer v)
           
protected  long unbox(Long v)
           
protected  Map<String,Object> unbox(Map<String,Object> v)
           
protected  BigDecimal unbox(Object v, BigDecimal t)
           
protected  BigInteger unbox(Object v, BigInteger t)
           
protected  boolean unbox(Object v, boolean t)
           
protected  byte[] unbox(Object v, byte[] t)
           
protected  DataBag unbox(Object v, DataBag t)
           
protected  org.joda.time.DateTime unbox(Object v, org.joda.time.DateTime t)
           
protected  double unbox(Object v, double t)
           
protected  float unbox(Object v, float t)
           
protected  int unbox(Object v, int t)
           
protected  long unbox(Object v, long t)
           
protected  Map<String,Object> unbox(Object v, Map<String,Object> t)
           
protected  String unbox(Object v, String t)
           
protected  Tuple unbox(Object v, Tuple t)
           
 BigDecimal unboxBigDecimal(Object val)
           
 BigInteger unboxBigInteger(Object val)
           
 boolean unboxBoolean(Object val)
           
 byte[] unboxBytes(Object val)
           
protected  DataBag unboxDataBag(Object val)
           
 org.joda.time.DateTime unboxDateTime(Object val)
           
 double unboxDouble(Object val)
           
 float unboxFloat(Object val)
           
 int unboxInt(Object val)
           
 long unboxLong(Object val)
           
protected  Map<String,Object> unboxMap(Object val)
           
 String unboxString(Object val)
           
protected  Tuple unboxTuple(Object val)
           
 void write(DataOutput out)
           
protected static void write(DataOutput out, BigDecimal v)
           
protected static void write(DataOutput out, BigInteger v)
           
protected  void write(DataOutput out, boolean writeIdentifiers)
           
protected static void write(DataOutput out, byte[] v)
           
protected static void write(DataOutput out, DataBag v)
           
protected static void write(DataOutput out, org.joda.time.DateTime v)
           
protected static void write(DataOutput out, double v)
           
protected static void write(DataOutput out, float v)
           
protected static void write(DataOutput out, int v)
           
protected static void write(DataOutput out, long v)
           
protected static void write(DataOutput out, Map<String,Object> v)
           
protected static void write(DataOutput out, SchemaTuple<?> t)
           
protected static void write(DataOutput out, String v)
           
protected  void writeElements(DataOutput out)
          This method is responsible for writing everything contained by the Tuple.
 
Methods inherited from class org.apache.pig.data.AbstractTuple
iterator, toDelimitedString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.pig.data.TypeAwareTuple
getSchema
 
Methods inherited from interface org.apache.pig.data.Tuple
toDelimitedString
 
Methods inherited from interface java.lang.Iterable
iterator
 

Constructor Detail

SchemaTuple

public SchemaTuple()
Method Detail

append

public void append(Object val)
Description copied from interface: Tuple
Append a field to a tuple. This method is not efficient as it may force copying of existing data in order to grow the data structure. Whenever possible you should construct your Tuple with TupleFactory.newTuple(int) and then fill in the values with Tuple.set(int, Object), rather than construct it with TupleFactory.newTuple() and append values.

Specified by:
append in interface Tuple
Parameters:
val - Object to append to the tuple.

getMemorySize

public long getMemorySize()
This only accounts for the size of members (adjusting for word alignment). It also includes the size of the object itself, since this never affects word boundaries.

Specified by:
getMemorySize in interface Tuple
Returns:
estimated memory size, in bytes.

getGeneratedCodeMemorySize

protected abstract long getGeneratedCodeMemorySize()

getSchemaTupleIdentifier

public abstract int getSchemaTupleIdentifier()
This method will return the identifier that the generated code was generated with. This is useful because when the classes are resolved generically, this let's us know the identifier, which is used when serlializing and deserializing tuples.

Returns:
the identifire as Int.

schemaSize

protected abstract int schemaSize()

getSchemaString

public String getSchemaString()

set

protected SchemaTuple<T> set(SchemaTuple<?> t,
                             boolean checkType)
                                             throws ExecException
Throws:
ExecException

generatedCodeSet

protected abstract SchemaTuple<T> generatedCodeSet(SchemaTuple<?> t,
                                                   boolean checkType)
                                                                   throws ExecException
Throws:
ExecException

setSpecific

protected SchemaTuple<T> setSpecific(T t)

generatedCodeSetSpecific

protected abstract SchemaTuple<T> generatedCodeSetSpecific(T t)

set

public SchemaTuple<T> set(Tuple t)
                                          throws ExecException
Throws:
ExecException

set

protected SchemaTuple<T> set(Tuple t,
                             boolean checkType)
                                             throws ExecException
Throws:
ExecException

set

public SchemaTuple<T> set(SchemaTuple<?> t)
                                          throws ExecException
Throws:
ExecException

set

public SchemaTuple<T> set(List<Object> l)
                                          throws ExecException
Throws:
ExecException

generatedCodeSetIterator

protected abstract void generatedCodeSetIterator(Iterator<Object> l)
                                          throws ExecException
Throws:
ExecException

write

protected void write(DataOutput out,
                     boolean writeIdentifiers)
              throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            DataBag v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            Map<String,Object> v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            int v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            long v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            float v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            double v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            org.joda.time.DateTime v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            BigDecimal v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            BigInteger v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            byte[] v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            String v)
                     throws IOException
Throws:
IOException

write

protected static void write(DataOutput out,
                            SchemaTuple<?> t)
                     throws IOException
Throws:
IOException

read

protected static DataBag read(DataInput in,
                              DataBag v)
                       throws IOException
Throws:
IOException

read

protected static Map<String,Object> read(DataInput in,
                                         Map<String,Object> v)
                                  throws IOException
Throws:
IOException

read

protected static int read(DataInput in,
                          int v)
                   throws IOException
Throws:
IOException

read

protected static long read(DataInput in,
                           long v)
                    throws IOException
Throws:
IOException

read

protected static float read(DataInput in,
                            float v)
                     throws IOException
Throws:
IOException

read

protected static double read(DataInput in,
                             double v)
                      throws IOException
Throws:
IOException

read

protected static org.joda.time.DateTime read(DataInput in,
                                             org.joda.time.DateTime v)
                                      throws IOException
Throws:
IOException

read

protected static BigDecimal read(DataInput in,
                                 BigDecimal v)
                          throws IOException
Throws:
IOException

read

protected static BigInteger read(DataInput in,
                                 BigInteger v)
                          throws IOException
Throws:
IOException

read

protected static String read(DataInput in,
                             String v)
                      throws IOException
Throws:
IOException

read

protected static byte[] read(DataInput in,
                             byte[] v)
                      throws IOException
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

reference

public void reference(Tuple t)
Description copied from interface: Tuple
Make this tuple reference the contents of another. This method does not copy the underlying data. It maintains references to the data from the original tuple (and possibly even to the data structure holding the data).

Specified by:
reference in interface Tuple
Overrides:
reference in class AbstractTuple
Parameters:
t - Tuple to reference.

getAll

public List<Object> getAll()
Description copied from interface: Tuple
Get all of the fields in the tuple as a list.

Specified by:
getAll in interface Tuple
Returns:
a list of objects containing the fields of the tuple in order.

isSpecificSchemaTuple

public abstract boolean isSpecificSchemaTuple(Object o)

compareTo

public int compareTo(Object other)
Specified by:
compareTo in interface Comparable

compareTo

public int compareTo(Tuple t)

compareTo

protected int compareTo(Tuple t,
                        boolean checkType)

compareTo

public int compareTo(SchemaTuple<?> t)

compareTo

protected int compareTo(SchemaTuple<?> t,
                        boolean checkType)

generatedCodeCompareTo

protected abstract int generatedCodeCompareTo(SchemaTuple<?> t,
                                              boolean checkType)

compareToSpecific

protected int compareToSpecific(T t)

generatedCodeCompareToSpecific

protected abstract int generatedCodeCompareToSpecific(T t)

equals

public boolean equals(Object other)
Overrides:
equals in class AbstractTuple

unbox

protected DataBag unbox(Object v,
                        DataBag t)

unbox

protected Map<String,Object> unbox(Object v,
                                   Map<String,Object> t)

unbox

protected byte[] unbox(Object v,
                       byte[] t)

unbox

protected int unbox(Object v,
                    int t)

unbox

protected long unbox(Object v,
                     long t)

unbox

protected float unbox(Object v,
                      float t)

unbox

protected double unbox(Object v,
                       double t)

unbox

protected boolean unbox(Object v,
                        boolean t)

unbox

protected org.joda.time.DateTime unbox(Object v,
                                       org.joda.time.DateTime t)

unbox

protected BigDecimal unbox(Object v,
                           BigDecimal t)

unbox

protected BigInteger unbox(Object v,
                           BigInteger t)

unbox

protected String unbox(Object v,
                       String t)

unbox

protected Tuple unbox(Object v,
                      Tuple t)

unbox

protected DataBag unbox(DataBag v)

unbox

protected Map<String,Object> unbox(Map<String,Object> v)

unbox

protected byte[] unbox(DataByteArray v)

unbox

protected int unbox(Integer v)

unbox

protected long unbox(Long v)

unbox

protected float unbox(Float v)

unbox

protected double unbox(Double v)

unbox

protected boolean unbox(Boolean v)

unbox

protected org.joda.time.DateTime unbox(org.joda.time.DateTime v)

box

protected DataBag box(DataBag v)

box

protected Map<String,Object> box(Map<String,Object> v)

box

protected DataByteArray box(byte[] v)

box

protected String box(String v)

box

protected Tuple box(Tuple t)

box

protected Integer box(int v)

box

protected Long box(long v)

box

protected Float box(float v)

box

protected Double box(double v)

box

protected Boolean box(boolean v)

box

protected org.joda.time.DateTime box(org.joda.time.DateTime v)

box

protected BigDecimal box(BigDecimal v)

box

protected BigInteger box(BigInteger v)

hashCodePiece

protected int hashCodePiece(int hash,
                            int v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            long v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            float v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            double v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            boolean v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            org.joda.time.DateTime v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            BigDecimal v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            BigInteger v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            byte[] v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            String v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            Tuple v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            DataBag v,
                            boolean isNull)

hashCodePiece

protected int hashCodePiece(int hash,
                            Map<String,Object> v,
                            boolean isNull)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

generatedCodeHashCode

protected abstract int generatedCodeHashCode()

set

public void set(int fieldNum,
                Object val)
         throws ExecException
Description copied from interface: Tuple
Set the value in a given field. This should not be called unless the tuple was constructed by TupleFactory.newTuple(int) with an argument greater than the fieldNum being passed here. This call will not automatically expand the tuple size. That is if you called TupleFactory.newTuple(int) with a 2, it is okay to call this function with a 1, but not with a 2 or greater.

Specified by:
set in interface Tuple
Parameters:
fieldNum - Number of the field to set the value for.
val - Object to put in the indicated field.
Throws:
ExecException - if the field number is greater than or equal to the number of fields in the tuple.

generatedCodeSetField

public abstract void generatedCodeSetField(int fieldNum,
                                           Object val)
                                    throws ExecException
Throws:
ExecException

get

public Object get(int fieldNum)
           throws ExecException
Description copied from interface: Tuple
Get the value in a given field.

Specified by:
get in interface Tuple
Parameters:
fieldNum - Number of the field to get the value for.
Returns:
value, as an Object.
Throws:
ExecException - if the field number is greater than or equal to the number of fields in the tuple.

generatedCodeGetField

public abstract Object generatedCodeGetField(int fieldNum)
                                      throws ExecException
Throws:
ExecException

isNull

public boolean isNull(int fieldNum)
               throws ExecException
Description copied from class: AbstractTuple
Find out if a given field is null.

Specified by:
isNull in interface Tuple
Overrides:
isNull in class AbstractTuple
Parameters:
fieldNum - Number of field to check for null.
Returns:
true if the field is null, false otherwise.
Throws:
ExecException - if the field number given is greater than or equal to the number of fields in the tuple.

isGeneratedCodeFieldNull

public abstract boolean isGeneratedCodeFieldNull(int fieldNum)
                                          throws ExecException
Throws:
ExecException

getType

public byte getType(int fieldNum)
             throws ExecException
Description copied from class: AbstractTuple
Find the type of a given field.

Specified by:
getType in interface Tuple
Overrides:
getType in class AbstractTuple
Parameters:
fieldNum - Number of field to get the type for.
Returns:
type, encoded as a byte value. The values are defined in DataType. If the field is null, then DataType.UNKNOWN will be returned.
Throws:
ExecException - if the field number is greater than or equal to the number of fields in the tuple.

getGeneratedCodeFieldType

public abstract byte getGeneratedCodeFieldType(int fieldNum)
                                        throws ExecException
Throws:
ExecException

setTypeAwareBase

protected void setTypeAwareBase(int fieldNum,
                                Object val,
                                String type)
                         throws ExecException
Throws:
ExecException

getTypeAwareBase

protected Object getTypeAwareBase(int fieldNum,
                                  String type)
                           throws ExecException
Throws:
ExecException

setInt

public void setInt(int fieldNum,
                   int val)
            throws ExecException
Specified by:
setInt in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetInt

protected abstract void generatedCodeSetInt(int fieldNum,
                                            int val)
                                     throws ExecException
Throws:
ExecException

setLong

public void setLong(int fieldNum,
                    long val)
             throws ExecException
Specified by:
setLong in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetLong

protected abstract void generatedCodeSetLong(int fieldNum,
                                             long val)
                                      throws ExecException
Throws:
ExecException

setFloat

public void setFloat(int fieldNum,
                     float val)
              throws ExecException
Specified by:
setFloat in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetFloat

protected abstract void generatedCodeSetFloat(int fieldNum,
                                              float val)
                                       throws ExecException
Throws:
ExecException

setDouble

public void setDouble(int fieldNum,
                      double val)
               throws ExecException
Specified by:
setDouble in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetDouble

protected abstract void generatedCodeSetDouble(int fieldNum,
                                               double val)
                                        throws ExecException
Throws:
ExecException

setBoolean

public void setBoolean(int fieldNum,
                       boolean val)
                throws ExecException
Specified by:
setBoolean in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetBoolean

protected abstract void generatedCodeSetBoolean(int fieldNum,
                                                boolean val)
                                         throws ExecException
Throws:
ExecException

setDateTime

public void setDateTime(int fieldNum,
                        org.joda.time.DateTime val)
                 throws ExecException
Specified by:
setDateTime in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetDateTime

protected abstract void generatedCodeSetDateTime(int fieldNum,
                                                 org.joda.time.DateTime val)
                                          throws ExecException
Throws:
ExecException

setBigDecimal

public void setBigDecimal(int fieldNum,
                          BigDecimal val)
                   throws ExecException
Specified by:
setBigDecimal in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetBigDecimal

protected abstract void generatedCodeSetBigDecimal(int fieldNum,
                                                   BigDecimal val)
                                            throws ExecException
Throws:
ExecException

setBigInteger

public void setBigInteger(int fieldNum,
                          BigInteger val)
                   throws ExecException
Specified by:
setBigInteger in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetBigInteger

protected abstract void generatedCodeSetBigInteger(int fieldNum,
                                                   BigInteger val)
                                            throws ExecException
Throws:
ExecException

setString

public void setString(int fieldNum,
                      String val)
               throws ExecException
Specified by:
setString in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetString

protected abstract void generatedCodeSetString(int fieldNum,
                                               String val)
                                        throws ExecException
Throws:
ExecException

setTuple

public void setTuple(int fieldNum,
                     Tuple val)
              throws ExecException
Specified by:
setTuple in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetTuple

protected abstract void generatedCodeSetTuple(int fieldNum,
                                              Tuple val)
                                       throws ExecException
Throws:
ExecException

setBytes

public void setBytes(int fieldNum,
                     byte[] val)
              throws ExecException
Specified by:
setBytes in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetBytes

protected abstract void generatedCodeSetBytes(int fieldNum,
                                              byte[] val)
                                       throws ExecException
Throws:
ExecException

setDataBag

public void setDataBag(int fieldNum,
                       DataBag val)
                throws ExecException
Specified by:
setDataBag in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetDataBag

protected abstract void generatedCodeSetDataBag(int fieldNum,
                                                DataBag val)
                                         throws ExecException
Throws:
ExecException

setMap

public void setMap(int fieldNum,
                   Map<String,Object> val)
            throws ExecException
Specified by:
setMap in interface TypeAwareTuple
Throws:
ExecException

generatedCodeSetMap

protected abstract void generatedCodeSetMap(int fieldNum,
                                            Map<String,Object> val)
                                     throws ExecException
Throws:
ExecException

returnUnlessNull

protected int returnUnlessNull(boolean isNull,
                               int val)
                        throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected long returnUnlessNull(boolean isNull,
                                long val)
                         throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected float returnUnlessNull(boolean isNull,
                                 float val)
                          throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected double returnUnlessNull(boolean isNull,
                                  double val)
                           throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected boolean returnUnlessNull(boolean isNull,
                                   boolean val)
                            throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected org.joda.time.DateTime returnUnlessNull(boolean isNull,
                                                  org.joda.time.DateTime val)
                                           throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected BigDecimal returnUnlessNull(boolean isNull,
                                      BigDecimal val)
                               throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected BigInteger returnUnlessNull(boolean isNull,
                                      BigInteger val)
                               throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected Tuple returnUnlessNull(boolean isNull,
                                 Tuple val)
                          throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected String returnUnlessNull(boolean isNull,
                                  String val)
                           throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected byte[] returnUnlessNull(boolean isNull,
                                  byte[] val)
                           throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected DataBag returnUnlessNull(boolean isNull,
                                   DataBag val)
                            throws FieldIsNullException
Throws:
FieldIsNullException

returnUnlessNull

protected Map<String,Object> returnUnlessNull(boolean isNull,
                                              Map<String,Object> val)
                                       throws FieldIsNullException
Throws:
FieldIsNullException

getInt

public int getInt(int fieldNum)
           throws ExecException
Specified by:
getInt in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetInt

protected abstract int generatedCodeGetInt(int fieldNum)
                                    throws ExecException
Throws:
ExecException

unboxInt

public int unboxInt(Object val)

getLong

public long getLong(int fieldNum)
             throws ExecException
Specified by:
getLong in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetLong

protected abstract long generatedCodeGetLong(int fieldNum)
                                      throws ExecException
Throws:
ExecException

unboxLong

public long unboxLong(Object val)

getFloat

public float getFloat(int fieldNum)
               throws ExecException
Specified by:
getFloat in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetFloat

protected abstract float generatedCodeGetFloat(int fieldNum)
                                        throws ExecException
Throws:
ExecException

unboxFloat

public float unboxFloat(Object val)

getDouble

public double getDouble(int fieldNum)
                 throws ExecException
Specified by:
getDouble in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetDouble

protected abstract double generatedCodeGetDouble(int fieldNum)
                                          throws ExecException
Throws:
ExecException

unboxDouble

public double unboxDouble(Object val)

getBoolean

public boolean getBoolean(int fieldNum)
                   throws ExecException
Specified by:
getBoolean in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetBoolean

protected abstract boolean generatedCodeGetBoolean(int fieldNum)
                                            throws ExecException
Throws:
ExecException

unboxBoolean

public boolean unboxBoolean(Object val)

getDateTime

public org.joda.time.DateTime getDateTime(int fieldNum)
                                   throws ExecException
Specified by:
getDateTime in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetDateTime

protected abstract org.joda.time.DateTime generatedCodeGetDateTime(int fieldNum)
                                                            throws ExecException
Throws:
ExecException

unboxDateTime

public org.joda.time.DateTime unboxDateTime(Object val)

getString

public String getString(int fieldNum)
                 throws ExecException
Specified by:
getString in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetString

protected abstract String generatedCodeGetString(int fieldNum)
                                          throws ExecException
Throws:
ExecException

unboxString

public String unboxString(Object val)

getBytes

public byte[] getBytes(int fieldNum)
                throws ExecException
Specified by:
getBytes in interface TypeAwareTuple
Throws:
ExecException

unboxBytes

public byte[] unboxBytes(Object val)

generatedCodeGetBytes

protected abstract byte[] generatedCodeGetBytes(int fieldNum)
                                         throws ExecException
Throws:
ExecException

getTuple

public Tuple getTuple(int fieldNum)
               throws ExecException
Specified by:
getTuple in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetTuple

protected abstract Tuple generatedCodeGetTuple(int fieldNum)
                                        throws ExecException
Throws:
ExecException

unboxTuple

protected Tuple unboxTuple(Object val)

getDataBag

public DataBag getDataBag(int fieldNum)
                   throws ExecException
Specified by:
getDataBag in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetDataBag

protected abstract DataBag generatedCodeGetDataBag(int fieldNum)
                                            throws ExecException
Throws:
ExecException

unboxDataBag

protected DataBag unboxDataBag(Object val)

getMap

public Map<String,Object> getMap(int fieldNum)
                          throws ExecException
Specified by:
getMap in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetMap

protected abstract Map<String,Object> generatedCodeGetMap(int fieldNum)
                                                   throws ExecException
Throws:
ExecException

unboxMap

protected Map<String,Object> unboxMap(Object val)

getBigDecimal

public BigDecimal getBigDecimal(int fieldNum)
                         throws ExecException
Specified by:
getBigDecimal in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetBigDecimal

protected abstract BigDecimal generatedCodeGetBigDecimal(int fieldNum)
                                                  throws ExecException
Throws:
ExecException

unboxBigDecimal

public BigDecimal unboxBigDecimal(Object val)

getBigInteger

public BigInteger getBigInteger(int fieldNum)
                         throws ExecException
Specified by:
getBigInteger in interface TypeAwareTuple
Throws:
ExecException

generatedCodeGetBigInteger

protected abstract BigInteger generatedCodeGetBigInteger(int fieldNum)
                                                  throws ExecException
Throws:
ExecException

unboxBigInteger

public BigInteger unboxBigInteger(Object val)

staticSchemaGen

protected static Schema staticSchemaGen(String s)

setAndCatch

public void setAndCatch(Tuple t)

setAndCatch

public void setAndCatch(SchemaTuple<?> t)

writeElements

protected void writeElements(DataOutput out)
                      throws IOException
This method is responsible for writing everything contained by the Tuple. Note that the base SchemaTuple class does not have an implementation (but is not abstract) so that the generated code can call this method via super without worrying about whether it is abstract or not, as there may be classes in between in the inheritance tree (such as AppendableSchemaTuple).

Parameters:
out -
Throws:
IOException

generatedCodeWriteElements

protected abstract void generatedCodeWriteElements(DataOutput out)
                                            throws IOException
Throws:
IOException

compareSize

protected int compareSize(Tuple t)

compareNull

protected int compareNull(boolean usNull,
                          boolean themNull)

compareNull

protected int compareNull(boolean usNull,
                          Tuple t,
                          int pos)

compareElementAtPos

protected int compareElementAtPos(int val,
                                  SchemaTuple<?> t,
                                  int pos)

compare

protected int compare(boolean usNull,
                      int usVal,
                      boolean themNull,
                      int themVal)

compare

protected int compare(int val,
                      int themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      int val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      long usVal,
                      boolean themNull,
                      long themVal)

compare

protected int compare(long val,
                      long themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      long val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      float usVal,
                      boolean themNull,
                      float themVal)

compare

public int compare(float val,
                   float themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      float val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      double usVal,
                      boolean themNull,
                      double themVal)

compare

protected int compare(double val,
                      double themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      double val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      boolean usVal,
                      boolean themNull,
                      boolean themVal)

compare

protected int compare(boolean val,
                      boolean themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      boolean val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      byte[] usVal,
                      boolean themNull,
                      byte[] themVal)

compare

protected int compare(byte[] val,
                      byte[] themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      byte[] val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      org.joda.time.DateTime usVal,
                      boolean themNull,
                      org.joda.time.DateTime themVal)

compare

protected int compare(org.joda.time.DateTime val,
                      org.joda.time.DateTime themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      org.joda.time.DateTime val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      BigDecimal usVal,
                      boolean themNull,
                      BigDecimal themVal)

compare

protected int compare(BigDecimal val,
                      BigDecimal themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      BigDecimal val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      BigInteger usVal,
                      boolean themNull,
                      BigInteger themVal)

compare

protected int compare(BigInteger val,
                      BigInteger themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      BigInteger val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      String usVal,
                      boolean themNull,
                      String themVal)

compare

protected int compare(String val,
                      String themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      String val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      DataBag usVal,
                      boolean themNull,
                      DataBag themVal)

compare

protected int compare(DataBag val,
                      DataBag themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      DataBag val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      Map<String,Object> usVal,
                      boolean themNull,
                      Map<String,Object> themVal)

compare

protected int compare(Map<String,Object> val,
                      Map<String,Object> themVal)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      Map<String,Object> val,
                                      SchemaTuple<?> t,
                                      int pos)

compareWithElementAtPos

protected int compareWithElementAtPos(boolean isNull,
                                      SchemaTuple<?> val,
                                      SchemaTuple<?> t,
                                      int pos)

compare

protected int compare(boolean usNull,
                      SchemaTuple<?> usVal,
                      boolean themNull,
                      Object themVal)

getQuickGenerator

public abstract SchemaTuple.SchemaTupleQuickGenerator<T> getQuickGenerator()
This is a mechanism which allows the SchemaTupleFactory to get around having to use reflection. The generated code will return a generator which will be created via reflection, but after which can generate SchemaTuples at native speed.


size

public int size()
Description copied from interface: Tuple
Find the size of the tuple. Used to be called arity().

Specified by:
size in interface Tuple
Returns:
number of fields in the tuple.

generatedCodeSize

protected abstract int generatedCodeSize()

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

generatedCodeReadFields

protected abstract void generatedCodeReadFields(DataInput in,
                                                boolean[] nulls)
                                         throws IOException
Throws:
IOException

generatedCodeNullsArray

protected abstract boolean[] generatedCodeNullsArray()
                                              throws IOException
Throws:
IOException


Copyright © 2007-2012 The Apache Software Foundation