You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Stephan Ewen (JIRA)" <ji...@apache.org> on 2016/07/20 11:52:20 UTC

[jira] [Comment Edited] (FLINK-3042) Define a way to let types create their own TypeInformation

    [ https://issues.apache.org/jira/browse/FLINK-3042?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15385721#comment-15385721 ] 

Stephan Ewen edited comment on FLINK-3042 at 7/20/16 11:52 AM:
---------------------------------------------------------------

Slightly more sophisticated, for generic types could be 

{code}
@TypeInfo(MyTypeInfoFactory.class)
public class MyOptionType<T> {
    ....
}

public class MyTypeInfoFactory<T> extends TypeInfoFactory<MyType<T>> {

    public TypeInformation<MyType<T>> createTypeInfo(Map<String, TypeInformation<?>> genericParameters) {
        return new MyTypeInfo(genericParameters.get("T");
    }
}
{code}


was (Author: stephanewen):
Slightly more sophisticated, for generic types could be 

@TypeInfo(MyTypeInfoFactory.class)
public class MyOptionType<T> {
    ....
}

public class MyTypeInfoFactory<T> extends TypeInfoFactory<MyType<T>> {

    public TypeInformation<MyType<T>> createTypeInfo(Map<String, TypeInformation<?>> genericParameters) {
        return new MyTypeInfo(genericParameters.get("T");
    }
}

> 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
>             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)