org.apache.pig.data
Class Tuple

java.lang.Object
  extended by org.apache.pig.data.Datum
      extended by org.apache.pig.data.Tuple
All Implemented Interfaces:
Comparable, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable
Direct Known Subclasses:
AmendableTuple, DataBag.BagDelimiterTuple, ExampleTuple, IndexedTuple, TimestampedTuple

public class Tuple
extends Datum
implements org.apache.hadoop.io.WritableComparable

an ordered list of Datums


Field Summary
protected  ArrayList<Datum> fields
           
 
Fields inherited from class org.apache.pig.data.Datum
ATOM, BAG, MAP, OBJECT_SIZE, RECORD_1, RECORD_2, RECORD_3, REF_SIZE, TUPLE
 
Constructor Summary
Tuple()
           
Tuple(Datum fieldIn)
          shortcut, if tuple only has one field
Tuple(int numFields)
           
Tuple(List<Datum> fieldsIn)
           
Tuple(String textLine)
          Creates a tuple from a delimited line of text.
Tuple(String textLine, String delimiter)
          Creates a tuple from a delimited line of text
Tuple(Tuple[] otherTs)
           
 
Method Summary
 void appendField(Datum newField)
           
 void appendTuple(Tuple other)
           
 int arity()
           
 int compareTo(Object other)
           
 int compareTo(Tuple other)
           
 void copyFrom(Tuple otherT)
           
 boolean equals(Object other)
           
 DataAtom getAtomField(int i)
           
 DataBag getBagField(int i)
           
 Datum getField(int i)
           
 long getMemorySize()
           
 Tuple getTupleField(int i)
           
 boolean greaterThan(Tuple other)
           
 int hashCode()
           
 boolean lessThan(Tuple other)
           
static Tuple read(DataInput in)
           
static Datum readDatum(DataInput in)
           
 void readFields(DataInput in)
           
 void setField(int i, Datum val)
           
 void setField(int i, double val)
           
 void setField(int i, int val)
           
 void setField(int i, String val)
           
 String toDelimitedString(String delim)
           
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

fields

protected ArrayList<Datum> fields
Constructor Detail

Tuple

public Tuple()

Tuple

public Tuple(int numFields)

Tuple

public Tuple(List<Datum> fieldsIn)

Tuple

public Tuple(Datum fieldIn)
shortcut, if tuple only has one field


Tuple

public Tuple(String textLine,
             String delimiter)
Creates a tuple from a delimited line of text

Parameters:
textLine - the line containing fields of data
delimiter - the delimiter (normal string, NO REGEX!!)

Tuple

public Tuple(String textLine)
Creates a tuple from a delimited line of text. This will invoke Tuple(textLine, null)

Parameters:
textLine - the line containing fields of data

Tuple

public Tuple(Tuple[] otherTs)
Method Detail

copyFrom

public void copyFrom(Tuple otherT)

arity

public int arity()

toString

public String toString()
Overrides:
toString in class Object

setField

public void setField(int i,
                     Datum val)

setField

public void setField(int i,
                     int val)

setField

public void setField(int i,
                     double val)

setField

public void setField(int i,
                     String val)

getField

public Datum getField(int i)

getAtomField

public DataAtom getAtomField(int i)

getTupleField

public Tuple getTupleField(int i)

getBagField

public DataBag getBagField(int i)

appendTuple

public void appendTuple(Tuple other)

appendField

public void appendField(Datum newField)

toDelimitedString

public String toDelimitedString(String delim)
                         throws IOException
Throws:
IOException

lessThan

public boolean lessThan(Tuple other)

greaterThan

public boolean greaterThan(Tuple other)

equals

public boolean equals(Object other)
Specified by:
equals in class Datum

compareTo

public int compareTo(Tuple other)

compareTo

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

write

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

readFields

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

read

public static Tuple read(DataInput in)
                  throws IOException
Throws:
IOException

readDatum

public static Datum readDatum(DataInput in)
                       throws IOException
Throws:
IOException

getMemorySize

public long getMemorySize()
Specified by:
getMemorySize in class Datum


Copyright © ${year} The Apache Software Foundation