@Override protected DataSet<GraphHead> computeNewGraphHeads() { return firstCollection.getGraphHeads() .union(secondCollection.getGraphHeads()) .distinct(new Id<GraphHead>()); }
/** * {@inheritDoc} */ @Override protected DataSet<GraphHead> computeNewGraphHeads() { return firstCollection.getGraphHeads() .union(secondCollection.getGraphHeads()) .distinct(new Id<GraphHead>()); }
/** * Executes the operator for collections based on * {@link org.gradoop.flink.model.impl.layouts.gve.GVELayout} * * @param collection graph collection * @return result graph collection */ private GraphCollection executeForGVELayout(GraphCollection collection) { DataSet<GraphHead> graphHeads = collection.getGraphHeads() .filter(predicate); return selectVerticesAndEdges(collection, graphHeads); }
@Override protected DataSet<Vertex> computeNewVertices( DataSet<GraphHead> newSubgraphs) { DataSet<GradoopId> ids = secondCollection.getGraphHeads() .map(new Id<GraphHead>()); return firstCollection.getVertices() .filter(new InAnyGraphBroadcast<Vertex>()) .withBroadcastSet(ids, GraphsContainmentFilterBroadcast.GRAPH_IDS); } }
@Override protected DataSet<Vertex> computeNewVertices( DataSet<GraphHead> newSubgraphs) { DataSet<GradoopId> ids = secondCollection.getGraphHeads() .map(new Id<GraphHead>()); return firstCollection.getVertices() .filter(new InAnyGraphBroadcast<Vertex>()) .withBroadcastSet(ids, GraphsContainmentFilterBroadcast.GRAPH_IDS); }
@Override public GraphCollection execute(GraphCollection collection) { return collection.getConfig().getGraphCollectionFactory().fromDataSets( collection.getGraphHeads().distinct(new Id<>()), collection.getVertices(), collection.getEdges()); } }
/** * Creates the meta data for the given graph collection. * * @param graphs graph collection * @return meta data information */ default DataSet<Tuple3<String, String, String>> tuplesFromCollection(GraphCollection graphs) { return tuplesFromElements(graphs.getVertices()) .union(tuplesFromElements(graphs.getEdges())) .union(tuplesFromElements(graphs.getGraphHeads())); }
/** * Creates the meta data for the given graph collection. * * @param graphs graph collection * @return meta data information */ default DataSet<Tuple3<String, String, String>> tuplesFromCollection(GraphCollection graphs) { return tuplesFromElements(graphs.getVertices()) .union(tuplesFromElements(graphs.getEdges())) .union(tuplesFromElements(graphs.getGraphHeads())); }
@Override public GraphCollection execute(GraphCollection collection) { // create canonical labels for all graph heads and choose representative for all distinct ones DataSet<GradoopId> graphIds = getCanonicalLabels(collection) .distinct(1) .map(new IdFromGraphHeadString()); DataSet<GraphHead> graphHeads = collection.getGraphHeads() .filter(new IdInBroadcast<>()) .withBroadcastSet(graphIds, IdInBroadcast.IDS); return selectVerticesAndEdges(collection, graphHeads); } }
@Override public GraphCollection execute(GraphCollection collection) { // create canonical labels for all graph heads and choose representative for all distinct ones DataSet<GradoopId> graphIds = getCanonicalLabels(collection) .distinct(1) .map(new IdFromGraphHeadString()); DataSet<GraphHead> graphHeads = collection.getGraphHeads() .filter(new IdInBroadcast<>()) .withBroadcastSet(graphIds, IdInBroadcast.IDS); return selectVerticesAndEdges(collection, graphHeads); }
@Test public void execute() throws Exception { GraphCollection collection = getTestCollection(); collection = collection.distinctById(); assertEquals(5, collection.getGraphHeads().count()); collection = collection.distinctByIsomorphism(); assertEquals(3, collection.getGraphHeads().count()); } }
@Override public GraphCollection executeForGVELayout(GraphCollection collection) { // the resulting logical graph holds multiple graph heads LogicalGraph modifiedGraph = executeInternal( collection.getGraphHeads(), collection.getVertices(), collection.getEdges(), collection.getConfig().getLogicalGraphFactory()); return collection.getFactory().fromDataSets( modifiedGraph.getGraphHead(), modifiedGraph.getVertices(), modifiedGraph.getEdges()); }
@Override public GraphCollection execute(GraphCollection collection) { DataSet<GraphHead> graphHeads = getCanonicalLabels(collection) .join(collection.getGraphHeads()) .where(0).equalTo(new Id<>()) .with(new GraphHeadGroup()) .groupBy(0) .reduceGroup(function); return selectVerticesAndEdges(collection, graphHeads); }
@Override public GraphCollection execute(GraphCollection collection) { DataSet<GraphHead> graphHeads = getCanonicalLabels(collection) .join(collection.getGraphHeads()) .where(0).equalTo(new Id<>()) .with(new GraphHeadGroup()) .groupBy(0) .reduceGroup(function); return selectVerticesAndEdges(collection, graphHeads); }
/** * {@inheritDoc} */ @Override public DataSet<Boolean> isEmpty() { return getGraphHeads() .map(new True<>()) .distinct() .union(getConfig().getExecutionEnvironment().fromElements(false)) .reduce(new Or()) .map(new Not()); }
@Override public void write(GraphCollection graphCollection, boolean overWrite) throws IOException { FileSystem.WriteMode writeMode = overWrite ? FileSystem.WriteMode.OVERWRITE : FileSystem.WriteMode.NO_OVERWRITE; graphCollection.getGraphHeads().writeAsFormattedText(getGraphHeadPath(), writeMode, new GraphHeadToJSON<>()); graphCollection.getVertices().writeAsFormattedText(getVertexPath(), writeMode, new VertexToJSON<>()); graphCollection.getEdges().writeAsFormattedText(getEdgePath(), writeMode, new EdgeToJSON<>()); } }
@Override public GraphCollection execute(LogicalGraph graph) { LogicalGraph graphWithWccIds = graph.callForGraph(new AnnotateWeaklyConnectedComponents( propertyKey, maxIterations)); GraphCollection split = graphWithWccIds.splitBy(propertyKey); return graph.getConfig().getGraphCollectionFactory().fromDataSets( split.getGraphHeads(), split.getVertices().map(new PropertyRemover<>(propertyKey)), split.getEdges().map(new PropertyRemover<>(propertyKey))); } }
@Override public GraphCollection execute(GraphCollection collection) { DataSet<GraphHead> graphHeads = collection.getGraphHeads().first(limit); DataSet<GradoopId> firstIds = graphHeads.map(new Id<>()); DataSet<Vertex> filteredVertices = collection.getVertices() .filter(new InAnyGraphBroadcast<>()) .withBroadcastSet(firstIds, GraphsContainmentFilterBroadcast.GRAPH_IDS); DataSet<Edge> filteredEdges = collection.getEdges() .filter(new InAnyGraphBroadcast<>()) .withBroadcastSet(firstIds, GraphsContainmentFilterBroadcast.GRAPH_IDS); return collection.getConfig().getGraphCollectionFactory() .fromDataSets(graphHeads, filteredVertices, filteredEdges); }
@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()); }