Interface Tuple

  • All Known Implementing Classes:
    TupleImpl

    public interface 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
    • Method Detail

      • size

        int size()
        Returns the number of fields in this tuple.
      • contains

        boolean contains​(String field)
        Returns true if this tuple contains the specified name of the field.
      • getFields

        Fields getFields()
        Gets the names of the fields in this tuple.
      • fieldIndex

        int fieldIndex​(String field)
        Returns the position of the specified field in this tuple.
        Throws:
        IllegalArgumentException - - if field does not exist
      • select

        List<Object> select​(Fields selector)
        Returns a subset of the tuple based on the fields selector.
      • getValue

        Object getValue​(int i)
        Gets the field at position i in the tuple. Returns object since tuples are dynamically typed.
        Throws:
        IndexOutOfBoundsException - - if the index is out of range `(index < 0 || index >= size())`
      • getBinary

        byte[] getBinary​(int i)
        Returns the byte array at position i in the tuple.
        Throws:
        ClassCastException - If that field is not a byte array
        IndexOutOfBoundsException - - if the index is out of range `(index < 0 || index >= size())`
      • getValueByField

        Object getValueByField​(String field)
        Gets the field with a specific name. Returns object since tuples are dynamically typed.
        Throws:
        IllegalArgumentException - - if field does not exist
      • getValues

        List<Object> getValues()
        Gets all the values in 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