@Override public DataSet<Boolean> execute(LogicalGraph firstGraph, LogicalGraph secondGraph) { GraphCollectionFactory collectionFactory = firstGraph.getConfig() .getGraphCollectionFactory(); return collectionEquality .execute(collectionFactory.fromGraph(firstGraph), collectionFactory.fromGraph(secondGraph)); }
@Test public void testEmptyFromGraphsMethod() throws Exception { GraphCollection expected = factory.createEmptyCollection(); GraphCollection result = factory.fromGraphs(); collectAndAssertTrue(result.equalsByGraphElementData(expected)); }
/** * Builds a {@link GraphCollection} from the graph referenced by the given * graph variables. * * @param variables graph variables used in GDL script * @return GraphCollection */ public GraphCollection getGraphCollectionByVariables(String... variables) { Collection<GraphHead> graphHeads = getGraphHeadsByVariables(variables); Collection<Vertex> vertices = getVerticesByGraphVariables(variables); Collection<Edge> edges = getEdgesByGraphVariables(variables); return config.getGraphCollectionFactory().fromCollections(graphHeads, vertices, edges); }
@Override public GraphCollection fromGraphs(LogicalGraph... logicalGraphLayouts) { if (logicalGraphLayouts.length != 0) { DataSet<GraphHead> graphHeads = null; DataSet<Vertex> vertices = null; DataSet<Edge> edges = null; if (logicalGraphLayouts.length == 1) { return fromGraph(logicalGraphLayouts[0]); } for (LogicalGraph logicalGraph : logicalGraphLayouts) { graphHeads = (graphHeads == null) ? logicalGraph.getGraphHead() : graphHeads.union(logicalGraph.getGraphHead()); vertices = (vertices == null) ? logicalGraph.getVertices() : vertices.union(logicalGraph.getVertices()); edges = (edges == null) ? logicalGraph.getEdges() : edges.union(logicalGraph.getEdges()); } return fromDataSets( graphHeads.distinct(new Id<>()), vertices.distinct(new Id<>()), edges.distinct(new Id<>())); } return createEmptyCollection(); }
@Override public GraphCollection execute( GraphCollection firstCollection, GraphCollection secondCollection) { // do some init stuff for the actual operator this.firstCollection = firstCollection; this.secondCollection = secondCollection; final DataSet<GraphHead> newGraphHeads = computeNewGraphHeads(); final DataSet<Vertex> newVertices = computeNewVertices(newGraphHeads); final DataSet<Edge> newEdges = computeNewEdges(newVertices); return firstCollection.getConfig().getGraphCollectionFactory() .fromDataSets(newGraphHeads, newVertices, newEdges); }
@Override public GraphCollection execute(GraphCollection collection) { config = collection.getConfig(); DataSet<GraphTransaction> input = collection .getGraphTransactions(); DataSet<GraphTransaction> output = execute(input); return config.getGraphCollectionFactory() .fromTransactions(output); }
@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()); }
if (graphHeads != null && vertices != null && edges != null) { collection = graph.getConfig().getGraphCollectionFactory() .fromDataSets(graphHeads, vertices, edges); } else { collection = graph.getConfig().getGraphCollectionFactory().createEmptyCollection();
@Override public GraphCollection fromGraphs(LogicalGraph... logicalGraphLayouts) { if (logicalGraphLayouts.length != 0) { DataSet<GraphHead> graphHeads = null; DataSet<Vertex> vertices = null; DataSet<Edge> edges = null; if (logicalGraphLayouts.length == 1) { return fromGraph(logicalGraphLayouts[0]); } for (LogicalGraph logicalGraph : logicalGraphLayouts) { graphHeads = (graphHeads == null) ? logicalGraph.getGraphHead() : graphHeads.union(logicalGraph.getGraphHead()); vertices = (vertices == null) ? logicalGraph.getVertices() : vertices.union(logicalGraph.getVertices()); edges = (edges == null) ? logicalGraph.getEdges() : edges.union(logicalGraph.getEdges()); } return fromDataSets( graphHeads.distinct(new Id<>()), vertices.distinct(new Id<>()), edges.distinct(new Id<>())); } return createEmptyCollection(); }
/** * {@inheritDoc} */ @Override public GraphCollection execute( GraphCollection firstCollection, GraphCollection secondCollection) { // do some init stuff for the actual operator this.firstCollection = firstCollection; this.secondCollection = secondCollection; final DataSet<GraphHead> newGraphHeads = computeNewGraphHeads(); final DataSet<Vertex> newVertices = computeNewVertices(newGraphHeads); final DataSet<Edge> newEdges = computeNewEdges(newVertices); return firstCollection.getConfig().getGraphCollectionFactory() .fromDataSets(newGraphHeads, newVertices, newEdges); }
@Override public GraphCollection execute(GraphCollection collection) { config = collection.getConfig(); DataSet<GraphTransaction> input = collection .getGraphTransactions(); DataSet<GraphTransaction> output = execute(input); return config.getGraphCollectionFactory() .fromTransactions(output); }
@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()); }
if (graphHeads != null && vertices != null && edges != null) { collection = graph.getConfig().getGraphCollectionFactory() .fromDataSets(graphHeads, vertices, edges); } else { collection = graph.getConfig().getGraphCollectionFactory().createEmptyCollection();
@Override public DataSet<Boolean> execute(LogicalGraph firstGraph, LogicalGraph secondGraph) { GraphCollectionFactory collectionFactory = firstGraph.getConfig() .getGraphCollectionFactory(); return collectionEquality .execute(collectionFactory.fromGraph(firstGraph), collectionFactory.fromGraph(secondGraph)); } }
@Override public GraphCollection execute(GraphCollection collection) { return collection.getConfig().getGraphCollectionFactory().fromDataSets( collection.getGraphHeads().distinct(new Id<>()), collection.getVertices(), collection.getEdges()); }
@Override public GraphCollection executeForTxLayout(GraphCollection collection) { DataSet<GraphTransaction> updatedTransactions = collection.getGraphTransactions() .map(new AggregateTransactions(aggregateFunctions)); return collection.getConfig().getGraphCollectionFactory().fromTransactions(updatedTransactions); }
@Test public void testTotalOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection col01 = loader.getGraphCollectionByVariables("g0", "g1"); GraphCollection expectation = getConfig().getGraphCollectionFactory().createEmptyCollection(); GraphCollection result = col01.difference(col01); checkAssertions(expectation, result, "total"); result = col01.differenceWithSmallResult(col01); checkAssertions(expectation, result, "small total"); } }
/** * Builds a {@link GraphCollection} from the graph referenced by the given * graph variables. * * @param variables graph variables used in GDL script * @return GraphCollection */ public GraphCollection getGraphCollectionByVariables(String... variables) { Collection<GraphHead> graphHeads = getGraphHeadsByVariables(variables); Collection<Vertex> vertices = getVerticesByGraphVariables(variables); Collection<Edge> edges = getEdgesByGraphVariables(variables); return config.getGraphCollectionFactory().fromCollections(graphHeads, vertices, edges); }
@Override public GraphCollection getGraphCollection() throws IOException { return config.getGraphCollectionFactory().fromGraph(getLogicalGraph()); } }
@Override public GraphCollection execute(GraphCollection collection) { return collection.getConfig().getGraphCollectionFactory().fromDataSets( collection.getGraphHeads().distinct(new Id<>()), collection.getVertices(), collection.getEdges()); } }