Class CompositeType<T>
- java.lang.Object
-
- org.apache.flink.api.common.typeinfo.TypeInformation<T>
-
- org.apache.flink.api.common.typeutils.CompositeType<T>
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
PojoTypeInfo,TupleTypeInfoBase
@Public public abstract class CompositeType<T> extends TypeInformation<T>
Base type information class for Tuple and Pojo typesThe class is taking care of serialization and comparators for Tuples as well.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCompositeType.FlatFieldDescriptorstatic classCompositeType.InvalidFieldReferenceExceptionprotected static interfaceCompositeType.TypeComparatorBuilder<T>
-
Constructor Summary
Constructors Constructor Description CompositeType(Class<T> typeClass)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancanEqual(Object obj)Returns true if the given object can be equaled with this object.TypeComparator<T>createComparator(int[] logicalKeyFields, boolean[] orders, int logicalFieldOffset, ExecutionConfig config)Generic implementation of the comparator creation.protected abstract CompositeType.TypeComparatorBuilder<T>createTypeComparatorBuilder()booleanequals(Object obj)abstract intgetFieldIndex(String fieldName)Returns the field index of the composite field of the given name.abstract String[]getFieldNames()Returns the names of the composite fields of this type.List<CompositeType.FlatFieldDescriptor>getFlatFields(String fieldExpression)Returns the flat field descriptors for the given field expression.abstract voidgetFlatFields(String fieldExpression, int offset, List<CompositeType.FlatFieldDescriptor> result)Computes the flat field descriptors for the given field expression with the given offset.abstract <X> TypeInformation<X>getTypeAt(int pos)Returns the type of the (unnested) field at the given field position.abstract <X> TypeInformation<X>getTypeAt(String fieldExpression)Returns the type of the (nested) field at the given field expression position.Class<T>getTypeClass()Returns the type class of the composite typebooleanhasDeterministicFieldOrder()True if this type has an inherent ordering of the fields, such that a user can always be sure in which order the fields will be in.booleanhasField(String fieldName)Returns true when this type has a composite field with the given name.inthashCode()booleanisKeyType()Checks whether this type can be used as a key.booleanisSortKeyType()Checks whether this type can be used as a key for sorting.StringtoString()-
Methods inherited from class org.apache.flink.api.common.typeinfo.TypeInformation
createSerializer, getArity, getGenericParameters, getTotalFields, isBasicType, isTupleType, of, of
-
-
-
-
Method Detail
-
getTypeClass
@PublicEvolving public Class<T> getTypeClass()
Returns the type class of the composite type- Specified by:
getTypeClassin classTypeInformation<T>- Returns:
- Type class of the composite type
-
getFlatFields
@PublicEvolving public List<CompositeType.FlatFieldDescriptor> getFlatFields(String fieldExpression)
Returns the flat field descriptors for the given field expression.- Parameters:
fieldExpression- The field expression for which the flat field descriptors are computed.- Returns:
- The list of descriptors for the flat fields which are specified by the field expression.
-
getFlatFields
@PublicEvolving public abstract void getFlatFields(String fieldExpression, int offset, List<CompositeType.FlatFieldDescriptor> result)
Computes the flat field descriptors for the given field expression with the given offset.- 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 abstract <X> TypeInformation<X> getTypeAt(String fieldExpression)
Returns the type of the (nested) field at the given field expression position. Wildcards are not allowed.- 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 abstract <X> TypeInformation<X> getTypeAt(int pos)
Returns the type of the (unnested) field at the given field position.- 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 abstract CompositeType.TypeComparatorBuilder<T> createTypeComparatorBuilder()
-
createComparator
@PublicEvolving public TypeComparator<T> createComparator(int[] logicalKeyFields, boolean[] orders, int logicalFieldOffset, ExecutionConfig config)
Generic implementation of the comparator creation. Composite types are supplying the infrastructure to create the actual comparators- Returns:
- The comparator
-
hasField
@PublicEvolving public boolean hasField(String fieldName)
Returns true when this type has a composite field with the given name.
-
isKeyType
@PublicEvolving public boolean isKeyType()
Description copied from class:TypeInformationChecks whether this type can be used as a key. As a bare minimum, types have to be hashable and comparable to be keys.- Specified by:
isKeyTypein classTypeInformation<T>- Returns:
- True, if the type can be used as a key, false otherwise.
-
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 classTypeInformation<T>
-
getFieldNames
@PublicEvolving public abstract String[] getFieldNames()
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.
-
hasDeterministicFieldOrder
@PublicEvolving public boolean hasDeterministicFieldOrder()
True if this type has an inherent ordering of the fields, such that a user can always be sure in which order the fields will be in. This is true for Tuples and Case Classes. It is not true for Regular Java Objects, since there, the ordering of the fields can be arbitrary.This is used when translating a DataSet or DataStream to an Expression Table, when initially renaming the fields of the underlying type.
-
getFieldIndex
@PublicEvolving public abstract int getFieldIndex(String fieldName)
Returns the field index of the composite field of the given name.- Returns:
- The field index or -1 if this type does not have a field of the given name.
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin classTypeInformation<T>
-
hashCode
public int hashCode()
- Specified by:
hashCodein classTypeInformation<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.- Specified by:
canEqualin classTypeInformation<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()
- Specified by:
toStringin classTypeInformation<T>
-
-