Search in sources :

Example 16 with NullValue

use of org.apache.flink.types.NullValue in project flink by apache.

the class EdgeTargetDegreeTest method testWithRMatGraph.

@Test
public void testWithRMatGraph() throws Exception {
    DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> targetDegreeOnTargetId = undirectedRMatGraph.run(new EdgeSourceDegree<LongValue, NullValue, NullValue>());
    Checksum checksumOnTargetId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>().run(targetDegreeOnTargetId).execute();
    assertEquals(20884, checksumOnTargetId.getCount());
    assertEquals(0x000000019d8f0070L, checksumOnTargetId.getChecksum());
    DataSet<Edge<LongValue, Tuple2<NullValue, LongValue>>> targetDegreeOnSourceId = undirectedRMatGraph.run(new EdgeTargetDegree<LongValue, NullValue, NullValue>().setReduceOnSourceId(true));
    Checksum checksumOnSourceId = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, LongValue>>>().run(targetDegreeOnSourceId).execute();
    assertEquals(checksumOnTargetId, checksumOnSourceId);
}
Also used : NullValue(org.apache.flink.types.NullValue) Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum) Tuple2(org.apache.flink.api.java.tuple.Tuple2) LongValue(org.apache.flink.types.LongValue) ChecksumHashCode(org.apache.flink.graph.asm.dataset.ChecksumHashCode) Edge(org.apache.flink.graph.Edge) Test(org.junit.Test)

Example 17 with NullValue

use of org.apache.flink.types.NullValue in project flink by apache.

the class VertexDegreeTest method testWithRMatGraph.

@Test
public void testWithRMatGraph() throws Exception {
    DataSet<Vertex<LongValue, LongValue>> degreeOnSourceId = undirectedRMatGraph.run(new VertexDegree<LongValue, NullValue, NullValue>());
    Checksum checksumOnSourceId = new ChecksumHashCode<Vertex<LongValue, LongValue>>().run(degreeOnSourceId).execute();
    assertEquals(902, checksumOnSourceId.getCount());
    assertEquals(0x0000000000e1fb30L, checksumOnSourceId.getChecksum());
    DataSet<Vertex<LongValue, LongValue>> degreeOnTargetId = undirectedRMatGraph.run(new VertexDegree<LongValue, NullValue, NullValue>().setReduceOnTargetId(true));
    Checksum checksumOnTargetId = new ChecksumHashCode<Vertex<LongValue, LongValue>>().run(degreeOnTargetId).execute();
    assertEquals(checksumOnSourceId, checksumOnTargetId);
}
Also used : Vertex(org.apache.flink.graph.Vertex) NullValue(org.apache.flink.types.NullValue) Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum) LongValue(org.apache.flink.types.LongValue) ChecksumHashCode(org.apache.flink.graph.asm.dataset.ChecksumHashCode) Test(org.junit.Test)

Example 18 with NullValue

use of org.apache.flink.types.NullValue in project flink by apache.

the class MaximumDegreeTest method testWithRMatGraph.

@Test
public void testWithRMatGraph() throws Exception {
    Checksum checksum = undirectedRMatGraph.run(new MaximumDegree<LongValue, NullValue, NullValue>(16)).run(new ChecksumHashCode<LongValue, NullValue, NullValue>()).execute();
    assertEquals(805, checksum.getCount());
    assertEquals(0x0000000008028b43L, checksum.getChecksum());
}
Also used : NullValue(org.apache.flink.types.NullValue) Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum) LongValue(org.apache.flink.types.LongValue) ChecksumHashCode(org.apache.flink.graph.library.metric.ChecksumHashCode) Test(org.junit.Test)

Example 19 with NullValue

use of org.apache.flink.types.NullValue in project flink by apache.

the class DegreesITCase method testGetDegreesWithDisconnectedData.

@Test
public void testGetDegreesWithDisconnectedData() throws Exception {
    /*
		 * Test getDegrees() with disconnected data
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    Graph<Long, NullValue, Long> graph = Graph.fromDataSet(TestGraphUtils.getDisconnectedLongLongEdgeData(env), env);
    DataSet<Tuple2<Long, LongValue>> data = graph.outDegrees();
    List<Tuple2<Long, LongValue>> result = data.collect();
    expectedResult = "1,2\n" + "2,1\n" + "3,0\n" + "4,1\n" + "5,0\n";
    compareResultAsTuples(result, expectedResult);
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) NullValue(org.apache.flink.types.NullValue) Tuple2(org.apache.flink.api.java.tuple.Tuple2) Test(org.junit.Test)

Example 20 with NullValue

use of org.apache.flink.types.NullValue in project flink by apache.

the class FromCollectionITCase method testFromCollectionEdgesNoInitialValue.

@Test
public void testFromCollectionEdgesNoInitialValue() throws Exception {
    /*
         * Test fromCollection(edges) with no initial value for the vertices
         */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    Graph<Long, NullValue, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongEdges(), env);
    DataSet<Vertex<Long, NullValue>> data = graph.getVertices();
    List<Vertex<Long, NullValue>> result = data.collect();
    expectedResult = "1,(null)\n" + "2,(null)\n" + "3,(null)\n" + "4,(null)\n" + "5,(null)\n";
    compareResultAsTuples(result, expectedResult);
}
Also used : Vertex(org.apache.flink.graph.Vertex) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) NullValue(org.apache.flink.types.NullValue) Test(org.junit.Test)

Aggregations

NullValue (org.apache.flink.types.NullValue)49 Test (org.junit.Test)39 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)33 LongValue (org.apache.flink.types.LongValue)23 Edge (org.apache.flink.graph.Edge)18 Vertex (org.apache.flink.graph.Vertex)18 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)15 Checksum (org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum)13 Graph (org.apache.flink.graph.Graph)12 DataSet (org.apache.flink.api.java.DataSet)11 ChecksumHashCode (org.apache.flink.graph.asm.dataset.ChecksumHashCode)11 DiscardingOutputFormat (org.apache.flink.api.java.io.DiscardingOutputFormat)7 JDKRandomGeneratorFactory (org.apache.flink.graph.generator.random.JDKRandomGeneratorFactory)7 NumberFormat (java.text.NumberFormat)6 JobExecutionResult (org.apache.flink.api.common.JobExecutionResult)6 Plan (org.apache.flink.api.common.Plan)6 MapFunction (org.apache.flink.api.common.functions.MapFunction)6 FieldList (org.apache.flink.api.common.operators.util.FieldList)6 ParameterTool (org.apache.flink.api.java.utils.ParameterTool)6 ProgramParametrizationException (org.apache.flink.client.program.ProgramParametrizationException)6