[
https://issues.apache.org/jira/browse/FLINK-3042?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15473535#comment-15473535
]
ASF GitHub Bot commented on FLINK-3042:
---------------------------------------
Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/2337#discussion_r77984002
--- Diff:
flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
---
@@ -792,12 +832,40 @@ else if (t instanceof Class) {
return null;
}
-
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
private <IN1> TypeInformation<?>
createTypeInfoFromInput(TypeVariable<?> returnTypeVar, ArrayList<Type>
inputTypeHierarchy, Type inType, TypeInformation<IN1> inTypeInfo) {
TypeInformation<?> info = null;
-
+
+ // use a factory to find corresponding type information to type
variable
+ final ArrayList<Type> factoryHierarchy = new
ArrayList<>(inputTypeHierarchy);
+ final TypeInfoFactory<?> factory =
getClosestFactory(factoryHierarchy, inType);
+ if (factory != null) {
+ // the type that defines the factory is last in factory
hierarchy
+ final Type factoryDefiningType =
factoryHierarchy.get(factoryHierarchy.size() - 1);
+ // defining type has generics, the factory need to be
asked for a mapping of subtypes to type information
+ if (factoryDefiningType instanceof ParameterizedType) {
--- End diff --
Yes, because we try to create type information from the input in this
method. This only works if a type variable connects input with output.
`Map<InType<A>, OutType<A>>`
> Define a way to let types create their own TypeInformation
> ----------------------------------------------------------
>
> Key: FLINK-3042
> URL: https://issues.apache.org/jira/browse/FLINK-3042
> Project: Flink
> Issue Type: Improvement
> Components: Core
> Affects Versions: 0.10.0
> Reporter: Stephan Ewen
> Assignee: Timo Walther
> Fix For: 1.0.0
>
>
> Currently, introducing new Types that should have specific TypeInformation
> requires
> - Either integration with the TypeExtractor
> - Or manually constructing the TypeInformation (potentially at every place)
> and using type hints everywhere.
> I propose to add a way to allow classes to create their own TypeInformation
> (like a static method "createTypeInfo()").
> To support generic nested types (like Optional / Either), the type extractor
> would provide a Map of what generic variables map to what types (deduced from
> the input). The class can use that to create the correct nested
> TypeInformation (possibly by calling the TypeExtractor again, passing the Map
> of generic bindings).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)