|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.htuple.Tuple
public class Tuple
A tuple for use as intermediary map outputs. Not designed for use beyond the scope of intermediary map outputs (i.e. don't use this for general-purpose persistence).
Null values are supported. If an element is retrieved using an index value that's out of bounds (and not a negative number), then a null value is be returned. SeeShuffleUtils for examples of how custom partitioning, sorting and grouping can be configured for
tuples.
Example usage:
// Create a 3-element tuple, where "alex" is located at index 0, "1" at index 1 and "3" at index 2
Tuple t = new Tuple();
t.add("alex").add(1).add(3);
// extract the third element (the number "3")
t.getInt(2);
You can also use enum's to get and set data for increased comprehension. The enum ordinal value
(see http://docs.oracle.com/javase/7/docs/api/java/lang/Enum.html#ordinal())
is used as the index.
enum MyTupleFields { ID, NAME }
...
Tuple t = new Tuple();
t.set(MyTupleFields.ID, 123);
t.set(MyTupleFields.NAME, "alex");
t.getString(MyTupleFields.NAME);
| Constructor Summary | |
|---|---|
Tuple()
|
|
| Method Summary | |
|---|---|
Tuple |
add(Boolean val)
Appends a new element to the tuple. |
Tuple |
add(org.apache.hadoop.io.BytesWritable val)
Appends a new element to the tuple. |
Tuple |
add(Double val)
Appends a new element to the tuple. |
Tuple |
add(Float val)
Appends a new element to the tuple. |
Tuple |
add(Integer val)
Appends a new element to the tuple. |
Tuple |
add(Long val)
Appends a new element to the tuple. |
Tuple |
add(Short val)
Appends a new element to the tuple. |
Tuple |
add(String val)
Appends a new element to the tuple. |
Tuple |
addBoolean(Boolean val)
Appends a new element to the tuple. |
Tuple |
addBytes(org.apache.hadoop.io.BytesWritable val)
Appends a new element to the tuple. |
Tuple |
addDouble(Double val)
Appends a new element to the tuple. |
Tuple |
addFloat(Float val)
Appends a new element to the tuple. |
Tuple |
addInt(Integer val)
Appends a new element to the tuple. |
Tuple |
addLong(Long val)
Appends a new element to the tuple. |
Tuple |
addShort(Short val)
Appends a new element to the tuple. |
Tuple |
addString(String val)
Appends a new element to the tuple. |
Tuple |
clear()
Remove all the elements from this tuple. |
int |
compareTo(Tuple other)
|
boolean |
equals(Object object)
|
Boolean |
getBoolean(Enum<?> eval)
Read an element from the supplied position in the tuple. |
Boolean |
getBoolean(int idx)
Read an element from the supplied position in the tuple. |
org.apache.hadoop.io.BytesWritable |
getBytes(Enum<?> eval)
Read an element from the supplied position in the tuple. |
org.apache.hadoop.io.BytesWritable |
getBytes(int idx)
Read an element from the supplied position in the tuple. |
Double |
getDouble(Enum<?> eval)
Read an element from the supplied position in the tuple. |
Double |
getDouble(int idx)
Read an element from the supplied position in the tuple. |
Float |
getFloat(Enum<?> eval)
Read an element from the supplied position in the tuple. |
Float |
getFloat(int idx)
Read an element from the supplied position in the tuple. |
Integer |
getInt(Enum<?> eval)
Read an element from the supplied position in the tuple. |
Integer |
getInt(int idx)
Read an element from the supplied position in the tuple. |
Long |
getLong(Enum<?> eval)
Read an element from the supplied position in the tuple. |
Long |
getLong(int idx)
Read an element from the supplied position in the tuple. |
Object |
getObject(Enum<?> eval)
Retrieves an element at a specific position. |
Object |
getObject(int idx)
Retrieves an element at a specific position. |
Short |
getShort(Enum<?> eval)
Read an element from the supplied position in the tuple. |
Short |
getShort(int idx)
Read an element from the supplied position in the tuple. |
String |
getString(Enum<?> eval)
Read an element from the supplied position in the tuple. |
String |
getString(int idx)
Read an element from the supplied position in the tuple. |
int |
hashCode()
|
void |
readFields(DataInput in)
|
Tuple |
set(Enum<?> eval,
org.apache.hadoop.io.BytesWritable val)
Deprecated. use setBytes(Enum, org.apache.hadoop.io.BytesWritable) instead |
Tuple |
set(Enum<?> eval,
Double val)
Deprecated. use setDouble(Enum, Double) instead |
Tuple |
set(Enum<?> eval,
Float val)
Deprecated. use setFloat(Enum, Float) instead |
Tuple |
set(Enum<?> eval,
Integer val)
Deprecated. use setInt(Enum, Integer) instead |
Tuple |
set(Enum<?> eval,
Long val)
Deprecated. use setLong(Enum, Long) instead |
Tuple |
set(Enum<?> eval,
Object val)
Sets a value at a specific position in the tuple. |
Tuple |
set(Enum<?> eval,
Short val)
Deprecated. use setShort(Enum, Short) instead |
Tuple |
set(Enum<?> eval,
String val)
Deprecated. use setString(Enum, String) instead |
Tuple |
set(int idx,
Boolean val)
Deprecated. use setBoolean(int, Boolean) instead |
Tuple |
set(int idx,
org.apache.hadoop.io.BytesWritable val)
Deprecated. use setBytes(int, org.apache.hadoop.io.BytesWritable) instead |
Tuple |
set(int idx,
Double val)
Deprecated. use setDouble(int, Double) instead |
Tuple |
set(int idx,
Float val)
Deprecated. use setFloat(int, Float) instead |
Tuple |
set(int idx,
Integer val)
Deprecated. use setInt(int, Integer) instead |
Tuple |
set(int idx,
Object val)
Sets a value at a specific position in the tuple. |
Tuple |
set(int idx,
Short val)
Deprecated. use setShort(int, Short) instead |
Tuple |
set(int idx,
String val)
Deprecated. use setString(int, String) instead |
Tuple |
setBoolean(int idx,
Boolean val)
Sets a value at a specific position in the tuple. |
Tuple |
setBytes(Enum<?> eval,
org.apache.hadoop.io.BytesWritable val)
Sets a value at a specific position in the tuple. |
Tuple |
setBytes(int idx,
org.apache.hadoop.io.BytesWritable val)
Sets a value at a specific position in the tuple. |
Tuple |
setDouble(Enum<?> eval,
Double val)
Sets a value at a specific position in the tuple. |
Tuple |
setDouble(int idx,
Double val)
Sets a value at a specific position in the tuple. |
Tuple |
setFloat(Enum<?> eval,
Float val)
Sets a value at a specific position in the tuple. |
Tuple |
setFloat(int idx,
Float val)
Sets a value at a specific position in the tuple. |
Tuple |
setInt(Enum<?> eval,
Integer val)
Sets a value at a specific position in the tuple. |
Tuple |
setInt(int idx,
Integer val)
Sets a value at a specific position in the tuple. |
Tuple |
setLong(Enum<?> eval,
Long val)
Sets a value at a specific position in the tuple. |
Tuple |
setLong(int idx,
Integer val)
Sets a value at a specific position in the tuple. |
Tuple |
setShort(Enum<?> eval,
Short val)
Sets a value at a specific position in the tuple. |
Tuple |
setShort(int idx,
Short val)
Sets a value at a specific position in the tuple. |
Tuple |
setString(Enum<?> eval,
String val)
Sets a value at a specific position in the tuple. |
Tuple |
setString(int idx,
String val)
Sets a value at a specific position in the tuple. |
int |
size()
Returns the number of elements in this tuple. |
String |
toString()
|
void |
write(DataOutput out)
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Tuple()
| Method Detail |
|---|
public Tuple clear()
public int size()
public Tuple set(int idx,
Object val)
idx elements.
idx - the index to setval - the value to set
public Tuple set(Enum<?> eval,
Object val)
Enum.ordinal() on the supplied enum.
If this tuple has fewer elements than the index being set, then the tuple will grow to
idx elements.
eval - the enum which is used to determine the index for the set operationval - the value to set
public Tuple set(Enum<?> eval,
Short val)
setShort(Enum, Short) instead
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple setShort(Enum<?> eval,
Short val)
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple set(int idx,
Short val)
setShort(int, Short) instead
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple setShort(int idx,
Short val)
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple set(Enum<?> eval,
Integer val)
setInt(Enum, Integer) instead
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple setInt(Enum<?> eval,
Integer val)
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple set(int idx,
Integer val)
setInt(int, Integer) instead
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple setInt(int idx,
Integer val)
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple set(Enum<?> eval,
Long val)
setLong(Enum, Long) instead
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple setLong(Enum<?> eval,
Long val)
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple setLong(int idx,
Integer val)
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple set(int idx,
String val)
setString(int, String) instead
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple setString(int idx,
String val)
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple set(Enum<?> eval,
String val)
setString(Enum, String) instead
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple setString(Enum<?> eval,
String val)
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple set(int idx,
Boolean val)
setBoolean(int, Boolean) instead
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple setBoolean(int idx,
Boolean val)
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple set(Enum<?> eval,
Double val)
setDouble(Enum, Double) instead
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple setDouble(Enum<?> eval,
Double val)
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple set(int idx,
Double val)
setDouble(int, Double) instead
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple setDouble(int idx,
Double val)
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple set(Enum<?> eval,
Float val)
setFloat(Enum, Float) instead
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple set(int idx,
Float val)
setFloat(int, Float) instead
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple setFloat(Enum<?> eval,
Float val)
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple setFloat(int idx,
Float val)
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple set(Enum<?> eval,
org.apache.hadoop.io.BytesWritable val)
setBytes(Enum, org.apache.hadoop.io.BytesWritable) instead
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple set(int idx,
org.apache.hadoop.io.BytesWritable val)
setBytes(int, org.apache.hadoop.io.BytesWritable) instead
idx - the index for the set operationval - the value to set
set(int, Object)
public Tuple setBytes(Enum<?> eval,
org.apache.hadoop.io.BytesWritable val)
eval - the enum which is used to determine the index for the set operationval - the value to set
for more info
public Tuple setBytes(int idx,
org.apache.hadoop.io.BytesWritable val)
idx - the index for the set operationval - the value to set
set(int, Object)public Tuple add(Short val)
val - the value to add
public Tuple addShort(Short val)
val - the value to add
public Tuple add(Integer val)
val - the value to add
public Tuple addInt(Integer val)
val - the value to add
public Tuple add(Long val)
val - the value to add
public Tuple addLong(Long val)
val - the value to add
public Tuple add(String val)
val - the value to add
public Tuple addString(String val)
val - the value to add
public Tuple add(Boolean val)
val - the value to add
public Tuple addBoolean(Boolean val)
val - the value to add
public Tuple add(Double val)
val - the value to add
public Tuple addDouble(Double val)
val - the value to add
public Tuple add(Float val)
val - the value to add
public Tuple addFloat(Float val)
val - the value to add
public Tuple add(org.apache.hadoop.io.BytesWritable val)
val - the value to add
public Tuple addBytes(org.apache.hadoop.io.BytesWritable val)
val - the value to add
public Object getObject(int idx)
List.get(int). In our case, if the supplied index is greater than
the number of elements in this tuple, we'll return a null.
However we do throw a IllegalArgumentException in the case that the
index is less than 0.
idx - the index into the fields
public Object getObject(Enum<?> eval)
eval - the enum used to extract the ordinal value
getObject(int)public Short getShort(Enum<?> eval)
getObject(Enum)public Short getShort(int idx)
getObject(int)public Integer getInt(Enum<?> eval)
getObject(Enum)public Integer getInt(int idx)
getObject(int)public Long getLong(Enum<?> eval)
getObject(Enum)public Long getLong(int idx)
getObject(int)public String getString(Enum<?> eval)
getObject(Enum)public String getString(int idx)
getObject(int)public Boolean getBoolean(Enum<?> eval)
getObject(Enum)public Boolean getBoolean(int idx)
getObject(int)public Double getDouble(Enum<?> eval)
getObject(Enum)public Double getDouble(int idx)
getObject(int)public Float getFloat(Enum<?> eval)
getObject(Enum)public Float getFloat(int idx)
getObject(int)public org.apache.hadoop.io.BytesWritable getBytes(Enum<?> eval)
getObject(Enum)public org.apache.hadoop.io.BytesWritable getBytes(int idx)
getObject(int)
public void write(DataOutput out)
throws IOException
write in interface org.apache.hadoop.io.WritableIOException
public void readFields(DataInput in)
throws IOException
readFields in interface org.apache.hadoop.io.WritableIOExceptionpublic int hashCode()
hashCode in class Objectpublic boolean equals(Object object)
equals in class Objectpublic String toString()
toString in class Objectpublic int compareTo(Tuple other)
compareTo in interface Comparable<Tuple>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||