@Test public void testDefaultName() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<String> strs = env.fromCollection(Arrays.asList("a", "b")); // WARNING: The test will fail if this line is being moved down in the file (the line-number is hard-coded) strs.filter(new FilterFunction<String>() { private static final long serialVersionUID = 1L; @Override public boolean filter(String value) throws Exception { return value.equals("a"); } }).output(new DiscardingOutputFormat<String>()); Plan plan = env.createProgramPlan(); testForName("Filter at testDefaultName(NamesTest.java:55)", plan); }
@Test public void testGivenName() { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<String> strs = env.fromCollection(Arrays.asList("a", "b")); strs.filter(new FilterFunction<String>() { private static final long serialVersionUID = 1L; @Override public boolean filter(String value) throws Exception { return value.equals("a"); } }).name("GivenName").output(new DiscardingOutputFormat<String>()); Plan plan = env.createProgramPlan(); testForName("GivenName", plan); }
.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());
.output(new DiscardingOutputFormat<Integer>());
.output(new DiscardingOutputFormat<Tuple2<Long, Long>>()).name("sink1");
@Test public void testIfContextIsSet() throws Exception { DataSet<Integer> elements = getExecutionEnvironment().fromElements(1, 2, 3, 4, 5); TestRichCombinableFilters filter1 = new TestRichCombinableFilters(); TestRichCombinableFilters filter2 = new TestRichCombinableFilters(); Configuration configuration = new Configuration(); configuration.setInteger(TestRichCombinableFilters.KEY, 2); List<Integer> result = new ArrayList<>(); elements.filter(new And<>(filter1, filter2)) .withParameters(configuration) .output(new LocalCollectionOutputFormat<>(result)); getExecutionEnvironment().execute(); assertEquals(1, result.size()); assertEquals(2, result.get(0).intValue()); }
extractedGraph.getVertices() .filter(new LabelIsIn<>("Person", "City")) .output(new LocalCollectionOutputFormat<>(vertices));
/** * Tests whether list properties are extracted correctly. * * @throws Exception If collect doesn't work as expected. */ @Test public void listPropertyTest() throws Exception { VertexFactory vf = getConfig().getVertexFactory(); Vertex v1 = vf.createVertex("foo"); v1.setProperty("a", PropertyValue.create(Arrays.asList(PropertyValue.create("m"), PropertyValue.create("n")))); Vertex v2 = vf.createVertex("foo"); v2.setProperty("a", PropertyValue.create(Arrays.asList(PropertyValue.create("x"), PropertyValue.create("y"), PropertyValue.create("z")))); LogicalGraph input = getConfig().getLogicalGraphFactory().fromCollections(Arrays.asList(v1, v2), Collections.emptyList()); ExtractPropertyFromVertex ext = new ExtractPropertyFromVertex("foo", "a", "A", "key"); LogicalGraph output = input.callForGraph(ext); List<Vertex> createdVertices = new ArrayList<>(); output.getVertices() .filter(new ByLabel<>("A")) .output(new LocalCollectionOutputFormat<>(createdVertices)); input.getConfig().getExecutionEnvironment().execute(); ArrayList<String> properties = new ArrayList<>(); createdVertices.forEach(v -> properties.add(v.getPropertyValue("key").getString())); Assert.assertTrue(properties.containsAll(Arrays.asList("m", "n", "x", "y", "z"))); }
invertedEdgeGraph.getVertices() .filter(new Or<>(new ByLabel<>("Person"), new ByLabel<>("Tag"))) .output(new LocalCollectionOutputFormat<>(vertices));