Search in sources :

Example 1 with EdgeValue

use of org.apache.flink.graph.library.Summarization.EdgeValue in project flink by apache.

the class SummarizationITCase method testWithVertexAndEdgeStringValues.

@Test
public void testWithVertexAndEdgeStringValues() throws Exception {
    ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    Graph<Long, String, String> input = Graph.fromDataSet(SummarizationData.getVertices(env), SummarizationData.getEdges(env), env);
    List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
    List<Edge<Long, EdgeValue<String>>> summarizedEdges = new ArrayList<>();
    Graph<Long, Summarization.VertexValue<String>, EdgeValue<String>> 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) EdgeValue(org.apache.flink.graph.library.Summarization.EdgeValue) Edge(org.apache.flink.graph.Edge) Test(org.junit.Test)

Example 2 with EdgeValue

use of org.apache.flink.graph.library.Summarization.EdgeValue 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)

Example 3 with EdgeValue

use of org.apache.flink.graph.library.Summarization.EdgeValue in project flink by apache.

the class SummarizationITCase method testWithVertexAndAbsentEdgeStringValues.

@Test
public void testWithVertexAndAbsentEdgeStringValues() throws Exception {
    ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    Graph<Long, String, NullValue> input = Graph.fromDataSet(SummarizationData.getVertices(env), SummarizationData.getEdges(env), env).run(new TranslateEdgeValues<>(new ToNullValue<>()));
    List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
    List<Edge<Long, EdgeValue<NullValue>>> summarizedEdges = new ArrayList<>();
    Graph<Long, Summarization.VertexValue<String>, EdgeValue<NullValue>> 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_ABSENT_VALUES, summarizedEdges);
}
Also used : Vertex(org.apache.flink.graph.Vertex) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) ArrayList(java.util.ArrayList) ToNullValue(org.apache.flink.graph.asm.translate.translators.ToNullValue) NullValue(org.apache.flink.types.NullValue) ToNullValue(org.apache.flink.graph.asm.translate.translators.ToNullValue) EdgeValue(org.apache.flink.graph.library.Summarization.EdgeValue) Edge(org.apache.flink.graph.Edge) Test(org.junit.Test)

Aggregations

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