com.ebay.erl.mobius.core.model
Class Tuple

java.lang.Object
  extended by com.ebay.erl.mobius.core.model.Tuple
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<Tuple>, java.util.Comparator<Tuple>, org.apache.hadoop.conf.Configurable, org.apache.hadoop.io.RawComparator<Tuple>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<Tuple>
Direct Known Subclasses:
DataJoinKey, DataJoinValue, KeyTuple

public class Tuple
extends java.lang.Object
implements org.apache.hadoop.io.WritableComparable<Tuple>, java.lang.Cloneable, org.apache.hadoop.conf.Configurable, org.apache.hadoop.io.RawComparator<Tuple>

Represents a record(row) in a dataset.

This product is licensed under the Apache License, Version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0. This product contains portions derived from Apache hadoop which is licensed under the Apache License, Version 2.0, available at http://hadoop.apache.org. © 2007 – 2012 eBay Inc., Evan Chiu, Woody Zhou, Neel Sundaresan


Nested Class Summary
static class Tuple.TupleColumnName
          Represents the name of a tuple column.
 
Field Summary
protected  java.lang.String _INSERT_KEY
          key used for synchronizing update activities to this tuple.
static byte BOOLEAN_TYPE
           
static byte BYTE_ARRAY_TYPE
          Represents byte[].
static byte BYTE_TYPE
           
protected  org.apache.hadoop.conf.Configuration conf
          Hadoop configuration object.
static byte DATE_TYPE
          java.sql.Date, only contains yyyy-mm-dd
static byte DOUBLE_TYPE
           
protected  long estimate_size_in_bytes
           
static byte FLOAT_TYPE
           
static byte INTEGER_TYPE
           
protected  boolean isMutable
           
static byte LONG_TYPE
           
protected static java.util.Map<java.lang.String,java.lang.String> lowerCases
          For quick look up of lower cases form of a given string so we don't to toLowerCase() everytime when retriving or setting value to a tuple
protected  java.util.Map<java.lang.String,java.lang.Integer> namesToIdxMapping
          a mapping from a column name to an index in the values array to get it value.
static Tuple NULL
          An immutable Tuple which contains only single Column NULL with null value.
static byte NULL_TYPE
          Represents java null.
static byte NULL_WRITABLE_TYPE
          represents org.apache.hadoop.io.NullWritable
static byte RESULT_WRAPPER_TYPE
          representing value generated by a combiner
static byte SERIALIZABLE_TYPE
          Represents Serializable
static byte SHORT_TYPE
           
protected static java.util.Map<java.util.Set<java.lang.String>,java.util.List<java.lang.String>> sortedKeys
           
static byte STRING_MAP_TYPE
          Represents CaseInsensitiveTreeMap type.
static byte STRING_TYPE
           
static byte TIME_TYPE
          java.sql.Time type, contains hh:mm:ss.[fff]
static byte TIMESTAMP_TYPE
          java.sql.Timestamp type, contains yyyy-mm-dd hh:mm:ss.[fff]
protected  java.lang.String[] toStringOrdering
           
static byte TUPLE_TYPE
          Represents com.ebay.erl.mobius.core.model.Tuple type.
protected  java.util.List<java.lang.Object> values
          to hold the actual values of columns within this mapper.
static byte WRITABLE_TYPE
          Represents org.hadoop.hadoop.io.Writable type.
 
Constructor Summary
Tuple()
           
 
Method Summary
protected  int check_in_schema(java.lang.String name)
          Check if the given name exists in this tuple or not, if so, returns its index.
 Tuple clone()
          Return a new instance of Tuple which contains the exact same data of this one.
 int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)
          compare two tuples in low level row format.
 int compare(Tuple t1, Tuple t2)
          Comparing two tuples.
 int compareTo(Tuple other)
          Compare this tuple with other.
 boolean equals(java.lang.Object obj)
          Compare if the obj equals to this tuple or not.
protected  java.lang.Object get(byte expecting_type, java.lang.String name, java.lang.Object default_value)
          Get the value for column name in the expecting_type.
