T
- The type represented by this type information.@Public public abstract class TypeInformation<T> extends Object implements Serializable
The type information also bridges between the programming languages object model and a logical flat schema. It maps fields from the types to to columns (fields) in a flat schema. Not all fields from a type are mapped to a separate fields in the flat schema and often, entire types are mapped to one field. It is important to notice that the schema must hold for all instances of a type. For that reason, elements in lists and arrays are not assigned to individual fields, but the lists and arrays are considered to be one field in total, to account for different lengths in the arrays.
To represent this properly, each type has an arity (the number of fields it contains directly), and a total number of fields (number of fields in the entire schema of this type, including nested types).
Consider the example below:
public class InnerType {
public int id;
public String text;
}
public class OuterType {
public long timestamp;
public InnerType nestedType;
}
The types "id", "text", and "timestamp" are basic types that take up one field. The "InnerType"
has an arity of two, and also two fields totally. The "OuterType" has an arity of two fields,
and a total number of three fields ( it contains "id", "text", and "timestamp" through recursive flattening).Constructor and Description |
---|
TypeInformation() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
canEqual(Object obj)
Returns true if the given object can be equaled with this object.
|
abstract TypeSerializer<T> |
createSerializer(ExecutionConfig config)
Creates a serializer for the type.
|
abstract boolean |
equals(Object obj) |
abstract int |
getArity()
Gets the arity of this type - the number of fields without nesting.
|
List<TypeInformation<?>> |
getGenericParameters()
Returns the generic parameters of this type.
|
abstract int |
getTotalFields()
Gets the number of logical fields in this type.
|
abstract Class<T> |
getTypeClass()
Gets the class of the type represented by this type information.
|
abstract int |
hashCode() |
abstract boolean |
isBasicType()
Checks if this type information represents a basic type.
|
abstract boolean |
isKeyType()
Checks whether this type can be used as a key.
|
boolean |
isSortKeyType()
Checks whether this type can be used as a key for sorting.
|
abstract boolean |
isTupleType()
Checks if this type information represents a Tuple type.
|
static <T> TypeInformation<T> |
of(Class<T> typeClass)
Creates a TypeInformation for the type described by the given class.
|
static <T> TypeInformation<T> |
of(TypeHint<T> typeHint)
Creates a TypeInformation for a generic type via a utility "type hint".
|
abstract String |
toString() |
@PublicEvolving public abstract boolean isBasicType()
BasicTypeInfo
and are primitives, their boxing types,
Strings, Date, Void, ...@PublicEvolving public abstract boolean isTupleType()
@PublicEvolving public abstract int getArity()
@PublicEvolving public abstract int getTotalFields()
@PublicEvolving public abstract Class<T> getTypeClass()
@PublicEvolving public List<TypeInformation<?>> getGenericParameters()
@PublicEvolving public abstract boolean isKeyType()
@PublicEvolving public boolean isSortKeyType()
@PublicEvolving public abstract TypeSerializer<T> createSerializer(ExecutionConfig config)
config
- The config used to parameterize the serializer.public abstract boolean canEqual(Object obj)
obj
- Object which wants to take part in the equality relationpublic static <T> TypeInformation<T> of(Class<T> typeClass)
This method only works for non-generic types. For generic types, use the
of(TypeHint)
method.
T
- The generic type.typeClass
- The class of the type.public static <T> TypeInformation<T> of(TypeHint<T> typeHint)
TypeInformation<Tuple2<String, Long>> info = TypeInformation.of(new TypeHint<Tuple2<String, Long>>(){});
T
- The generic type.typeHint
- The hint for the generic type.Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.