[
https://issues.apache.org/jira/browse/FLINK-5097?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15683916#comment-15683916
]
ASF GitHub Bot commented on FLINK-5097:
---------------------------------------
Github user greghogan commented on a diff in the pull request:
https://github.com/apache/flink/pull/2842#discussion_r88920404
--- Diff:
flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/TypeExtractorTest.java
---
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.graph.test.operations;
+
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.java.DataSet;
+import org.apache.flink.api.java.ExecutionEnvironment;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.api.java.typeutils.TupleTypeInfo;
+import org.apache.flink.graph.Edge;
+import org.apache.flink.graph.Graph;
+import org.apache.flink.graph.Vertex;
+import org.apache.flink.graph.test.TestGraphUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+
+public class TypeExtractorTest {
+
+ private Graph<Long, Long, Long> inputGraph;
+
+
+ @Before
+ public void setUp() throws Exception {
+ ExecutionEnvironment env =
ExecutionEnvironment.getExecutionEnvironment();
+ DataSet<Vertex<Long, Long>> vertices =
TestGraphUtils.getLongLongVertexData(env);
+ DataSet<Edge<Long, Long>> edges =
TestGraphUtils.getLongLongEdgeData(env);
+ inputGraph = Graph.fromDataSet(vertices, edges, env);
+ }
+
+ public class TestGraphWithGeneric<K> {
+
+ public DataSet<Vertex<K, Tuple2<K, Integer>>>
mapVertices(Graph<K, Long, Long> input) {
+ return input.mapVertices(new
VertexMapper<K>()).getVertices();
+ }
+
+ public DataSet<Edge<K, Tuple2<K, Integer>>> mapEdges(Graph<K,
Long, Long> input) {
+ return input.mapEdges(new EdgeMapper<K>()).getEdges();
+ }
+ }
+
+ @Test
+ public void testMapVerticesType() throws Exception {
+ TestGraphWithGeneric<Long> test = new TestGraphWithGeneric<>();
+
+ // test type extraction in mapVertices
+ DataSet<Vertex<Long, Tuple2<Long, Integer>>> outVertices =
test.mapVertices(inputGraph);
+ Assert.assertEquals(true, (new TupleTypeInfo(Vertex.class,
BasicTypeInfo.LONG_TYPE_INFO,
+ new TupleTypeInfo<Tuple2<Long,
Integer>>(BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO)))
+ .equals(outVertices.getType()));
+ }
+
+ @Test
+ public void testMapEdgesType() throws Exception {
+ TestGraphWithGeneric<Long> test = new TestGraphWithGeneric<>();
+
+ // test type extraction in mapEdges
+ DataSet<Edge<Long, Tuple2<Long, Integer>>> outEdges =
test.mapEdges(inputGraph);
+ Assert.assertEquals(true, (new TupleTypeInfo(Edge.class,
BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO,
+ new TupleTypeInfo<Tuple2<Long,
Integer>>(BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO)))
+ .equals(outEdges.getType()));
+ }
+
+ public static final class VertexMapper<K> implements
MapFunction<Vertex<K, Long>, Tuple2<K, Integer>> {
+
+ private final Tuple2<K, Integer> outTuple = new Tuple2<>();
+
+ @Override
+ public Tuple2<K, Integer> map(Vertex<K, Long> inputVertex)
throws Exception {
+ outTuple.setField(inputVertex.getId(), 0);
+ outTuple.setField(inputVertex.getValue().intValue(),
0);
--- End diff --
This and again below should set field 1? I'm not seeing how this is
compiling since outTuple.f0 is typed to `K`.
> The TypeExtractor is missing input type information in some Graph methods
> -------------------------------------------------------------------------
>
> Key: FLINK-5097
> URL: https://issues.apache.org/jira/browse/FLINK-5097
> Project: Flink
> Issue Type: Bug
> Components: Gelly
> Reporter: Vasia Kalavri
> Assignee: Vasia Kalavri
>
> The TypeExtractor is called without information about the input type in
> {{mapVertices}} and {{mapEdges}} although this information can be easily
> retrieved.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)