protected  java.lang.Object get(byte expecting_type, java.lang.String name, java.lang.Object value, java.lang.Object default_value)
          Get the value of the given column name in the expecting_type.
 java.lang.Object get(int index)
          Get value directly using index.
 java.lang.Object get(java.lang.String name)
          Get the value of column named name.
 java.lang.Boolean getBoolean(java.lang.String name)
          Get the value of column named name.
 java.lang.Boolean getBoolean(java.lang.String name, boolean default_value)
          Get the value of column named name.
 java.lang.Byte getByte(java.lang.String name)
          Get the value of column named name.
 java.lang.Byte getByte(java.lang.String name, byte default_value)
          Get the value of column named name.
 org.apache.hadoop.conf.Configuration getConf()
          Get Hadoop configuration.
 java.sql.Date getDate(java.lang.String name)
          Get the value of column named name.
 java.sql.Date getDate(java.lang.String name, java.sql.Date default_value)
          Get the value of column named name.
 java.lang.Double getDouble(int idx, double default_value)
          Get the value of idxth column in this tuple.
 java.lang.Double getDouble(java.lang.String name)
          Get the value of column named name.
 java.lang.Double getDouble(java.lang.String name, double default_value)
          Get the value of column named name.
 long getEstimatedSizeInMemory()
          Return the estimated size in bytes of this tuple in memory.
 java.lang.Float getFloat(java.lang.String name)
          Get the value of column named name.
 java.lang.Float getFloat(java.lang.String name, float default_value)
          Get the value of column named name.
 java.lang.Integer getInt(java.lang.String name)
          Get the value of column named name.
 java.lang.Integer getInt(java.lang.String name, int default_value)
          Get the value of column named name.
 java.lang.Long getLong(java.lang.String name)
          Get the value of column named name.
 java.lang.Long getLong(java.lang.String name, long default_value)
          Get the value of column named name.
 java.util.Map<java.lang.String,java.lang.String> getMap(java.lang.String name)
          Get the value of column named name.
 java.lang.String[] getSchema()
          Return the schema of this column.
 java.lang.Short getShort(java.lang.String name)
          Get the value of column named name.
 java.lang.Short getShort(java.lang.String name, short default_value)
          Get the value of column named name.
protected static java.util.List<java.lang.String> getSorted(java.util.Set<java.lang.String> aKeySet)
           
 java.lang.String getString(java.lang.String name)
          Get the value of column named name.
 java.lang.String getString(java.lang.String name, java.lang.String default_value)
          Get the value of column named name.
 java.sql.Time getTime(java.lang.String name)
          Get the value of column named name.
 java.sql.Time getTime(java.lang.String name, java.sql.Time default_value)
          Get the value of column named name.
 java.sql.Timestamp getTimestamp(java.lang.String name)
          Get the value of column named name.
 java.sql.Timestamp getTimestamp(java.lang.String name, java.sql.Timestamp default_value)
          Get the value of column named name.
static byte getType(java.lang.Object obj)
          Get the type of the given obj in byte format, one of the supported type in Tuple.
static java.lang.String getTypeString(byte type)
          Get the readable string representation for a given type.
 int hashCode()
           
 boolean hasSchema()
           
static Tuple immutable(Tuple t)
          return a new instance of tuple that contains the same data of the given t tuple, but reject all modification requests, such as insert(String, Object).
 Tuple insert(java.lang.String name, java.lang.Object value)
          Add a new column in the given with provided value.
static boolean isDateType(byte type)
          Test if the given type is TIME_TYPE, DATE_TYPE, or TIMESTAMP_TYPE.
static boolean isNumericalType(byte type)
          Test if the given type is BYTE_TYPE, SHORT_TYPE, INTEGER_TYPE, LONG_TYPE, FLOAT_TYPE, or DOUBLE_TYPE.
protected static java.lang.String lowerCase(java.lang.String key)
           
static void main(java.lang.String[] arg)
           
