You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Timo Walther (JIRA)" <ji...@apache.org> on 2016/03/02 15:12:18 UTC

[jira] [Comment Edited] (FLINK-3563) .returns() doesn't compile when using .map() with a custom MapFunction

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

Timo Walther edited comment on FLINK-3563 at 3/2/16 2:11 PM:
-------------------------------------------------------------

As far as I know, mixing of Scala and Java API is not supported. So it is possible that the type extraction fails in this example. 

I tested this which runs fine:
{code}
text.map(new MapFunction<String, java.util.Map>() {
    @Override
    public Map map(String value) throws Exception {
      return new HashMap(2);
    }
}).print();
{code}

Explicit casts are ok in this case.

[~aljoscha] I think we can close this issue, what do you think?


was (Author: twalthr):
As far as I know, mixing of Scala and Java API is not supported. So it is possible that the type extraction fails in this example. 

I tested this which runs fine:
{code}
text.map(new MapFunction<String, java.util.Map>() {
    @Override
    public Map map(String value) throws Exception {
      return new HashMap(2);
    }
}).print();
{code}

Explicit casts is ok in this case.

[~aljoscha] I think we can close this issue, what do you think?

> .returns() doesn't compile when using .map() with a custom MapFunction
> ----------------------------------------------------------------------
>
>                 Key: FLINK-3563
>                 URL: https://issues.apache.org/jira/browse/FLINK-3563
>             Project: Flink
>          Issue Type: Bug
>          Components: Type Serialization System
>    Affects Versions: 0.10.1
>            Reporter: Simone Robutti
>            Priority: Minor
>
> Defined a DummyMapFunction that goes from a java Map to another java Map like this:
> {code:title=DummyMapFunction.scalaborderStyle=solid}
> class DummyMapFunction() extends MapFunction[java.util.Map[String, Any], java.util.Map[FieldName, Any]] {
>   override def map(input: java.util.Map[String, Any]): java.util.Map[FieldName, Any] = {
>     val result: java.util.Map[FieldName, Any] = new java.util.HashMap[FieldName, Any]()
>     result
>   }
> }
> {code}
> and trying to use it with a map:
> {code:title=Main.java}
> DummyMapFunction operator = new DummyMapFunction();
> DataSource<Map<String, Object>> dataset = env.fromCollection(input);
>         List<java.util.Map<FieldName, Object>> collectedResult = dataset.map(operator).returns(java.util.Map.class).collect();
> {code}
> the returns call doesn't compile because it can't resolve the returns method with the parameter.
> But if insted of creating a variable of type DummyMapFunction I create a
> {code}
> MapFunction operator=new DummyMapFuction();
> {code}
> or I explicitly cast the variable to a MapFunction, it compiles and work flawlessly.
> This is a trick that works but I think is an unexpected behaviour. 



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