Class 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 Detail

      • TupleImpl

        public TupleImpl​(org.apache.heron.api.tuple.Tuple t)
    • Method Detail

      • getDelegate

        public org.apache.heron.api.tuple.Tuple getDelegate()
      • size

        public int size()
        Returns the number of fields in this tuple.
        Specified by:
        size in interface Tuple
      • fieldIndex

        public int fieldIndex​(String field)
        Returns the position of the specified field in this tuple.
        Specified by:
        fieldIndex in interface Tuple
      • contains

        public boolean contains​(String field)
        Returns true if this tuple contains the specified name of the field.
        Specified by:
        contains in interface Tuple
      • getValue

        public Object getValue​(int i)
        Gets the field at position i in the tuple. Returns object since tuples are dynamically typed.
        Specified by:
        getValue in interface Tuple
      • 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.
        Specified by:
        getString in interface Tuple
      • 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 interface Tuple
      • 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.
        Specified by:
        getLong in interface Tuple
      • 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 interface Tuple
      • 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.
        Specified by:
        getShort in interface Tuple
      • 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.
        Specified by:
        getByte in interface Tuple
      • 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.
        Specified by:
        getDouble in interface Tuple
      • 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.
        Specified by:
        getFloat in interface Tuple
      • 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.
        Specified by:
        getBinary in interface Tuple
      • 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 interface Tuple
      • getStringByField

        public String getStringByField​(String field)
        Description copied from interface: Tuple
        Gets the String field with a specific name.
        Specified by:
        getStringByField in interface Tuple
      • getIntegerByField

        public Integer getIntegerByField​(String field)
        Description copied from interface: Tuple
        Gets the Integer field with a specific name.
        Specified by:
        getIntegerByField in interface Tuple
      • getLongByField

        public Long getLongByField​(String field)
        Description copied from interface: Tuple
        Gets the Long field with a specific name.
        Specified by:
        getLongByField in interface Tuple
      • getBooleanByField

        public Boolean getBooleanByField​(String field)
        Description copied from interface: Tuple
        Gets the Boolean field with a specific name.
        Specified by:
        getBooleanByField in interface Tuple
      • getShortByField

        public Short getShortByField​(String field)
        Description copied from interface: Tuple
        Gets the Short field with a specific name.
        Specified by:
        getShortByField in interface Tuple
      • getByteByField

        public Byte getByteByField​(String field)
        Description copied from interface: Tuple
        Gets the Byte field with a specific name.
        Specified by:
        getByteByField in interface Tuple
      • getDoubleByField

        public Double getDoubleByField​(String field)
        Description copied from interface: Tuple
        Gets the Double field with a specific name.
        Specified by:
        getDoubleByField in interface Tuple
      • getFloatByField

        public Float getFloatByField​(String field)
        Description copied from interface: Tuple
        Gets the Float field with a specific name.
        Specified by:
        getFloatByField in interface Tuple
      • getBinaryByField

        public byte[] getBinaryByField​(String field)
        Description copied from interface: Tuple
        Gets the Byte array field with a specific name.
        Specified by:
        getBinaryByField in interface Tuple
      • getValues

        public List<Object> getValues()
        Gets all the values in this tuple.
        Specified by:
        getValues in interface Tuple
      • getFields

        public Fields getFields()
        Gets the names of the fields in this tuple.
        Specified by:
        getFields in interface Tuple
      • select

        public List<Object> select​(Fields selector)
        Returns a subset of the tuple based on the fields selector.
        Specified by:
        select in interface Tuple
      • getSourceComponent

        public String getSourceComponent()
        Gets the id of the component that created this tuple.
        Specified by:
        getSourceComponent in interface Tuple
      • getSourceTask

        public int getSourceTask()
        Gets the id of the task that created this tuple.
        Specified by:
        getSourceTask in interface Tuple
      • getSourceStreamId

        public String getSourceStreamId()
        Gets the id of the stream that this tuple was emitted to.
        Specified by:
        getSourceStreamId in interface Tuple
      • resetValues

        public void resetValues()
        Resets the tuple values to null TODO:- Is this needed
        Specified by:
        resetValues in interface Tuple
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object