Package org.apache.flink.api.java.tuple
Class Tuple
- java.lang.Object
-
- org.apache.flink.api.java.tuple.Tuple
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Tuple0
,Tuple1
,Tuple10
,Tuple11
,Tuple12
,Tuple13
,Tuple14
,Tuple15
,Tuple16
,Tuple17
,Tuple18
,Tuple19
,Tuple2
,Tuple20
,Tuple21
,Tuple22
,Tuple23
,Tuple24
,Tuple25
,Tuple3
,Tuple4
,Tuple5
,Tuple6
,Tuple7
,Tuple8
,Tuple9
@Public public abstract class Tuple extends Object implements Serializable
The base class of all tuples. Tuples have a fix length and contain a set of fields, which may all be of different types. Because Tuples are strongly typed, each distinct tuple length is represented by its own class. Tuples exists with up to 25 fields and are described in the classesTuple1
toTuple25
.The fields in the tuples may be accessed directly a public fields, or via position (zero indexed)
getField(int)
.Tuples are in principle serializable. However, they may contain non-serializable fields, in which case serialization will fail.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_ARITY
-
Constructor Summary
Constructors Constructor Description Tuple()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <T extends Tuple>
Tcopy()
Shallow tuple copy.abstract int
getArity()
Gets the number of field in the tuple (the tuple arity).abstract <T> T
getField(int pos)
Gets the field at the specified position.<T> T
getFieldNotNull(int pos)
Gets the field at the specified position, throws NullFieldException if the field is null.static Class<? extends Tuple>
getTupleClass(int arity)
Gets the class corresponding to the tuple of the given arity (dimensions).static Tuple
newInstance(int arity)
abstract <T> void
setField(T value, int pos)
Sets the field at the specified position.
-
-
-
Field Detail
-
MAX_ARITY
public static final int MAX_ARITY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getField
public abstract <T> T getField(int pos)
Gets the field at the specified position.- Parameters:
pos
- The position of the field, zero indexed.- Returns:
- The field at the specified position.
- Throws:
IndexOutOfBoundsException
- Thrown, if the position is negative, or equal to, or larger than the number of fields.
-
getFieldNotNull
public <T> T getFieldNotNull(int pos)
Gets the field at the specified position, throws NullFieldException if the field is null. Used for comparing key fields.- Parameters:
pos
- The position of the field, zero indexed.- Returns:
- The field at the specified position.
- Throws:
IndexOutOfBoundsException
- Thrown, if the position is negative, or equal to, or larger than the number of fields.NullFieldException
- Thrown, if the field at pos is null.
-
setField
public abstract <T> void setField(T value, int pos)
Sets the field at the specified position.- Parameters:
value
- The value to be assigned to the field at the specified position.pos
- The position of the field, zero indexed.- Throws:
IndexOutOfBoundsException
- Thrown, if the position is negative, or equal to, or larger than the number of fields.
-
getArity
public abstract int getArity()
Gets the number of field in the tuple (the tuple arity).- Returns:
- The number of fields in the tuple.
-
copy
public abstract <T extends Tuple> T copy()
Shallow tuple copy.- Returns:
- A new Tuple with the same fields as this.
-
getTupleClass
public static Class<? extends Tuple> getTupleClass(int arity)
Gets the class corresponding to the tuple of the given arity (dimensions). For example,getTupleClass(3)
will return theTuple3.class
.- Parameters:
arity
- The arity of the tuple class to get.- Returns:
- The tuple class with the given arity.
-
newInstance
public static Tuple newInstance(int arity)
-
-