Class FieldAccessor<T,F>

java.lang.Object
org.apache.flink.streaming.util.typeutils.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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.flink.api.common.typeinfo.TypeInformation
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract F
    get(T record)
    Gets the value of the field (specified in the constructor) of the given record.
    org.apache.flink.api.common.typeinfo.TypeInformation<F>
    Gets the TypeInformation for the type of the field.
    abstract T
    set(T record, F fieldValue)
    Sets the field (specified in the constructor) of the given record to the given value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • fieldType

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

    • FieldAccessor

      public FieldAccessor()
  • Method Details

    • 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)