Search in sources :

Example 1 with TranslateVertexValues

use of org.apache.flink.graph.asm.translate.TranslateVertexValues in project flink by apache.

the class SummarizationITCase method testWithVertexAndEdgeLongValues.

@Test
public void testWithVertexAndEdgeLongValues() throws Exception {
    ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    Graph<Long, Long, Long> input = Graph.fromDataSet(SummarizationData.getVertices(env), SummarizationData.getEdges(env), env).run(new TranslateVertexValues<>(new StringToLong())).run(new TranslateEdgeValues<>(new StringToLong()));
    List<Vertex<Long, Summarization.VertexValue<Long>>> summarizedVertices = new ArrayList<>();
    List<Edge<Long, EdgeValue<Long>>> summarizedEdges = new ArrayList<>();
    Graph<Long, Summarization.VertexValue<Long>, EdgeValue<Long>> output = input.run(new Summarization<>());
    output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
    output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));
    env.execute();
    validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
    validateEdges(SummarizationData.EXPECTED_EDGES_WITH_VALUES, summarizedEdges);
}
Also used : Vertex(org.apache.flink.graph.Vertex) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) ArrayList(java.util.ArrayList) TranslateVertexValues(org.apache.flink.graph.asm.translate.TranslateVertexValues) EdgeValue(org.apache.flink.graph.library.Summarization.EdgeValue) Edge(org.apache.flink.graph.Edge) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)1 Edge (org.apache.flink.graph.Edge)1 Vertex (org.apache.flink.graph.Vertex)1 TranslateVertexValues (org.apache.flink.graph.asm.translate.TranslateVertexValues)1 EdgeValue (org.apache.flink.graph.library.Summarization.EdgeValue)1 Test (org.junit.Test)1