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));
}
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();
}
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());
}
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());
}
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);
}
Aggregations