Class PojoTypeInfo<T>
- java.lang.Object
-
- org.apache.flink.api.common.typeinfo.TypeInformation<T>
-
- org.apache.flink.api.common.typeutils.CompositeType<T>
-
- org.apache.flink.api.java.typeutils.PojoTypeInfo<T>
-
- Type Parameters:
T- The type represented by this type information.
- All Implemented Interfaces:
Serializable
@Public public class PojoTypeInfo<T> extends CompositeType<T>
TypeInformation for "Java Beans"-style types. Flink refers to them as POJOs, since the conditions are slightly different from Java Beans. A type is considered a Flink POJO type, if it fulfills the conditions below.- It is a public class, and standalone (not a non-static inner class)
- It has a public no-argument constructor.
- All non-static, non-transient fields in the class (and all superclasses) are either public (and non-final) or have a public getter and a setter method that follows the Java beans naming conventions for getters and setters.
- It is a fixed-length, null-aware composite type with non-deterministic field order. Every field can be null independent of the field's type.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPojoTypeInfo.NamedFlatFieldDescriptor-
Nested classes/interfaces inherited from class org.apache.flink.api.common.typeutils.CompositeType
CompositeType.FlatFieldDescriptor, CompositeType.InvalidFieldReferenceException, CompositeType.TypeComparatorBuilder<T>
-
-
Constructor Summary
Constructors Constructor Description PojoTypeInfo(Class<T> typeClass, List<PojoField> fields)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanEqual(Object obj)Returns true if the given object can be equaled with this object.PojoSerializer<T>createPojoSerializer(ExecutionConfig config)TypeSerializer<T>createSerializer(ExecutionConfig config)Creates a serializer for the type.protected CompositeType.TypeComparatorBuilder<T>createTypeComparatorBuilder()booleanequals(Object obj)intgetArity()Gets the arity of this type - the number of fields without nesting.intgetFieldIndex(String fieldName)Returns the field index of the composite field of the given name.String[]getFieldNames()Returns the names of the composite fields of this type.voidgetFlatFields(String fieldExpression, int offset, List<CompositeType.FlatFieldDescriptor> result)Computes the flat field descriptors for the given field expression with the given offset.PojoFieldgetPojoFieldAt(int pos)intgetTotalFields()Gets the number of logical fields in this type.<X> TypeInformation<X>getTypeAt(int pos)Returns the type of the (unnested) field at the given field position.<X> TypeInformation<X>getTypeAt(String fieldExpression)Returns the type of the (nested) field at the given field expression position.inthashCode()booleanisBasicType()Checks if this type information represents a basic type.booleanisSortKeyType()Checks whether this type can be used as a key for sorting.booleanisTupleType()Checks if this type information represents a Tuple type.StringtoString()-
Methods inherited from class org.apache.flink.api.common.typeutils.CompositeType
createComparator, getFlatFields, getTypeClass, hasDeterministicFieldOrder, hasField, isKeyType
-
Methods inherited from class org.apache.flink.api.common.typeinfo.TypeInformation
getGenericParameters, of, of
-
-
-
-
Method Detail
-
isBasicType
@PublicEvolving public boolean isBasicType()
Description copied from class:TypeInformationChecks if this type information represents a basic type. Basic types are defined inBasicTypeInfoand are primitives, their boxing types, Strings, Date, Void, ...- Specified by:
isBasicTypein classTypeInformation<T>- Returns:
- True, if this type information describes a basic type, false otherwise.
-
isTupleType
@PublicEvolving public boolean isTupleType()
Description copied from class:TypeInformationChecks if this type information represents a Tuple type. Tuple types are subclasses of the Java API tuples.- Specified by:
isTupleTypein classTypeInformation<T>- Returns:
- True, if this type information describes a tuple type, false otherwise.
-
getArity
@PublicEvolving public int getArity()
Description copied from class:TypeInformationGets the arity of this type - the number of fields without nesting.- Specified by:
getArityin classTypeInformation<T>- Returns:
- Gets the number of fields in this type without nesting.
-
getTotalFields
@PublicEvolving public int getTotalFields()
Description copied from class:TypeInformationGets the number of logical fields in this type. This includes its nested and transitively nested fields, in the case of composite types. In the example above, the OuterType type has three fields in total.The total number of fields must be at least 1.
- Specified by:
getTotalFieldsin classTypeInformation<T>- Returns:
- The number of fields in this type, including its sub-fields (for composite types)
-
isSortKeyType
@PublicEvolving public boolean isSortKeyType()
Description copied from class:TypeInformationChecks whether this type can be used as a key for sorting. The order produced by sorting this type must be meaningful.- Overrides:
isSortKeyTypein classCompositeType<T>
-
getFlatFields
@PublicEvolving public void getFlatFields(String fieldExpression, int offset, List<CompositeType.FlatFieldDescriptor> result)
Description copied from class:CompositeTypeComputes the flat field descriptors for the given field expression with the given offset.- Specified by:
getFlatFieldsin classCompositeType<T>- Parameters:
fieldExpression- The field expression for which the FlatFieldDescriptors are computed.offset- The offset to use when computing the positions of the flat fields.result- The list into which all flat field descriptors are inserted.
-
getTypeAt
@PublicEvolving public <X> TypeInformation<X> getTypeAt(String fieldExpression)
Description copied from class:CompositeTypeReturns the type of the (nested) field at the given field expression position. Wildcards are not allowed.- Specified by:
getTypeAtin classCompositeType<T>- Parameters:
fieldExpression- The field expression for which the field of which the type is returned.- Returns:
- The type of the field at the given field expression.
-
getTypeAt
@PublicEvolving public <X> TypeInformation<X> getTypeAt(int pos)
Description copied from class:CompositeTypeReturns the type of the (unnested) field at the given field position.- Specified by:
getTypeAtin classCompositeType<T>- Parameters:
pos- The position of the (unnested) field in this composite type.- Returns:
- The type of the field at the given position.
-
createTypeComparatorBuilder
@PublicEvolving protected CompositeType.TypeComparatorBuilder<T> createTypeComparatorBuilder()
- Specified by:
createTypeComparatorBuilderin classCompositeType<T>
-
getPojoFieldAt
@PublicEvolving public PojoField getPojoFieldAt(int pos)
-
getFieldNames
@PublicEvolving public String[] getFieldNames()
Description copied from class:CompositeTypeReturns the names of the composite fields of this type. The order of the returned array must be consistent with the internal field index ordering.- Specified by:
getFieldNamesin classCompositeType<T>
-
getFieldIndex
@PublicEvolving public int getFieldIndex(String fieldName)
Description copied from class:CompositeTypeReturns the field index of the composite field of the given name.- Specified by:
getFieldIndexin classCompositeType<T>- Returns:
- The field index or -1 if this type does not have a field of the given name.
-
createSerializer
@PublicEvolving public TypeSerializer<T> createSerializer(ExecutionConfig config)
Description copied from class:TypeInformationCreates a serializer for the type. The serializer may use the ExecutionConfig for parameterization.- Specified by:
createSerializerin classTypeInformation<T>- Parameters:
config- The config used to parameterize the serializer.- Returns:
- A serializer for this type.
-
createPojoSerializer
public PojoSerializer<T> createPojoSerializer(ExecutionConfig config)
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classCompositeType<T>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classCompositeType<T>
-
canEqual
public boolean canEqual(Object obj)
Description copied from class:TypeInformationReturns true if the given object can be equaled with this object. If not, it returns false.- Overrides:
canEqualin classCompositeType<T>- Parameters:
obj- Object which wants to take part in the equality relation- Returns:
- true if obj can be equaled with this, otherwise false
-
toString
public String toString()
- Overrides:
toStringin classCompositeType<T>
-
-