Package org.apache.heron.api.tuple
Interface Tuple
-
- All Superinterfaces:
Serializable
public interface Tuple extends Serializable
The tuple is the main data structure in Heron. A tuple is a named list of values, where each value can be any type. Tuples are dynamically typed -- the types of the fields do not need to be declared. Tuples have helper methods like getInteger and getString to get field values without having to cast the result.Heron needs to know how to serialize all the values in a tuple. By default, Heron knows how to serialize the primitive types, strings, and byte arrays. If you want to use another type, you'll need to implement and register a serializer for that type.
- See Also:
- Storm serialization
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancontains(String field)Returns true if this tuple contains the specified name of the field.intfieldIndex(String field)Returns the position of the specified field in this tuple.byte[]getBinary(int i)Returns the byte array at position i in the tuple.byte[]getBinaryByField(String field)BooleangetBoolean(int i)Returns the Boolean at position i in the tuple.BooleangetBooleanByField(String field)BytegetByte(int i)Returns the Byte at position i in the tuple.BytegetByteByField(String field)DoublegetDouble(int i)Returns the Double at position i in the tuple.DoublegetDoubleByField(String field)FieldsgetFields()Gets the names of the fields in this tuple.FloatgetFloat(int i)Returns the Float at position i in the tuple.FloatgetFloatByField(String field)IntegergetInteger(int i)Returns the Integer at position i in the tuple.IntegergetIntegerByField(String field)LonggetLong(int i)Returns the Long at position i in the tuple.LonggetLongByField(String field)ShortgetShort(int i)Returns the Short at position i in the tuple.ShortgetShortByField(String field)StringgetSourceComponent()Gets the id of the component that created this tuple.org.apache.heron.api.generated.TopologyAPI.StreamIdgetSourceGlobalStreamId()Returns the global stream id (component + stream) of this tuple.StringgetSourceStreamId()Gets the id of the stream that this tuple was emitted to.intgetSourceTask()Gets the id of the task that created this tuple.StringgetString(int i)Returns the String at position i in the tuple.StringgetStringByField(String field)ObjectgetValue(int i)Gets the field at position i in the tuple.ObjectgetValueByField(String field)List<Object>getValues()Gets all the values in this tuple.voidresetValues()Resets the tuple values to null TODO:- Is this neededList<Object>select(Fields selector)Returns a subset of the tuple based on the fields selector.intsize()Returns the number of fields in this tuple.
-
-
-
Method Detail
-
size
int size()
Returns the number of fields in this tuple.
-
fieldIndex
int fieldIndex(String field)
Returns the position of the specified field in this tuple.
-
contains
boolean contains(String field)
Returns true if this tuple contains the specified name of the field.
-
getValue
Object getValue(int i)
Gets the field at position i in the tuple. Returns object since tuples are dynamically typed.
-
getString
String getString(int i)
Returns the String at position i in the tuple. If that field is not a String, you will get a runtime error.
-
getInteger
Integer getInteger(int i)
Returns the Integer at position i in the tuple. If that field is not an Integer, you will get a runtime error.
-
getLong
Long getLong(int i)
Returns the Long at position i in the tuple. If that field is not a Long, you will get a runtime error.
-
getBoolean
Boolean getBoolean(int i)
Returns the Boolean at position i in the tuple. If that field is not a Boolean, you will get a runtime error.
-
getShort
Short getShort(int i)
Returns the Short at position i in the tuple. If that field is not a Short, you will get a runtime error.
-
getByte
Byte getByte(int i)
Returns the Byte at position i in the tuple. If that field is not a Byte, you will get a runtime error.
-
getDouble
Double getDouble(int i)
Returns the Double at position i in the tuple. If that field is not a Double, you will get a runtime error.
-
getFloat
Float getFloat(int i)
Returns the Float at position i in the tuple. If that field is not a Float, you will get a runtime error.
-
getBinary
byte[] getBinary(int i)
Returns the byte array at position i in the tuple. If that field is not a byte array, you will get a runtime error.
-
getBinaryByField
byte[] getBinaryByField(String field)
-
getFields
Fields getFields()
Gets the names of the fields in this tuple.
-
select
List<Object> select(Fields selector)
Returns a subset of the tuple based on the fields selector.
-
getSourceGlobalStreamId
org.apache.heron.api.generated.TopologyAPI.StreamId getSourceGlobalStreamId()
Returns the global stream id (component + stream) of this tuple.
-
getSourceComponent
String getSourceComponent()
Gets the id of the component that created this tuple.
-
getSourceTask
int getSourceTask()
Gets the id of the task that created this tuple.
-
getSourceStreamId
String getSourceStreamId()
Gets the id of the stream that this tuple was emitted to.
-
resetValues
void resetValues()
Resets the tuple values to null TODO:- Is this needed
-
-