use of org.apache.flink.types.NullValue in project flink by apache.
the class GraphCreationWithCsvITCase method testCreateWithOnlyEdgesCsvFile.
@Test
public void testCreateWithOnlyEdgesCsvFile() throws Exception {
/*
* Test with one Csv file one with Edges data. Also tests the configuration method ignoreFistLineEdges()
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
final String fileContent2 = "header\n1,2,ot\n" + "3,2,tt\n" + "3,1,to\n";
final FileInputSplit split2 = createTempFile(fileContent2);
Graph<Long, NullValue, String> graph = Graph.fromCsvReader(split2.getPath().toString(), env).ignoreFirstLineEdges().ignoreCommentsVertices("hi").edgeTypes(Long.class, String.class);
List<Triplet<Long, NullValue, String>> result = graph.getTriplets().collect();
expectedResult = "1,2,(null),(null),ot\n" + "3,2,(null),(null),tt\n" + "3,1,(null),(null),to\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.types.NullValue in project flink by apache.
the class GraphCreationWithCsvITCase method testCsvWithNullEdge.
@Test
public void testCsvWithNullEdge() throws Exception {
/*
Test fromCsvReader with edge and vertex path and nullvalue for edge
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
final String vertexFileContent = "1,one\n" + "2,two\n" + "3,three\n";
final String edgeFileContent = "1,2\n" + "3,2\n" + "3,1\n";
final FileInputSplit split = createTempFile(vertexFileContent);
final FileInputSplit edgeSplit = createTempFile(edgeFileContent);
Graph<Long, String, NullValue> graph = Graph.fromCsvReader(split.getPath().toString(), edgeSplit.getPath().toString(), env).vertexTypes(Long.class, String.class);
List<Triplet<Long, String, NullValue>> result = graph.getTriplets().collect();
expectedResult = "1,2,one,two,(null)\n" + "3,2,three,two,(null)\n" + "3,1,three,one,(null)\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.types.NullValue in project flink by apache.
the class GraphOperationsITCase method testIntersectWithPairs.
@Test
public final void testIntersectWithPairs() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
@SuppressWarnings("unchecked") List<Edge<Long, Long>> edges1 = new ArrayList<>();
edges1.add(new Edge<>(1L, 3L, 12L));
edges1.add(new Edge<>(1L, 3L, 13L));
// output
edges1.add(new Edge<>(1L, 3L, 13L));
// output
edges1.add(new Edge<>(1L, 3L, 13L));
// output
edges1.add(new Edge<>(1L, 3L, 14L));
@SuppressWarnings("unchecked") List<Edge<Long, Long>> edges2 = new ArrayList<>();
// output
edges2.add(new Edge<>(1L, 3L, 13L));
// output
edges2.add(new Edge<>(1L, 3L, 13L));
// output
edges2.add(new Edge<>(1L, 3L, 14L));
Graph<Long, NullValue, Long> graph1 = Graph.fromCollection(edges1, env);
Graph<Long, NullValue, Long> graph2 = Graph.fromCollection(edges2, env);
Graph<Long, NullValue, Long> intersect = graph1.intersect(graph2, false);
List<Vertex<Long, NullValue>> vertices = new ArrayList<>();
List<Edge<Long, Long>> edges = new ArrayList<>();
intersect.getVertices().output(new LocalCollectionOutputFormat<>(vertices));
intersect.getEdges().output(new LocalCollectionOutputFormat<>(edges));
env.execute();
String expectedVertices = "1,(null)\n" + "3,(null)\n";
String expectedEdges = "1,3,13\n" + "1,3,13\n" + "1,3,13\n" + "1,3,13\n" + "1,3,14\n" + "1,3,14";
compareResultAsTuples(vertices, expectedVertices);
compareResultAsTuples(edges, expectedEdges);
}
use of org.apache.flink.types.NullValue in project flink by apache.
the class CoGroupGroupSortITCase method testProgram.
@Override
protected void testProgram() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Tuple2<Long, Long>> input1 = env.fromElements(new Tuple2<Long, Long>(0L, 5L), new Tuple2<Long, Long>(0L, 4L), new Tuple2<Long, Long>(0L, 3L), new Tuple2<Long, Long>(0L, 2L), new Tuple2<Long, Long>(0L, 1L), new Tuple2<Long, Long>(1L, 10L), new Tuple2<Long, Long>(1L, 8L), new Tuple2<Long, Long>(1L, 9L), new Tuple2<Long, Long>(1L, 7L));
DataSet<TestPojo> input2 = env.fromElements(new TestPojo(0L, 10L, 3L), new TestPojo(0L, 8L, 3L), new TestPojo(0L, 10L, 1L), new TestPojo(0L, 9L, 0L), new TestPojo(0L, 8L, 2L), new TestPojo(0L, 8L, 4L), new TestPojo(1L, 10L, 3L), new TestPojo(1L, 8L, 3L), new TestPojo(1L, 10L, 1L), new TestPojo(1L, 9L, 0L), new TestPojo(1L, 8L, 2L), new TestPojo(1L, 8L, 4L));
input1.coGroup(input2).where(1).equalTo("b").sortFirstGroup(0, Order.DESCENDING).sortSecondGroup("c", Order.ASCENDING).sortSecondGroup("a", Order.DESCENDING).with(new ValidatingCoGroup()).output(new DiscardingOutputFormat<NullValue>());
env.execute();
}
Aggregations