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

ASF GitHub Bot commented on FLINK-2788:
---------------------------------------

GitHub user StephanEwen opened a pull request:

    https://github.com/apache/flink/pull/1744

    [FLINK-2788] [apis] Add TypeHint class to allow type-safe generic type 
parsing

    This adds the `TypeHint` as a type-safe way to create `TypeInformation` for 
generic types. I think it should gradually replace the `TypeInfoParser`.
    
    Generic type infos can be created via
    ```java
    TypeInformation<Tuple2<String, Double>> info = TypeInformation.of(new 
TypeHint<Tuple2<String, Double>>() {});
    ```
    This creates an inline class that captures the generic parameters, and 
fetches them via the TypeExtractor.
    
    *This pull request is in preparation for improving the streaming example.*

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/StephanEwen/incubator-flink typehint

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/1744.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1744
    
----
commit c4957ce198935a390e838ca74a610108af122ad8
Author: Stephan Ewen <[email protected]>
Date:   2016-02-29T18:24:34Z

    [FLINK-2788] [apis] Add TypeHint class to allow type-safe generic type 
parsing

----


> Add type hint with TypeExtactor call on Hint Type
> -------------------------------------------------
>
>                 Key: FLINK-2788
>                 URL: https://issues.apache.org/jira/browse/FLINK-2788
>             Project: Flink
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 0.10.0
>            Reporter: Stephan Ewen
>            Assignee: Stephan Ewen
>             Fix For: 1.0.0
>
>
> As per discussion with [~aljoscha]
> A very good and type safe way to supply type hints would be the following:
> Define a hint class that takes a generic parameter.
> {code}
> public abstract class TypeHint<T> {}
> {code}
> The hints would have the following method:
> {code}
> public DataSet<T> returns(TypeHint<T> hint);
> {code}
> It would be used like this:
> {code}
> DataSet<Sting> data = ...;
> data
>   .flatMap( (String str, Collector<Integer> out) -> out.collect(str.length()) 
> )
>   .returns( new TypeHint<Integer>() {})
> {code}
> This would create an inline subclass of the hint, from which the type could 
> be extracted. The generics would ensure that it is typesafe.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to