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 booleancontains(String field)Returns true if this tuple contains the specified name of the field.booleanequals(Object other)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)Gets the Byte array field with a specific name.BooleangetBoolean(int i)Returns the Boolean at position i in the tuple.BooleangetBooleanByField(String field)Gets the Boolean field with a specific name.BytegetByte(int i)Returns the Byte at position i in the tuple.BytegetByteByField(String field)Gets the Byte field with a specific name.org.apache.heron.api.tuple.TuplegetDelegate()DoublegetDouble(int i)Returns the Double at position i in the tuple.DoublegetDoubleByField(String field)Gets the Double field with a specific name.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)Gets the Float field with a specific name.IntegergetInteger(int i)Returns the Integer at position i in the tuple.IntegergetIntegerByField(String field)Gets the Integer field with a specific name.LonggetLong(int i)Returns the Long at position i in the tuple.LonggetLongByField(String field)Gets the Long field with a specific name.ShortgetShort(int i)Returns the Short at position i in the tuple.ShortgetShortByField(String field)Gets the Short field with a specific name.StringgetSourceComponent()Gets the id of the component that created 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)Gets the String field with a specific name.ObjectgetValue(int i)Gets the field at position i in the tuple.ObjectgetValueByField(String field)Gets the field with a specific name.List<Object>getValues()Gets all the values in this tuple.inthashCode()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.StringtoString()
-
-
-
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:
fieldIndexin 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:
getIntegerin 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:
getBooleanin 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:TupleGets the field with a specific name. Returns object since tuples are dynamically typed.- Specified by:
getValueByFieldin interfaceTuple
-
getStringByField
public String getStringByField(String field)
Description copied from interface:TupleGets the String field with a specific name.- Specified by:
getStringByFieldin interfaceTuple
-
getIntegerByField
public Integer getIntegerByField(String field)
Description copied from interface:TupleGets the Integer field with a specific name.- Specified by:
getIntegerByFieldin interfaceTuple
-
getLongByField
public Long getLongByField(String field)
Description copied from interface:TupleGets the Long field with a specific name.- Specified by:
getLongByFieldin interfaceTuple
-
getBooleanByField
public Boolean getBooleanByField(String field)
Description copied from interface:TupleGets the Boolean field with a specific name.- Specified by:
getBooleanByFieldin interfaceTuple
-
getShortByField
public Short getShortByField(String field)
Description copied from interface:TupleGets the Short field with a specific name.- Specified by:
getShortByFieldin interfaceTuple
-
getByteByField
public Byte getByteByField(String field)
Description copied from interface:TupleGets the Byte field with a specific name.- Specified by:
getByteByFieldin interfaceTuple
-
getDoubleByField
public Double getDoubleByField(String field)
Description copied from interface:TupleGets the Double field with a specific name.- Specified by:
getDoubleByFieldin interfaceTuple
-
getFloatByField
public Float getFloatByField(String field)
Description copied from interface:TupleGets the Float field with a specific name.- Specified by:
getFloatByFieldin interfaceTuple
-
getBinaryByField
public byte[] getBinaryByField(String field)
Description copied from interface:TupleGets the Byte array field with a specific name.- Specified by:
getBinaryByFieldin 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:
getSourceComponentin interfaceTuple
-
getSourceTask
public int getSourceTask()
Gets the id of the task that created this tuple.- Specified by:
getSourceTaskin interfaceTuple
-
getSourceStreamId
public String getSourceStreamId()
Gets the id of the stream that this tuple was emitted to.- Specified by:
getSourceStreamIdin interfaceTuple
-
resetValues
public void resetValues()
Resets the tuple values to null TODO:- Is this needed- Specified by:
resetValuesin interfaceTuple
-
-