/** * @return a long integer representing the number of edges */ public long numberOfEdges() throws Exception { return edges.count(); }
/** * @return a long integer representing the number of vertices */ public long numberOfVertices() throws Exception { return vertices.count(); }
private static <T, B extends CopyableIterator<T>> void testReducePerformance (B iterator, TypeInformation<T> typeInfo, CombineHint hint, int numRecords, boolean print) throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.getConfig().enableObjectReuse(); @SuppressWarnings("unchecked") DataSet<T> output = env.fromParallelCollection(new SplittableRandomIterator<T, B>(numRecords, iterator), typeInfo) .groupBy("0") .reduce(new SumReducer()).setCombineHint(hint); long start = System.currentTimeMillis(); System.out.println(output.count()); long end = System.currentTimeMillis(); if (print) { System.out.println("=== Time for " + iterator.getClass().getSimpleName() + " with hint " + hint.toString() + ": " + (end - start) + "ms ==="); } }
@Test public void testSimple() throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Integer[] input = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; DataSet<Integer> data = env.fromElements(input); // count long numEntries = data.count(); assertEquals(10, numEntries); // collect ArrayList<Integer> list = (ArrayList<Integer>) data.collect(); assertArrayEquals(input, list.toArray()); }
@Test public void testCountElementsPerPartition() throws Exception { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); long expectedSize = 100L; DataSet<Long> numbers = env.generateSequence(0, expectedSize - 1); DataSet<Tuple2<Integer, Long>> ds = DataSetUtils.countElementsPerPartition(numbers); Assert.assertEquals(env.getParallelism(), ds.count()); Assert.assertEquals(expectedSize, ds.sum(1).collect().get(0).f1.longValue()); }
long numEntries = data3.count(); assertEquals(100, numEntries);
); final long numVertices = vertices.count(); final long numDanglingVertices = vertices .filter(
/** * @return a long integer representing the number of vertices */ public long numberOfVertices() throws Exception { return vertices.count(); }
/** * @return a long integer representing the number of edges */ public long numberOfEdges() throws Exception { return edges.count(); }
/** * @return a long integer representing the number of vertices */ public long numberOfVertices() throws Exception { return vertices.count(); }
/** * @return a long integer representing the number of edges */ public long numberOfEdges() throws Exception { return edges.count(); }
/** * @return a long integer representing the number of edges */ public long numberOfEdges() throws Exception { return edges.count(); }
/** * @return a long integer representing the number of vertices */ public long numberOfVertices() throws Exception { return vertices.count(); }
/** * Check PageRank for included "zero-degree" vertices * * @throws Exception If the execution fails. */ @Test public void testPageRankWithZeroDegrees() throws Exception { LogicalGraph resultGraph = new PageRank(propertyKey, 0.3, 20, true) .execute(testGraph); checkPageRankProperty(resultGraph); assertEquals(resultGraph.getVertices().count(), testGraph.getVertices().count()); }
@Override public LogicalGraph executeInGelly(Graph<GradoopId, NullValue, NullValue> graph) throws Exception { DataSet<Tuple3<GradoopId, GradoopId, GradoopId>> triangles = new org.apache.flink.graph.library.TriangleEnumerator<GradoopId, NullValue, NullValue>() .run(graph); DataSet<GraphHead> resultHead = currentGraph.getGraphHead() .map(new WritePropertyToGraphHeadMap( PROPERTY_KEY_TRIANGLES, PropertyValue.create(triangles.count()))); return currentGraph.getConfig().getLogicalGraphFactory().fromDataSets( resultHead, currentGraph.getVertices(), currentGraph.getEdges()); }
@Test public void testFilterWithNoPredicates() throws Exception { CNF predicates = predicateFromQuery("MATCH (a)"); Properties properties = Properties.create(); properties.set("name", "Anton"); DataSet<Vertex> vertices = getExecutionEnvironment() .fromElements(new VertexFactory().createVertex("Person", properties)); FilterAndProjectVertices filter = new FilterAndProjectVertices(vertices, predicates, new ArrayList<>()); assertEquals(1, filter.evaluate().count()); }
/** * Check PageRank for excluded "zero-degree" vertices * * @throws Exception If the execution fails. */ @Test public void testPageRankWithoutZeroDegrees() throws Exception { LogicalGraph resultGraph = new PageRank(propertyKey, 0.3, 20) .execute(testGraph); checkPageRankProperty(resultGraph); assertEquals(resultGraph.getVertices().count(), 3L); }
@Test public void testEmpty() throws Exception { GraphCollection inputCollection = getConfig().getGraphCollectionFactory() .createEmptyCollection(); int limit = 4; int expectedCount = 0; GraphCollection outputCollection = inputCollection.limit(limit); assertEquals(expectedCount, outputCollection.getGraphHeads().count()); }
@Test(expected = InvalidProgramException.class) public void testNegativeLimit() throws Exception { GraphCollection inputCollection = getConfig().getGraphCollectionFactory() .createEmptyCollection(); int limit = -1; int expectedCount = 0; GraphCollection outputCollection = inputCollection.limit(limit); assertEquals(expectedCount, outputCollection.getGraphHeads().count()); }