Class Tuple1<T0>

  • Type Parameters:
    T0 - The type of field 0
    All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    CountAggFunction.CountAccumulator

    @Public
    public class Tuple1<T0>
    extends Tuple
    A tuple with 1 fields. Tuples are strongly typed; each field may be of a separate type. The fields of the tuple can be accessed directly as public fields (f0, f1, ...) or via their position through the getField(int) method. The tuple field positions start at zero.

    Tuples are mutable types, meaning that their fields can be re-assigned. This allows functions that work with Tuples to reuse objects in order to reduce pressure on the garbage collector.

    Warning: If you subclass Tuple1, then be sure to either

    • not add any new fields, or
    • make it a POJO, and always declare the element type of your DataStreams/DataSets to your descendant type. (That is, if you have a "class Foo extends Tuple1", then don't use instances of Foo in a DataStream<Tuple1> / DataSet<Tuple1>, but declare it as DataStream<Foo> / DataSet<Foo>.)
    See Also:
    Tuple, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      T0 f0
      Field 0 of the tuple.
      • Fields inherited from class org.apache.flink.api.java.tuple.Tuple

        MAX_ARITY
    • Constructor Summary

      Constructors 
      Constructor Description
      Tuple1()
      Creates a new tuple where all fields are null.
      Tuple1​(T0 f0)
      Creates a new tuple and assigns the given values to the tuple's fields.
    • Field Detail

      • f0

        public T0 f0
        Field 0 of the tuple.
    • Constructor Detail

      • Tuple1

        public Tuple1()
        Creates a new tuple where all fields are null.
      • Tuple1

        public Tuple1​(T0 f0)
        Creates a new tuple and assigns the given values to the tuple's fields.
        Parameters:
        f0 - The value for field 0
    • Method Detail

      • getArity

        public int getArity()
        Description copied from class: Tuple
        Gets the number of field in the tuple (the tuple arity).
        Specified by:
        getArity in class Tuple
        Returns:
        The number of fields in the tuple.
      • getField

        public <T> T getField​(int pos)
        Description copied from class: Tuple
        Gets the field at the specified position.
        Specified by:
        getField in class Tuple
        Parameters:
        pos - The position of the field, zero indexed.
        Returns:
        The field at the specified position.
      • setField

        public <T> void setField​(T value,
                                 int pos)
        Description copied from class: Tuple
        Sets the field at the specified position.
        Specified by:
        setField in class Tuple
        Parameters:
        value - The value to be assigned to the field at the specified position.
        pos - The position of the field, zero indexed.
      • setFields

        public void setFields​(T0 f0)
        Sets new values to all fields of the tuple.
        Parameters:
        f0 - The value for field 0
      • toString

        public String toString()
        Creates a string representation of the tuple in the form (f0), where the individual fields are the value returned by calling Object.toString() on that field.
        Overrides:
        toString in class Object
        Returns:
        The string representation of the tuple.
      • equals

        public boolean equals​(Object o)
        Deep equality for tuples by calling equals() on the tuple members.
        Overrides:
        equals in class Object
        Parameters:
        o - the object checked for equality
        Returns:
        true if this is equal to o.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • copy

        public Tuple1<T0> copy()
        Shallow tuple copy.
        Specified by:
        copy in class Tuple
        Returns:
        A new Tuple with the same fields as this.
      • of

        public static <T0> Tuple1<T0> of​(T0 f0)
        Creates a new tuple and assigns the given values to the tuple's fields. This is more convenient than using the constructor, because the compiler can infer the generic type arguments implicitly. For example: Tuple3.of(n, x, s) instead of new Tuple3<Integer, Double, String>(n, x, s)