Package org.apache.storm.tuple
Class TupleImpl
- java.lang.Object
-
- org.apache.storm.tuple.TupleImpl
-
- All Implemented Interfaces:
Tuple
public class TupleImpl extends Object implements Tuple
The tuple is the main data structure in Storm. 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.Storm needs to know how to serialize all the values in a tuple. By default, Storm 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
-
-
Constructor Summary
Constructors Constructor Description TupleImpl(org.apache.heron.api.tuple.Tuple t)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(String field)
Returns true if this tuple contains the specified name of the field.boolean
equals(Object other)
int
fieldIndex(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)
Gets the Byte array field with a specific name.Boolean
getBoolean(int i)
Returns the Boolean at position i in the tuple.Boolean
getBooleanByField(String field)
Gets the Boolean field with a specific name.Byte
getByte(int i)
Returns the Byte at position i in the tuple.Byte
getByteByField(String field)
Gets the Byte field with a specific name.org.apache.heron.api.tuple.Tuple
getDelegate()
Double
getDouble(int i)
Returns the Double at position i in the tuple.Double
getDoubleByField(String field)
Gets the Double field with a specific name.Fields
getFields()
Gets the names of the fields in this tuple.Float
getFloat(int i)
Returns the Float at position i in the tuple.Float
getFloatByField(String field)
Gets the Float field with a specific name.Integer
getInteger(int i)
Returns the Integer at position i in the tuple.Integer
getIntegerByField(String field)
Gets the Integer field with a specific name.Long
getLong(int i)
Returns the Long at position i in the tuple.Long
getLongByField(String field)
Gets the Long field with a specific name.Short
getShort(int i)
Returns the Short at position i in the tuple.Short
getShortByField(String field)
Gets the Short field with a specific name.String
getSourceComponent()
Gets the id of the component that created this tuple.String
getSourceStreamId()
Gets the id of the stream that this tuple was emitted to.int
getSourceTask()
Gets the id of the task that created this tuple.String
getString(int i)
Returns the String at position i in the tuple.String
getStringByField(String field)
Gets the String field with a specific name.Object
getValue(int i)
Gets the field at position i in the tuple.Object
getValueByField(String field)
Gets the field with a specific name.List<Object>
getValues()
Gets all the values in this tuple.int
hashCode()
void
resetValues()
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.int
size()
Returns the number of fields in this tuple.String
toString()
-
-
-
Method Detail
-
getDelegate
public org.apache.heron.api.tuple.Tuple getDelegate()
-
size
public int size()
Returns the number of fields in this tuple.
-
fieldIndex
public int fieldIndex(String field)
Returns the position of the specified field in this tuple.- Specified by:
fieldIndex
in interfaceTuple
-
contains
public boolean contains(String field)
Returns true if this tuple contains the specified name of the field.
-
getValue
public Object getValue(int i)
Gets the field at position i in the tuple. Returns object since tuples are dynamically typed.
-
getString
public 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
public 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.- Specified by:
getInteger
in interfaceTuple
-
getLong
public 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
public 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.- Specified by:
getBoolean
in interfaceTuple
-
getShort
public 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
public 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
public 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
public 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
public 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.
-
getValueByField
public Object getValueByField(String field)
Description copied from interface:Tuple
Gets the field with a specific name. Returns object since tuples are dynamically typed.- Specified by:
getValueByField
in interfaceTuple
-
getStringByField
public String getStringByField(String field)
Description copied from interface:Tuple
Gets the String field with a specific name.- Specified by:
getStringByField
in interfaceTuple
-
getIntegerByField
public Integer getIntegerByField(String field)
Description copied from interface:Tuple
Gets the Integer field with a specific name.- Specified by:
getIntegerByField
in interfaceTuple
-
getLongByField
public Long getLongByField(String field)
Description copied from interface:Tuple
Gets the Long field with a specific name.- Specified by:
getLongByField
in interfaceTuple
-
getBooleanByField
public Boolean getBooleanByField(String field)
Description copied from interface:Tuple
Gets the Boolean field with a specific name.- Specified by:
getBooleanByField
in interfaceTuple
-
getShortByField
public Short getShortByField(String field)
Description copied from interface:Tuple
Gets the Short field with a specific name.- Specified by:
getShortByField
in interfaceTuple
-
getByteByField
public Byte getByteByField(String field)
Description copied from interface:Tuple
Gets the Byte field with a specific name.- Specified by:
getByteByField
in interfaceTuple
-
getDoubleByField
public Double getDoubleByField(String field)
Description copied from interface:Tuple
Gets the Double field with a specific name.- Specified by:
getDoubleByField
in interfaceTuple
-
getFloatByField
public Float getFloatByField(String field)
Description copied from interface:Tuple
Gets the Float field with a specific name.- Specified by:
getFloatByField
in interfaceTuple
-
getBinaryByField
public byte[] getBinaryByField(String field)
Description copied from interface:Tuple
Gets the Byte array field with a specific name.- Specified by:
getBinaryByField
in interfaceTuple
-
getFields
public Fields getFields()
Gets the names of the fields in this tuple.
-
select
public List<Object> select(Fields selector)
Returns a subset of the tuple based on the fields selector.
-
getSourceComponent
public String getSourceComponent()
Gets the id of the component that created this tuple.- Specified by:
getSourceComponent
in interfaceTuple
-
getSourceTask
public int getSourceTask()
Gets the id of the task that created this tuple.- Specified by:
getSourceTask
in interfaceTuple
-
getSourceStreamId
public String getSourceStreamId()
Gets the id of the stream that this tuple was emitted to.- Specified by:
getSourceStreamId
in interfaceTuple
-
resetValues
public void resetValues()
Resets the tuple values to null TODO:- Is this needed- Specified by:
resetValues
in interfaceTuple
-
-