static Tuple merge(Tuple t1, Tuple t2)
          Merge the tuples together, and return a new tuple represents the merged result.
 Tuple put(java.lang.String name, boolean value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, byte value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, byte[] value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, CaseInsensitiveTreeMap value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, java.sql.Date value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, double value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, float value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, int value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, long value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, ResultWrapper<?> v)
           
 Tuple put(java.lang.String name, java.io.Serializable value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, short value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, java.lang.String value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, java.sql.Time value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, java.sql.Timestamp value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple put(java.lang.String name, org.apache.hadoop.io.Writable value)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.
 Tuple putNull(java.lang.String name)
          For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to null.
 void readFields(java.io.DataInput in)
          Deserialize the tuple from the input in.
 void setConf(org.apache.hadoop.conf.Configuration conf)
          Set the Hadoop configuration, the delimiter to be used to separated the column value in the toString() is also set here.
 void setSchema(java.lang.String[] schema)
          To set the schema of this tuple.
 void setToStringOrdering(java.lang.String[] columns)
           
 java.lang.String toString()
          Convert this Tuple into text, the delimiter is specified by "mobius.tuple.tostring.delimiter" (default is tab).
static Tuple valueOf(org.apache.hadoop.io.Text source, java.lang.String[] schema, java.lang.String delimiter)
          Convert the source into a tuple.
 void write(java.io.DataOutput out)
          Serialize this tuple to the output out.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

estimate_size_in_bytes

protected long estimate_size_in_bytes

BYTE_TYPE

public static final byte BYTE_TYPE
See Also:
Constant Field Values

SHORT_TYPE

public static final byte SHORT_TYPE
See Also:
Constant Field Values

INTEGER_TYPE

public static final byte INTEGER_TYPE
See Also:
Constant Field Values

LONG_TYPE

public static final byte LONG_TYPE
See Also:
Constant Field Values

FLOAT_TYPE

public static final byte FLOAT_TYPE
See Also:
Constant Field Values

DOUBLE_TYPE

public static final byte DOUBLE_TYPE
See Also:
Constant Field Values

STRING_TYPE

public static final byte STRING_TYPE
See Also:
Constant Field Values

DATE_TYPE

public static final byte DATE_TYPE
java.sql.Date, only contains yyyy-mm-dd

See Also:
Constant Field Values

TIMESTAMP_TYPE

public static final byte TIMESTAMP_TYPE
java.sql.Timestamp type, contains yyyy-mm-dd hh:mm:ss.[fff]

See Also:
Constant Field Values

TIME_TYPE

public static final byte TIME_TYPE
java.sql.Time type, contains hh:mm:ss.[fff]

See Also:
Constant Field Values

BOOLEAN_TYPE

public static final byte BOOLEAN_TYPE
See Also:
Constant Field Values

RESULT_WRAPPER_TYPE

public static final byte RESULT_WRAPPER_TYPE
representing value generated by a combiner

See Also:
Constant Field Values

NULL_WRITABLE_TYPE

public static final byte NULL_WRITABLE_TYPE
represents org.apache.hadoop.io.NullWritable

See Also:
Constant Field Values

TUPLE_TYPE

public static final byte TUPLE_TYPE
Represents com.ebay.erl.mobius.core.model.Tuple type.

See Also:
Constant Field Values

BYTE_ARRAY_TYPE

public static final byte BYTE_ARRAY_TYPE
Represents byte[].

See Also:
Constant Field Values

STRING_MAP_TYPE

public static final byte STRING_MAP_TYPE
Represents CaseInsensitiveTreeMap type.

See Also:
Constant Field Values

WRITABLE_TYPE

public static final byte WRITABLE_TYPE
Represents org.hadoop.hadoop.io.Writable type.

See Also:
Constant Field Values

SERIALIZABLE_TYPE

public static final byte SERIALIZABLE_TYPE
Represents Serializable

See Also:
Constant Field Values

NULL_TYPE

public static final byte NULL_TYPE
Represents java null.

See Also:
Constant Field Values

namesToIdxMapping

protected java.util.Map<java.lang.String,java.lang.Integer> namesToIdxMapping
a mapping from a column name to an index in the values array to get it value.


values

protected java.util.List<java.lang.Object> values
to hold the actual values of columns within this mapper.


_INSERT_KEY

protected final java.lang.String _INSERT_KEY
key used for synchronizing update activities to this tuple.

See Also:
Constant Field Values

conf

protected org.apache.hadoop.conf.Configuration conf
Hadoop configuration object.


isMutable

protected boolean isMutable

lowerCases

protected static java.util.Map<java.lang.String,java.lang.String> lowerCases
For quick look up of lower cases form of a given string so we don't to toLowerCase() everytime when retriving or setting value to a tuple


sortedKeys

protected static java.util.Map<java.util.Set<java.lang.String>,java.util.List<java.lang.String>> sortedKeys

NULL

public static final Tuple NULL
An immutable Tuple which contains only single Column NULL with null value.


toStringOrdering

protected java.lang.String[] toStringOrdering
Constructor Detail

Tuple

public Tuple()
Method Detail

main

public static void main(java.lang.String[] arg)
                 throws java.lang.Throwable
Throws:
java.lang.Throwable

lowerCase

protected static java.lang.String lowerCase(java.lang.String key)

getSorted

protected static java.util.List<java.lang.String> getSorted(java.util.Set<java.lang.String> aKeySet)

setSchema

public void setSchema(java.lang.String[] schema)
To set the schema of this tuple.

This method is called when deserialize a tuple from disk, and should be called only in that case.

The ordering of the schema is sorted first then set into this tuple. It it because when a tuple is being serialize to disk, the values are extracted according to the order of their name. So when deserialize it back, the schema need to be sorted first and then set.

The reason of doing this is because Mobius stores the schema in hadoop configuration, but the user might create Tuples with the same schema but in different ordering (insert the values in the different order than the defined schema). To solve this problem, Mobius always serialize the values in a tuple according to their schema name order, so it can be deserialized back always in the right schema.


check_in_schema

protected int check_in_schema(java.lang.String name)
Check if the given name exists in this tuple or not, if so, returns its index.

Returns:
if the given name is in the schema of this tuple, the index of the schema is returned. Otherwise, IllegalArgumentException is thrown.

get

protected java.lang.Object get(byte expecting_type,
                               java.lang.String name,
                               java.lang.Object value,
                               java.lang.Object default_value)
Get the value of the given column name in the expecting_type.

If the original value is not in the exact same expecting_type, Mobius will try to convert it to the expecting_type and return it.

If the original value is null, then default_value is returned.

Parameters:
expecting_type - user specified type for the returned value.
name - the name of a column within this tuple.
value - the original value of the column name
default_value - if the original value is null, then default_value is returned.
Returns:

get

protected java.lang.Object get(byte expecting_type,
                               java.lang.String name,
                               java.lang.Object default_value)
Get the value for column name in the expecting_type.

Parameters:
expecting_type - the type of the returned object.
name - name of a column in this tuple.
default_value - if the value of the column is null, then default_value is returned.
Returns:
the value in the expected_type of column name

getDouble

public java.lang.Double getDouble(int idx,
                                  double default_value)
Get the value of idxth column in this tuple.

If the value of that column is not double, Mobius will try to convert it to double if possible, otherwise, NumberFormatException will be thrown.

Parameters:
idx - index to a column in this tuple, starts from 0.
default_value - if the value of the column is null, then default_value is returned.
Returns:

getTypeString

public static java.lang.String getTypeString(byte type)
Get the readable string representation for a given type.

Parameters:
type - type supported by Tuple.
Returns:
a readable string representation of the type.

getType

public static byte getType(java.lang.Object obj)
Get the type of the given obj in byte format, one of the supported type in Tuple.


readFields

public void readFields(java.io.DataInput in)
                throws java.io.IOException
Deserialize the tuple from the input in.

Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

write

public void write(java.io.DataOutput out)
           throws java.io.IOException
Serialize this tuple to the output out.

When serialize, the values are stored in the order of schema name's ordering. See setSchema(String[]) for more explanation.

Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
java.io.IOException

compareTo

public int compareTo(Tuple other)
Compare this tuple with other.

It calls compare(Tuple, Tuple) underline.

Specified by:
compareTo in interface java.lang.Comparable<Tuple>

insert

public Tuple insert(java.lang.String name,
                    java.lang.Object value)
Add a new column in the given with provided value.

Throws:
java.lang.UnsupportedOperationException - if this tuple is immutable.

getConf

public org.apache.hadoop.conf.Configuration getConf()
Get Hadoop configuration.

Specified by:
getConf in interface org.apache.hadoop.conf.Configurable

setConf

public void setConf(org.apache.hadoop.conf.Configuration conf)
Set the Hadoop configuration, the delimiter to be used to separated the column value in the toString() is also set here.

The default delimiter is tab, unless ConfigureConstants.TUPLE_TO_STRING_DELIMITER is set by user.

Specified by:
setConf in interface org.apache.hadoop.conf.Configurable

compare

public int compare(byte[] b1,
                   int s1,
                   int l1,
                   byte[] b2,
                   int s2,
                   int l2)
compare two tuples in low level row format.

Specified by:
compare in interface org.apache.hadoop.io.RawComparator<Tuple>

compare

public int compare(Tuple t1,
                   Tuple t2)
Comparing two tuples.

It compares the values of the two tuples one by one in sequence, and as long as there is a difference between two values, then the difference is returned.

If the number of values in the tuples are different, the values are compared up to the boundary of the smaller size tuple. If all the values before the boundary have no differences, then the smaller size tuple is considered to be placed before the bigger size tuple.

Specified by:
compare in interface java.util.Comparator<Tuple>

put

public Tuple put(java.lang.String name,
                 ResultWrapper<?> v)

putNull

public Tuple putNull(java.lang.String name)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to null.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 byte value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 byte[] value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 short value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 int value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 long value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 float value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 double value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 boolean value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 java.sql.Date value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 java.sql.Timestamp value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 java.sql.Time value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 java.lang.String value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 CaseInsensitiveTreeMap value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 org.apache.hadoop.io.Writable value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple

put

public Tuple put(java.lang.String name,
                 java.io.Serializable value)
For the given column named name, add (if it doesn't exist) to this tuple or update (if it exists) its value to the given value.

Returns:
return this tuple
Throws:
java.lang.IllegalArgumentException - if value is instance of Map but not CaseInsensitiveTreeMap. Or when value doesn't implement Comparable

getShort

public java.lang.Short getShort(java.lang.String name)
Get the value of column named name.

If the value is null, -1 is returned.

If the value is not null, but it's not a short type, Mobius will try to convert it to short, otherwise, NumberFormatException is thrown.


getShort

public java.lang.Short getShort(java.lang.String name,
                                short default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a short type, Mobius will try to convert it to short, otherwise, NumberFormatException is thrown.


getInt

public java.lang.Integer getInt(java.lang.String name)
Get the value of column named name.

If the value is null, -1 is returned.

If the value is not null, but it's not a short type, Mobius will try to convert it to short, otherwise, NumberFormatException is thrown.


getInt

public java.lang.Integer getInt(java.lang.String name,
                                int default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not an integer type, Mobius will try to convert it to integer, otherwise, NumberFormatException is thrown.


getLong

public java.lang.Long getLong(java.lang.String name)
Get the value of column named name.

If the value is null, -1L is returned.

If the value is not null, but it's not a long type, Mobius will try to convert it to long, otherwise, NumberFormatException is thrown.


getLong

public java.lang.Long getLong(java.lang.String name,
                              long default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a long type, Mobius will try to convert it to long, otherwise, NumberFormatException is thrown.


getFloat

public java.lang.Float getFloat(java.lang.String name)
Get the value of column named name.

If the value is null, -1F is returned.

If the value is not null, but it's not a float type, Mobius will try to convert it to float, otherwise, NumberFormatException is thrown.


getFloat

public java.lang.Float getFloat(java.lang.String name,
                                float default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a float type, Mobius will try to convert it to float, otherwise, NumberFormatException is thrown.


getDouble

public java.lang.Double getDouble(java.lang.String name)
Get the value of column named name.

If the value is null, -1D is returned.

If the value is not null, but it's not a double type, Mobius will try to convert it to double, otherwise, NumberFormatException is thrown.


getDouble

public java.lang.Double getDouble(java.lang.String name,
                                  double default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a double type, Mobius will try to convert it to double, otherwise, NumberFormatException is thrown.


getByte

public java.lang.Byte getByte(java.lang.String name)
Get the value of column named name.

If the value is null, 0x00 is returned.

If the value is not null, but it's not a byte type, Mobius will try to convert it to byte, otherwise, NumberFormatException is thrown.


getByte

public java.lang.Byte getByte(java.lang.String name,
                              byte default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a byte type, Mobius will try to convert it to byte, otherwise, NumberFormatException is thrown.


getBoolean

public java.lang.Boolean getBoolean(java.lang.String name)
Get the value of column named name.

If the value is null, false is returned.

If the value is not null, but it's not a boolean type, Mobius will try to convert it to using Boolean.valueOf(String).


getBoolean

public java.lang.Boolean getBoolean(java.lang.String name,
                                    boolean default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a boolean type, Mobius will try to convert it to using Boolean.valueOf(String).


getString

public java.lang.String getString(java.lang.String name)
Get the value of column named name.

If the value is null, null is still returned.

If the value is not null, but it's not a string type, Mobius will try to convert it to using the toString() method.


getString

public java.lang.String getString(java.lang.String name,
                                  java.lang.String default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a string type, Mobius will try to convert it to using the toString() method.


getMap

public java.util.Map<java.lang.String,java.lang.String> getMap(java.lang.String name)
Get the value of column named name.

If the value is null, null is still returned.

If the value is not null, but it's not a map type, IllegalArgumentException is thrown.


getDate

public java.sql.Date getDate(java.lang.String name)
Get the value of column named name.

If the value is null, null is still returned.

If the value is not null, but it's not a date type, Mobius will try to convert it to using the Date.valueOf(String) method.


getDate

public java.sql.Date getDate(java.lang.String name,
                             java.sql.Date default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a date type, Mobius will try to convert it to using the Date.valueOf(String) method.


getTimestamp

public java.sql.Timestamp getTimestamp(java.lang.String name)
Get the value of column named name.

If the value is null, null is still returned.

If the value is not null, but it's not a date type, Mobius will try to convert it to using the Timestamp.valueOf(String) method.


getTimestamp

public java.sql.Timestamp getTimestamp(java.lang.String name,
                                       java.sql.Timestamp default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a date type, Mobius will try to convert it to using the Timestamp.valueOf(String) method.


getTime

public java.sql.Time getTime(java.lang.String name)
Get the value of column named name.

If the value is null, null is still returned.

If the value is not null, but it's not a date type, Mobius will try to convert it to using the Time.valueOf(String) method.


getTime

public java.sql.Time getTime(java.lang.String name,
                             java.sql.Time default_value)
Get the value of column named name.

If the value is null, default_value is returned.

If the value is not null, but it's not a date type, Mobius will try to convert it to using the Time.valueOf(String) method.


get

public java.lang.Object get(int index)
Get value directly using index.


get

public java.lang.Object get(java.lang.String name)
Get the value of column named name.

Parameters:
name - the name of a column.
Returns:
value of the column.

clone

public Tuple clone()
Return a new instance of Tuple which contains the exact same data of this one.

Overrides:
clone in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isNumericalType

public static boolean isNumericalType(byte type)
Test if the given type is BYTE_TYPE, SHORT_TYPE, INTEGER_TYPE, LONG_TYPE, FLOAT_TYPE, or DOUBLE_TYPE.

Return true if the type is within the above types, false otherwise.


isDateType

public static boolean isDateType(byte type)
Test if the given type is TIME_TYPE, DATE_TYPE, or TIMESTAMP_TYPE.

Return true if the type is within the above types, false otherwise.


immutable

public static Tuple immutable(Tuple t)
return a new instance of tuple that contains the same data of the given t tuple, but reject all modification requests, such as insert(String, Object).

Note that, this method return a new instance, the original t tuple is still a mutable Tuple.


merge

public static Tuple merge(Tuple t1,
                          Tuple t2)
Merge the tuples together, and return a new tuple represents the merged result.

All the columns in t1 and t2 will be put together into the returned Tuple. If there are columns in t2 also appear in t1, then values from t2 of those columns will be used instead of the values in t1.


toString

public java.lang.String toString()
Convert this Tuple into text, the delimiter is specified by "mobius.tuple.tostring.delimiter" (default is tab).

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compare if the obj equals to this tuple or not.

Equals only whe the class of this tuple and the obj is the same, both share same schema, and the values of the columns are the same.

Specified by:
equals in interface java.util.Comparator<Tuple>
Overrides:
equals in class java.lang.Object

getSchema

public java.lang.String[] getSchema()
Return the schema of this column.


valueOf

public static Tuple valueOf(org.apache.hadoop.io.Text source,
                            java.lang.String[] schema,
                            java.lang.String delimiter)
Convert the source into a tuple.

Split the source with the given delimiter, and use them as the values to the returned tuple, then set the schema to the tuple.

The ordering of the schema shall be the same as the ordering of the values from the splitted source.

If the number of values in the splitted source is greater than the length of schema, IDX_$i is used as the name of those value, where $i starts from the length of schema.


getEstimatedSizeInMemory

public long getEstimatedSizeInMemory()
Return the estimated size in bytes of this tuple in memory.

This calculation is based on 64bit VM.


setToStringOrdering

public void setToStringOrdering(java.lang.String[] columns)

hasSchema

public boolean hasSchema()