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

Aljoscha Krettek commented on FLINK-1962:
-----------------------------------------

Oh my, the gift that keeps on giving. Now the problem is, that the 
TypeExtractor (that is usually used for Java stuff) that is used in 
Graph.mapVertices() (Graph.java) to extract the types of the mapVertices 
function cannot properly extract the types from a Scala Mapper.

In Graph.java (line 351), if I change it to this:
{code}
String callLocation = Utils.getCallLocationName();
TypeInformation<NV> valueType = TypeExtractor.getMapReturnTypes(mapper, 
vertices.getType(), callLocation, false);
{code}

Then the code for the syntactic sugar works if I change the code in Graph.scala 
(line 39):
{code}
val mapper: MapFunction[Vertex[K, VV], NV] = new MapFunction[Vertex[K, VV], NV] 
with ResultTypeQueryable[NV] {
            val cleanFun = clean(fun)

            def map(in: Vertex[K, VV]): NV = cleanFun(in)

          override def getProducedType: TypeInformation[NV] = 
createTypeInformation[NV]
 }
{code}

This ResultTypeQueryable allows a user function to directly announce the 
TypeInformation that it returns. This is only used, however, if the correct 
TypeExtractor method is used, such as TypeExtractor.getMapReturnTypes().

Here I did the changes that make it work for the syntactic sugar but break it 
for the regular Mapper: https://github.com/aljoscha/flink/tree/scala-gelly

Please let me know if you need a more thorough explanation. This is tricky (and 
annoying) stuff.

> Add Gelly Scala API
> -------------------
>
>                 Key: FLINK-1962
>                 URL: https://issues.apache.org/jira/browse/FLINK-1962
>             Project: Flink
>          Issue Type: Task
>          Components: Gelly, Scala API
>    Affects Versions: 0.9
>            Reporter: Vasia Kalavri
>




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

Reply via email to