com.datasalt.pangool.io
Class Tuple

java.lang.Object
  extended by com.datasalt.pangool.io.Tuple
All Implemented Interfaces:
ITuple, Serializable, Cloneable

public class Tuple
extends Object
implements ITuple, Serializable, Cloneable

This is the basic implementation of ITuple.

See Also:
Serialized Form

Nested Class Summary
static class Tuple.IDontKnowHowToCopyThisStuff
          Thrown by deepCopy(ITuple, java.util.Map) in the case of field of a type that Pangool doesn't know how to copy it.
 
Constructor Summary
Tuple(Schema schema)
           
 
Method Summary
 void clear()
           
 Tuple deepCopy()
          Performs a deep copy of this Tuple.
static Tuple deepCopy(ITuple tuple)
          Performs a deep copy of the given Tuple.
static Tuple deepCopy(ITuple tuple, Map<String,FieldClonator> customClonators)
          Performs a deep copy of the given Tuple.
 Tuple deepCopy(Map<String,FieldClonator> customClonators)
          Performs a deep copy of this Tuple.
 boolean equals(Object that)
           
 Object get(int pos)
           
 Object get(String field)
           
 Boolean getBoolean(int pos)
           
 Boolean getBoolean(String field)
           
 Double getDouble(int pos)
           
 Double getDouble(String field)
           
 Float getFloat(int pos)
           
 Float getFloat(String field)
           
 Integer getInteger(int pos)
           
 Integer getInteger(String field)
           
 Long getLong(int pos)
           
 Long getLong(String field)
           
 Schema getSchema()
           
 String getString(int pos)
           
 String getString(String field)
           
 int hashCode()
           
 void set(int pos, Object object)
           
 void set(String field, Object object)
           
 void shallowCopy(ITuple tupleDest)
          Simple shallow copy of this Tuple to another Tuple.
 String toString()
           
static String toString(ITuple tuple)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tuple

public Tuple(Schema schema)
Method Detail

get

public Object get(int pos)
Specified by:
get in interface ITuple

set

public void set(int pos,
                Object object)
Specified by:
set in interface ITuple

toString

public String toString()
Overrides:
toString in class Object

toString

public static String toString(ITuple tuple)

clear

public void clear()
Specified by:
clear in interface ITuple

getSchema

public Schema getSchema()
Specified by:
getSchema in interface ITuple

get

public Object get(String field)
Specified by:
get in interface ITuple

set

public void set(String field,
                Object object)
Specified by:
set in interface ITuple

equals

public boolean equals(Object that)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

shallowCopy

public void shallowCopy(ITuple tupleDest)
Simple shallow copy of this Tuple to another Tuple.

Parameters:
tupleDest - The destination Tuple (should have the same Schema or a super-set of it).

deepCopy

public Tuple deepCopy()
Performs a deep copy of this Tuple.
Custom FieldClonators can be provided for each individual field.

Returns:
a copy of the tuple
Throws:
IllegalArgumentException - if the value of a particular field does not match with the type on the schema for this field.
Tuple.IDontKnowHowToCopyThisStuff - for fields of type Field.Type#OBJECT. See deepCopy(ITuple, java.util.Map) for solving this issue with FieldClonator

deepCopy

public Tuple deepCopy(Map<String,FieldClonator> customClonators)
Performs a deep copy of this Tuple.
Custom FieldClonators can be provided for each individual field.

Parameters:
customClonators - map with custom FieldClonator for each field, indexed by field name.
Returns:
a copy of the tuple
Throws:
IllegalArgumentException - if the value of a particular field does not match with the type on the schema for this field.
Tuple.IDontKnowHowToCopyThisStuff - for fields of type Field.Type#OBJECT without a custom FieldClonator. Provide always corresponding FieldClonators for this type of fields.

deepCopy

public static Tuple deepCopy(ITuple tuple)
Performs a deep copy of the given Tuple.
Custom FieldClonators can be provided for each individual field.

Parameters:
tuple - a tuple to copy.
Returns:
a copy of the tuple
Throws:
IllegalArgumentException - if the value of a particular field does not match with the type on the schema for this field.
Tuple.IDontKnowHowToCopyThisStuff - for fields of type Field.Type#OBJECT. See deepCopy(ITuple, java.util.Map) for solving this issue with FieldClonator

deepCopy

public static Tuple deepCopy(ITuple tuple,
                             Map<String,FieldClonator> customClonators)
Performs a deep copy of the given Tuple.
Custom FieldClonators can be provided for each individual field.

Parameters:
tuple - a tuple to copy.
customClonators - map with custom FieldClonator for each field, indexed by field name.
Returns:
a copy of the tuple
Throws:
IllegalArgumentException - if the value of a particular field does not match with the type on the schema for this field.
Tuple.IDontKnowHowToCopyThisStuff - for fields of type Field.Type#OBJECT without a custom FieldClonator. Provide always corresponding FieldClonators for this type of fields.

getInteger

public Integer getInteger(int pos)
Specified by:
getInteger in interface ITuple

getInteger

public Integer getInteger(String field)
Specified by:
getInteger in interface ITuple

getLong

public Long getLong(int pos)
Specified by:
getLong in interface ITuple

getLong

public Long getLong(String field)
Specified by:
getLong in interface ITuple

getFloat

public Float getFloat(int pos)
Specified by:
getFloat in interface ITuple

getFloat

public Float getFloat(String field)
Specified by:
getFloat in interface ITuple

getDouble

public Double getDouble(int pos)
Specified by:
getDouble in interface ITuple

getDouble

public Double getDouble(String field)
Specified by:
getDouble in interface ITuple

getBoolean

public Boolean getBoolean(int pos)
Specified by:
getBoolean in interface ITuple

getBoolean

public Boolean getBoolean(String field)
Specified by:
getBoolean in interface ITuple

getString

public String getString(int pos)
Specified by:
getString in interface ITuple

getString

public String getString(String field)
Specified by:
getString in interface ITuple


Copyright © –2014 Datasalt Systems S.L.. All rights reserved.