Class FieldAccessor<T,​F>

  • All Implemented Interfaces:
    Serializable

    @Internal
    public abstract class FieldAccessor<T,​F>
    extends Object
    implements Serializable
    These classes encapsulate the logic of accessing a field specified by the user as either an index or a field expression string. TypeInformation can also be requested for the field. The position index might specify a field of a Tuple, an array, or a simple type(only "0th field").

    Field expressions that specify nested fields (e.g. "f1.a.foo") result in nested field accessors. These penetrate one layer, and then delegate the rest of the work to an "innerAccessor". (see PojoFieldAccessor, RecursiveTupleFieldAccessor, RecursiveProductFieldAccessor)

    See Also:
    Serialized Form
    • Field Detail

      • fieldType

        protected org.apache.flink.api.common.typeinfo.TypeInformation fieldType
    • Constructor Detail

      • FieldAccessor

        public FieldAccessor()
    • Method Detail

      • getFieldType

        public org.apache.flink.api.common.typeinfo.TypeInformation<F> getFieldType()
        Gets the TypeInformation for the type of the field. Note: For an array of a primitive type, it returns the corresponding basic type (Integer for int[]).
      • get

        public abstract F get​(T record)
        Gets the value of the field (specified in the constructor) of the given record.
        Parameters:
        record - The record on which the field will be accessed
        Returns:
        The value of the field.
      • set

        public abstract T set​(T record,
                              F fieldValue)
        Sets the field (specified in the constructor) of the given record to the given value.

        Warning: This might modify the original object, or might return a new object instance. (This is necessary, because the record might be immutable.)

        Parameters:
        record - The record to modify
        fieldValue - The new value of the field
        Returns:
        A record that has the given field value. (this might be a new instance or the original)