|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcascading.tuple.Tuple
public class Tuple
A Tuple represents a set of values. Consider a Tuple the same as a data base record where every value is a column in that table. A Tuple stream would be a set of Tuple instances, which are passed consecutively through a Pipe assembly.
A Tuple is a collection of elements. These elements must be of type Comparable, so that Tuple instances can be compared. Tuple itself is Comparable and subsequently can hold elements of type Tuple. Tuples are mutable for sake of efficiency. Since Tuples are mutable, it is not a good idea to hold an instance around with out first copying it via its copy constructor, a subsequentPipe could change the Tuple in
place. This is especially true for Aggregator operators.
Because a Tuple can hold any Comparable type, it is suitable for storing custom types. But all custom types
must have a serialization support per the underlying framework.
For Hadoop, a Serialization implementation
must be registered with Hadoop. For further performance improvements, see the
SerializationToken Java annotation.
Comparable,
Serialization,
SerializationToken,
Serialized Form| Field Summary | |
|---|---|
protected List<Comparable> |
elements
Field elements |
protected boolean |
isUnmodifiable
Field isUnmodifiable |
| Constructor Summary | |
|---|---|
|
Tuple()
Constructor Tuple creates a new Tuple instance. |
|
Tuple(Comparable... values)
Constructor Tuple creates a new Tuple instance with all the given values. |
protected |
Tuple(List<Comparable> elements)
|
|
Tuple(String value)
Constructor Tuple creates a new Tuple instance with a single String value. |
|
Tuple(Tuple tuple)
Copy constructor. |
| Method Summary | |
|---|---|
void |
add(Comparable value)
Method add adds a new element value to this instance. |
void |
addAll(Comparable... values)
Method addAll adds all given values to this instance. |
void |
addAll(Tuple tuple)
Method addAll adds all the element values of the given Tuple instance to this instance. |
Tuple |
append(Tuple... tuples)
Method append appends all the values of the given Tuple instances to a copy of this instance. |
static Tuple |
asUnmodifiable(Tuple tuple)
|
int |
compareTo(Object other)
Method compareTo implements the Comparable.compareTo(Object) method. |
int |
compareTo(Tuple other)
Method compareTo compares this Tuple to the given Tuple instance. |
boolean |
equals(Object object)
|
String |
format(String format)
Method format uses the Formatter class for formatting this tuples values into a new string. |
Tuple |
get(Fields declarator,
Fields selector)
Method get returns a new Tuple populated with only those values whose field names are specified in the given selector. |
Comparable |
get(int pos)
Method get returns the element at the given position i. |
Tuple |
get(int[] pos)
Method get will return a new Tuple instace populated with element values from the given array of positions. |
boolean |
getBoolean(int pos)
Method getBoolean returns the element at the given position as a boolean. |
double |
getDouble(int pos)
Method getDouble returns the element at the given position i as a double. |
float |
getFloat(int pos)
Method getFloat returns the element at the given position i as a float. |
int |
getInteger(int pos)
Method getInteger returns the element at the given position i as an int. |
long |
getLong(int pos)
Method getLong returns the element at the given position i as an long. |
short |
getShort(int pos)
Method getShort returns the element at the given position i as an short. |
String |
getString(int pos)
Method getString returns the element at the given position i as a String. |
Class[] |
getTypes()
Method getTypes returns an array of the element classes. |
int |
hashCode()
|
boolean |
isEmpty()
Method isEmpty returns true if this Tuple instance has no values. |
boolean |
isUnmodifiable()
Method isUnmodifiable returns true if this Tuple instance is unmodifiable. |
Iterator |
iterator()
Method iterator returns an Iterator over this Tuple instances values. |
Tuple |
leave(int[] pos)
Method is the inverse of remove(int[]). |
static Tuple |
parse(String string)
Method parse will parse the print() String representation of a Tuple instance and return a new Tuple instance. |
String |
print()
Method print returns a parsable String representation of this Tuple instance. |
void |
put(Fields declarator,
Fields fields,
Tuple tuple)
Method put places the values of the given tuple into the positions specified by the fields argument. |
Tuple |
remove(Fields declarator,
Fields selector)
Method remove removes the values specified by the given selector. |
Tuple |
remove(int[] pos)
Method remove removes the values specified by the given pos array and returns a new Tuple containing the removed values. |
void |
set(Fields declarator,
Fields selector,
Tuple tuple)
Method set sets the values in the given selector positions to the values from the given Tuple. |
void |
set(int index,
Comparable value)
Method set sets the given value to the given index position in this instance. |
int |
size()
Method size retuns the number of values in this Tuple instance. |
static Tuple |
size(int size)
Method size returns a new Tuple instance of the given size with nulls as its element values. |
static Tuple |
size(int size,
Comparable value)
Method size returns a new Tuple instance of the given size with the given Comparable as its element values. |
String |
toString()
|
String |
toString(String delim)
Method toString writes this Tuple instance values out to a String delimited by the given String value. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected boolean isUnmodifiable
protected List<Comparable> elements
| Constructor Detail |
|---|
protected Tuple(List<Comparable> elements)
public Tuple()
public Tuple(String value)
value - of type Stringpublic Tuple(Tuple tuple)
add(Comparable).
tuple - of type Tuplepublic Tuple(Comparable... values)
values - of type Comparable...| Method Detail |
|---|
public static Tuple asUnmodifiable(Tuple tuple)
public static Tuple size(int size)
size - of type int
public static Tuple size(int size,
Comparable value)
size - of type intvalue - of type Comparable
public static Tuple parse(String string)
print() String representation of a Tuple instance and return a new Tuple instance.
string - of type String
public boolean isUnmodifiable()
public Comparable get(int pos)
pos - of type int
public String getString(int pos)
pos - of type int
public float getFloat(int pos)
pos - of type int
public double getDouble(int pos)
pos - of type int
public int getInteger(int pos)
pos - of type int
public long getLong(int pos)
pos - of type int
public short getShort(int pos)
pos - of type int
public boolean getBoolean(int pos)
true value will be returned. false if null.
pos - of type int
public Tuple get(int[] pos)
pos - of type int[]
public Tuple get(Fields declarator,
Fields selector)
declarator - of type Fieldsselector - of type Fields
public Tuple leave(int[] pos)
remove(int[]).
pos - of type int[]
public void add(Comparable value)
value - of type Comparablepublic void addAll(Comparable... values)
values - of type Comparable...public void addAll(Tuple tuple)
tuple - of type Tuple
public void set(int index,
Comparable value)
index - of type intvalue - of type Comparable
public void put(Fields declarator,
Fields fields,
Tuple tuple)
declarator - of type Fieldsfields - of type Fieldstuple - of type Tuplepublic Tuple remove(int[] pos)
pos - of type int[]
public Tuple remove(Fields declarator,
Fields selector)
declarator - of type Fieldsselector - of type Fields
public void set(Fields declarator,
Fields selector,
Tuple tuple)
declarator - of type Fieldsselector - of type Fieldstuple - of type Tuplepublic Iterator iterator()
Iterator over this Tuple instances values.
iterator in interface Iterablepublic boolean isEmpty()
public int size()
public Class[] getTypes()
public Tuple append(Tuple... tuples)
tuples - of type Tuple
public int compareTo(Tuple other)
other - of type Tuple
public int compareTo(Object other)
Comparable.compareTo(Object) method.
compareTo in interface Comparableother - of type Object
public boolean equals(Object object)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectpublic String toString(String delim)
delim - of type String
public String format(String format)
Formatter class for formatting this tuples values into a new string.
format - of type String
public String print()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||