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
- Direct Known Subclasses:
AvroTypeInfo
@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 class
PojoTypeInfo.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 boolean
canEqual(Object obj)
Returns true if the given object can be equaled with this object.PojoSerializer<T>
createPojoSerializer(SerializerConfig config)
TypeSerializer<T>
createSerializer(SerializerConfig config)
Creates a serializer for the type.protected CompositeType.TypeComparatorBuilder<T>
createTypeComparatorBuilder()
boolean
equals(Object obj)
int
getArity()
Gets the arity of this type - the number of fields without nesting.int
getFieldIndex(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.void
getFlatFields(String fieldExpression, int offset, List<CompositeType.FlatFieldDescriptor> result)
Computes the flat field descriptors for the given field expression with the given offset.PojoField
getPojoFieldAt(int pos)
int
getTotalFields()
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.int
hashCode()
boolean
isBasicType()
Checks if this type information represents a basic type.boolean
isSortKeyType()
Checks whether this type can be used as a key for sorting.boolean
isTupleType()
Checks if this type information represents a Tuple type.String
toString()
-
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
-
-
-
-
Constructor Detail
-
PojoTypeInfo
@PublicEvolving public PojoTypeInfo(Class<T> typeClass, List<PojoField> fields)
-
-
Method Detail
-
isBasicType
@PublicEvolving public boolean isBasicType()
Description copied from class:TypeInformation
Checks if this type information represents a basic type. Basic types are defined inBasicTypeInfo
and are primitives, their boxing types, Strings, Date, Void, ...- Specified by:
isBasicType
in classTypeInformation<T>
- Returns:
- True, if this type information describes a basic type, false otherwise.
-
isTupleType
@PublicEvolving public boolean isTupleType()
Description copied from class:TypeInformation
Checks if this type information represents a Tuple type. Tuple types are subclasses of the Java API tuples.- Specified by:
isTupleType
in classTypeInformation<T>
- Returns:
- True, if this type information describes a tuple type, false otherwise.
-
getArity
@PublicEvolving public int getArity()
Description copied from class:TypeInformation
Gets the arity of this type - the number of fields without nesting.- Specified by:
getArity
in classTypeInformation<T>
- Returns:
- Gets the number of fields in this type without nesting.
-
getTotalFields
@PublicEvolving public int getTotalFields()
Description copied from class:TypeInformation
Gets 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:
getTotalFields
in 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:TypeInformation
Checks whether this type can be used as a key for sorting. The order produced by sorting this type must be meaningful.- Overrides:
isSortKeyType
in classCompositeType<T>
-
getFlatFields
@PublicEvolving public void getFlatFields(String fieldExpression, int offset, List<CompositeType.FlatFieldDescriptor> result)
Description copied from class:CompositeType
Computes the flat field descriptors for the given field expression with the given offset.- Specified by:
getFlatFields
in 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:CompositeType
Returns the type of the (nested) field at the given field expression position. Wildcards are not allowed.- Specified by:
getTypeAt
in 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:CompositeType
Returns the type of the (unnested) field at the given field position.- Specified by:
getTypeAt
in 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:
createTypeComparatorBuilder
in classCompositeType<T>
-
getPojoFieldAt
@PublicEvolving public PojoField getPojoFieldAt(int pos)
-
getFieldNames
@PublicEvolving public String[] getFieldNames()
Description copied from class:CompositeType
Returns 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:
getFieldNames
in classCompositeType<T>
-
getFieldIndex
@PublicEvolving public int getFieldIndex(String fieldName)
Description copied from class:CompositeType
Returns the field index of the composite field of the given name.- Specified by:
getFieldIndex
in 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(SerializerConfig config)
Description copied from class:TypeInformation
Creates a serializer for the type. The serializer may use the ExecutionConfig for parameterization.- Specified by:
createSerializer
in classTypeInformation<T>
- Parameters:
config
- The config used to parameterize the serializer.- Returns:
- A serializer for this type.
-
createPojoSerializer
public PojoSerializer<T> createPojoSerializer(SerializerConfig config)
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classCompositeType<T>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classCompositeType<T>
-
canEqual
public boolean canEqual(Object obj)
Description copied from class:TypeInformation
Returns true if the given object can be equaled with this object. If not, it returns false.- Overrides:
canEqual
in 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:
toString
in classCompositeType<T>
-
-