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

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

Github user zentol commented on the pull request:

    https://github.com/apache/flink/pull/1045#issuecomment-134203619
  
    InvalidTypesException (from here on abbreviated as ITE) is no longer 
unchecked.
    
    For this to work i had to make changes in surprisingly many classes so 
let's break it down:
    
    * In general, InvalidProgramExceptions are now thrown for unrecoverable 
conditions, where previously an ITE would be thrown..
    
    * TypeExtractor methods that return a TypeInformation will never throw an 
ITE and instead return a MissingTypeInfo if it is allowed, otherwise an 
InvalidProgramException.
    * One public TypeExtractor method now throws an ITE, which is 
getParameterType(). This method is heavily used in the TypeExtractor itself as 
well, so i didn't see a way to fix this in a non API breaking way that doesn't 
rely yet again on unchecked exceptions.
     * affects hadoop-compatibility functions, which now catch them
    
    * A few OperatorClasses catched ITE's in returns(TypeInformation ...) and 
then manually created a MissingTypeInfo. This now happens in the TypeExtractor 
directly.
    
    * TypeInformation classes threw an ITE in getInfoFor(Class ...) if the 
given class didn't match the TypeInformation class. These have been changed to 
IllegalArgumentExceptions.
    
    * DataSet/DataStream threw an ITE in getType() if the type was a 
MissingTypeInfo, changed to InvalidProgramException.
     * similiar issue in StreamExecutionEnvironment


> Manual type information via "returns" fails in DataSet API
> ----------------------------------------------------------
>
>                 Key: FLINK-2557
>                 URL: https://issues.apache.org/jira/browse/FLINK-2557
>             Project: Flink
>          Issue Type: Bug
>          Components: Java API
>            Reporter: Matthias J. Sax
>            Assignee: Chesnay Schepler
>
> I changed the WordCount example as below and get an exception:
> Tokenizer is change to this (removed generics and added cast to String):
> {code:java}
> public static final class Tokenizer implements FlatMapFunction {
>       public void flatMap(Object value, Collector out) {
>               String[] tokens = ((String) value).toLowerCase().split("\\W+");
>               for (String token : tokens) {
>                       if (token.length() > 0) {
>                               out.collect(new Tuple2<String, Integer>(token, 
> 1));
>                       }
>               }
>       }
> }
> {code}
> I added call to "returns(....)" here:
> {code:java}
> DataSet<Tuple2<String, Integer>> counts =
>       text.flatMap(new Tokenizer()).returns("Tuple2<String,Integer>")
>       .groupBy(0).sum(1);
> {code}
> The exception is:
> {noformat}
> Exception in thread "main" java.lang.IllegalArgumentException: The types of 
> the interface org.apache.flink.api.common.functions.FlatMapFunction could not 
> be inferred. Support for synthetic interfaces, lambdas, and generic types is 
> limited at this point.
>       at 
> org.apache.flink.api.java.typeutils.TypeExtractor.getParameterType(TypeExtractor.java:686)
>       at 
> org.apache.flink.api.java.typeutils.TypeExtractor.getParameterTypeFromGenericType(TypeExtractor.java:710)
>       at 
> org.apache.flink.api.java.typeutils.TypeExtractor.getParameterType(TypeExtractor.java:673)
>       at 
> org.apache.flink.api.java.typeutils.TypeExtractor.privateCreateTypeInfo(TypeExtractor.java:365)
>       at 
> org.apache.flink.api.java.typeutils.TypeExtractor.getUnaryOperatorReturnType(TypeExtractor.java:279)
>       at 
> org.apache.flink.api.java.typeutils.TypeExtractor.getFlatMapReturnTypes(TypeExtractor.java:120)
>       at org.apache.flink.api.java.DataSet.flatMap(DataSet.java:262)
>       at 
> org.apache.flink.examples.java.wordcount.WordCount.main(WordCount.java:69)
> {noformat}
> Fix:
> This should not immediately fail, but also only give a "MissingTypeInfo" so 
> that type hints would work.
> The error message is also wrong, btw: It should state that raw types are not 
> supported.



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

Reply via email to