Java Code Examples for org.apache.flink.graph.Graph#joinWithEdgesOnSource()
The following examples show how to use
org.apache.flink.graph.Graph#joinWithEdgesOnSource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JoinWithEdgesITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testOnSourceWithCustom() throws Exception { /* * Test joinWithEdgesOnSource with a DataSet containing custom parametrised type input values */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(TestGraphUtils.getLongCustomTuple2SourceData(env), new CustomValueMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,10\n" + "1,3,10\n" + "2,3,30\n" + "3,4,40\n" + "3,5,40\n" + "4,5,45\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 2
Source File: JoinWithEdgesITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testOnSourceWithCustom() throws Exception { /* * Test joinWithEdgesOnSource with a DataSet containing custom parametrised type input values */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(TestGraphUtils.getLongCustomTuple2SourceData(env), new CustomValueMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,10\n" + "1,3,10\n" + "2,3,30\n" + "3,4,40\n" + "3,5,40\n" + "4,5,45\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 3
Source File: JoinWithEdgesITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOnSourceWithLessElements() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet passed as a parameter containing * less elements than the edge DataSet, but of the same type */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(graph.getEdges().first(3) .map(new ProjectSourceAndValueMapper()), new AddValuesMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,24\n" + "1,3,25\n" + "2,3,46\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 4
Source File: JoinWithEdgesITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOnSourceWithNoCommonKeys() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet containing different keys than the edge DataSet * - the iterator becomes empty. */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(TestGraphUtils.getLongLongTuple2SourceData(env), new DoubleValueMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,20\n" + "1,3,20\n" + "2,3,60\n" + "3,4,80\n" + "3,5,80\n" + "4,5,120\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 5
Source File: JoinWithEdgesITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOnSourceWithDifferentType() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet passed as a parameter containing * less elements than the edge DataSet and of a different type(Boolean) */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(graph.getEdges().first(3) .map(new ProjectSourceWithTrueMapper()), new DoubleIfTrueMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,24\n" + "1,3,26\n" + "2,3,46\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 6
Source File: JoinWithEdgesITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOnSourceWithLessElements() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet passed as a parameter containing * less elements than the edge DataSet, but of the same type */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(graph.getEdges().first(3) .map(new ProjectSourceAndValueMapper()), new AddValuesMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,24\n" + "1,3,25\n" + "2,3,46\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 7
Source File: JoinWithEdgesITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithEdgesOnSource() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet parameter identical * to the edge DataSet */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(graph.getEdges() .map(new ProjectSourceAndValueMapper()), new AddValuesMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,24\n" + "1,3,25\n" + "2,3,46\n" + "3,4,68\n" + "3,5,69\n" + "4,5,90\n" + "5,1,102\n"; compareResultAsTuples(result, expectedResult); }
Example 8
Source File: PageRank.java From flink with Apache License 2.0 | 5 votes |
@Override public DataSet<Vertex<K, Double>> run(Graph<K, Double, Double> network) throws Exception { DataSet<Tuple2<K, LongValue>> vertexOutDegrees = network.outDegrees(); Graph<K, Double, Double> networkWithWeights = network .joinWithEdgesOnSource(vertexOutDegrees, new InitWeights()); ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); parameters.setOptNumVertices(true); return networkWithWeights.runScatterGatherIteration(new RankMessenger<>(), new VertexRankUpdater<>(beta), maxIterations, parameters) .getVertices(); }
Example 9
Source File: GSAPageRank.java From flink with Apache License 2.0 | 5 votes |
@Override public DataSet<Vertex<K, Double>> run(Graph<K, Double, Double> network) throws Exception { DataSet<Tuple2<K, LongValue>> vertexOutDegrees = network.outDegrees(); Graph<K, Double, Double> networkWithWeights = network .joinWithEdgesOnSource(vertexOutDegrees, new InitWeights()); GSAConfiguration parameters = new GSAConfiguration(); parameters.setOptNumVertices(true); return networkWithWeights.runGatherSumApplyIteration(new GatherRanks(), new SumRanks(), new UpdateRanks<>(beta), maxIterations, parameters) .getVertices(); }
Example 10
Source File: JoinWithEdgesITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOnSourceWithNoCommonKeys() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet containing different keys than the edge DataSet * - the iterator becomes empty. */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(TestGraphUtils.getLongLongTuple2SourceData(env), new DoubleValueMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,20\n" + "1,3,20\n" + "2,3,60\n" + "3,4,80\n" + "3,5,80\n" + "4,5,120\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 11
Source File: JoinWithEdgesITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOnSourceWithDifferentType() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet passed as a parameter containing * less elements than the edge DataSet and of a different type(Boolean) */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(graph.getEdges().first(3) .map(new ProjectSourceWithTrueMapper()), new DoubleIfTrueMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,24\n" + "1,3,26\n" + "2,3,46\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 12
Source File: GSAPageRank.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public DataSet<Vertex<K, Double>> run(Graph<K, Double, Double> network) throws Exception { DataSet<Tuple2<K, LongValue>> vertexOutDegrees = network.outDegrees(); Graph<K, Double, Double> networkWithWeights = network .joinWithEdgesOnSource(vertexOutDegrees, new InitWeights()); GSAConfiguration parameters = new GSAConfiguration(); parameters.setOptNumVertices(true); return networkWithWeights.runGatherSumApplyIteration(new GatherRanks(), new SumRanks(), new UpdateRanks<>(beta), maxIterations, parameters) .getVertices(); }
Example 13
Source File: JoinWithEdgesITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithEdgesOnSource() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet parameter identical * to the edge DataSet */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(graph.getEdges() .map(new ProjectSourceAndValueMapper()), new AddValuesMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,24\n" + "1,3,25\n" + "2,3,46\n" + "3,4,68\n" + "3,5,69\n" + "4,5,90\n" + "5,1,102\n"; compareResultAsTuples(result, expectedResult); }
Example 14
Source File: PageRank.java From flink with Apache License 2.0 | 5 votes |
@Override public DataSet<Vertex<K, Double>> run(Graph<K, Double, Double> network) throws Exception { DataSet<Tuple2<K, LongValue>> vertexOutDegrees = network.outDegrees(); Graph<K, Double, Double> networkWithWeights = network .joinWithEdgesOnSource(vertexOutDegrees, new InitWeights()); ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); parameters.setOptNumVertices(true); return networkWithWeights.runScatterGatherIteration(new RankMessenger<>(), new VertexRankUpdater<>(beta), maxIterations, parameters) .getVertices(); }
Example 15
Source File: GSAPageRank.java From flink with Apache License 2.0 | 5 votes |
@Override public DataSet<Vertex<K, Double>> run(Graph<K, Double, Double> network) throws Exception { DataSet<Tuple2<K, LongValue>> vertexOutDegrees = network.outDegrees(); Graph<K, Double, Double> networkWithWeights = network .joinWithEdgesOnSource(vertexOutDegrees, new InitWeights()); GSAConfiguration parameters = new GSAConfiguration(); parameters.setOptNumVertices(true); return networkWithWeights.runGatherSumApplyIteration(new GatherRanks(), new SumRanks(), new UpdateRanks<>(beta), maxIterations, parameters) .getVertices(); }
Example 16
Source File: JoinWithEdgesITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testOnSourceWithNoCommonKeys() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet containing different keys than the edge DataSet * - the iterator becomes empty. */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(TestGraphUtils.getLongLongTuple2SourceData(env), new DoubleValueMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,20\n" + "1,3,20\n" + "2,3,60\n" + "3,4,80\n" + "3,5,80\n" + "4,5,120\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 17
Source File: JoinWithEdgesITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testOnSourceWithDifferentType() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet passed as a parameter containing * less elements than the edge DataSet and of a different type(Boolean) */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(graph.getEdges().first(3) .map(new ProjectSourceWithTrueMapper()), new DoubleIfTrueMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,24\n" + "1,3,26\n" + "2,3,46\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 18
Source File: JoinWithEdgesITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testOnSourceWithLessElements() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet passed as a parameter containing * less elements than the edge DataSet, but of the same type */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(graph.getEdges().first(3) .map(new ProjectSourceAndValueMapper()), new AddValuesMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,24\n" + "1,3,25\n" + "2,3,46\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n"; compareResultAsTuples(result, expectedResult); }
Example 19
Source File: JoinWithEdgesITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWithEdgesOnSource() throws Exception { /* * Test joinWithEdgesOnSource with the input DataSet parameter identical * to the edge DataSet */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(graph.getEdges() .map(new ProjectSourceAndValueMapper()), new AddValuesMapper()); DataSet<Edge<Long, Long>> data = res.getEdges(); List<Edge<Long, Long>> result = data.collect(); expectedResult = "1,2,24\n" + "1,3,25\n" + "2,3,46\n" + "3,4,68\n" + "3,5,69\n" + "4,5,90\n" + "5,1,102\n"; compareResultAsTuples(result, expectedResult); }
Example 20
Source File: PageRank.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public DataSet<Vertex<K, Double>> run(Graph<K, Double, Double> network) throws Exception { DataSet<Tuple2<K, LongValue>> vertexOutDegrees = network.outDegrees(); Graph<K, Double, Double> networkWithWeights = network .joinWithEdgesOnSource(vertexOutDegrees, new InitWeights()); ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); parameters.setOptNumVertices(true); return networkWithWeights.runScatterGatherIteration(new RankMessenger<>(), new VertexRankUpdater<>(beta), maxIterations, parameters) .getVertices(); }