Search in sources :

Example 36 with NullValue

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

the class ToNullValueTest method testTranslation.

@Test
public void testTranslation() throws Exception {
    NullValue reuse = NullValue.getInstance();
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new DoubleValue(), reuse));
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new FloatValue(), reuse));
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new IntValue(), reuse));
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new LongValue(), reuse));
    assertEquals(NullValue.getInstance(), new ToNullValue<>().translate(new StringValue(), reuse));
}
Also used : NullValue(org.apache.flink.types.NullValue) DoubleValue(org.apache.flink.types.DoubleValue) LongValue(org.apache.flink.types.LongValue) FloatValue(org.apache.flink.types.FloatValue) StringValue(org.apache.flink.types.StringValue) IntValue(org.apache.flink.types.IntValue) Test(org.junit.Test)

Example 37 with NullValue

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

the class ConnectedComponentsWithRandomisedEdgesITCase method testProgram.

@Override
protected void testProgram() throws Exception {
    ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Long> vertexIds = env.generateSequence(1, NUM_VERTICES);
    DataSet<String> edgeString = env.fromElements(ConnectedComponentsData.getRandomOddEvenEdges(NUM_EDGES, NUM_VERTICES, SEED).split("\n"));
    DataSet<Edge<Long, NullValue>> edges = edgeString.map(new EdgeParser());
    DataSet<Vertex<Long, Long>> initialVertices = vertexIds.map(new IdAssigner());
    Graph<Long, Long, NullValue> graph = Graph.fromDataSet(initialVertices, edges, env);
    DataSet<Vertex<Long, Long>> result = graph.run(new ConnectedComponents<Long, Long, NullValue>(100));
    result.writeAsCsv(resultPath, "\n", " ");
    env.execute();
}
Also used : Vertex(org.apache.flink.graph.Vertex) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) NullValue(org.apache.flink.types.NullValue) Edge(org.apache.flink.graph.Edge)

Example 38 with NullValue

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

the class LocalClusteringCoefficientTest method testRMatGraph.

@Test
public void testRMatGraph() throws Exception {
    DataSet<Result<LongValue>> cc = undirectedRMatGraph.run(new LocalClusteringCoefficient<LongValue, NullValue, NullValue>());
    Checksum checksum = new ChecksumHashCode<Result<LongValue>>().run(cc).execute();
    assertEquals(902, checksum.getCount());
    assertEquals(0x000001cab2d3677bL, 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.asm.dataset.ChecksumHashCode) Result(org.apache.flink.graph.library.clustering.undirected.LocalClusteringCoefficient.Result) Test(org.junit.Test)

Example 39 with NullValue

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

the class TriangleListingTest method testCompleteGraph.

@Test
public void testCompleteGraph() throws Exception {
    long expectedDegree = completeGraphVertexCount - 1;
    long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3;
    DataSet<Result<LongValue>> tl = completeGraph.run(new TriangleListing<LongValue, NullValue, NullValue>());
    Checksum checksum = new ChecksumHashCode<Result<LongValue>>().run(tl).execute();
    assertEquals(expectedCount, checksum.getCount());
}
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.asm.dataset.ChecksumHashCode) Result(org.apache.flink.graph.library.clustering.undirected.TriangleListing.Result) Test(org.junit.Test)

Example 40 with NullValue

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

the class GraphCreationITCase method testFromTuple2WithMapper.

@Test
public void testFromTuple2WithMapper() throws Exception {
    /*
		 * Test graph creation with fromTuple2DataSet with vertex initializer
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    DataSet<Tuple2<Long, Long>> edges = TestGraphUtils.getLongLongTuple2Data(env);
    Graph<Long, String, NullValue> graph = Graph.fromTuple2DataSet(edges, new BooMapper(), env);
    List<Vertex<Long, String>> result = graph.getVertices().collect();
    expectedResult = "1,boo\n" + "2,boo\n" + "3,boo\n" + "4,boo\n" + "6,boo\n" + "10,boo\n" + "20,boo\n" + "30,boo\n" + "40,boo\n" + "60,boo\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) Tuple2(org.apache.flink.api.java.tuple.Tuple2) 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