@Test public void testEmptyFromGraphsMethod() throws Exception { GraphCollection expected = factory.createEmptyCollection(); GraphCollection result = factory.fromGraphs(); collectAndAssertTrue(result.equalsByGraphElementData(expected)); }
@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()); }
@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"); } }
/** * Test writing a graph to {@link HBaseDataSink} with overwrite flag, that results in an exception */ @Test(expected = NotImplementedException.class) public void testWriteToSinkWithOverWrite() throws Exception { // Create an empty store HBaseEPGMStore newStore = createEmptyEPGMStore("testWriteToSink"); GraphCollection graphCollection = getConfig().getGraphCollectionFactory() .createEmptyCollection(); new HBaseDataSink(newStore, getConfig()).write(graphCollection, true); getExecutionEnvironment().execute(); } }
@Test public void testNonOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection col01 = loader.getGraphCollectionByVariables("g0", "g1"); GraphCollection col23 = loader.getGraphCollectionByVariables("g2", "g3"); GraphCollection expectation = getConfig().getGraphCollectionFactory().createEmptyCollection(); GraphCollection result = col01.intersect(col23); checkAssertions(expectation, result, "non"); result = col01.intersectWithSmallResult(col23); checkAssertions(expectation, result, "small non"); }
.fromDataSets(graphHeads, vertices, edges); } else { collection = graph.getConfig().getGraphCollectionFactory().createEmptyCollection();
.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(); }
@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(); }
@Test public void testCollectionEqualityByGraphIds() throws Exception { FlinkAsciiGraphLoader loader = getTestGraphLoader(); CollectionEqualityByGraphIds equality = new CollectionEqualityByGraphIds(); GraphCollection gRef1 = loader.getGraphCollectionByVariables("gRef"); GraphCollection gRef2 = loader.getGraphCollectionByVariables("gRef"); GraphCollection gClone = loader.getGraphCollectionByVariables("gClone"); GraphCollection gEmpty = getConfig().getGraphCollectionFactory() .createEmptyCollection(); // direct operator call collectAndAssertTrue(equality.execute(gRef1, gRef2)); collectAndAssertFalse(equality.execute(gRef1, gClone)); collectAndAssertFalse(equality.execute(gRef1, gEmpty)); // convenience method collectAndAssertTrue(gRef1.equalsByGraphIds(gRef2)); collectAndAssertFalse(gRef1.equalsByGraphIds(gClone)); collectAndAssertFalse(gRef1.equalsByGraphIds(gEmpty)); }
.getGraphCollectionByVariables("gDiffData", "gEmpty"); GraphCollection gEmpty = getConfig().getGraphCollectionFactory() .createEmptyCollection();
@Test public void testCollectionEqualityByGraphElementData() throws Exception { FlinkAsciiGraphLoader loader = getTestGraphLoader(); CollectionEquality equality = new CollectionEquality( new GraphHeadToEmptyString(), new VertexToDataString(), new EdgeToDataString(), true ); GraphCollection gRef = loader .getGraphCollectionByVariables("gRef", "gClone", "gEmpty"); GraphCollection gClone = loader .getGraphCollectionByVariables("gClone", "gRef", "gEmpty"); GraphCollection gSmall = loader .getGraphCollectionByVariables("gRef", "gRef"); GraphCollection gDiffData = loader .getGraphCollectionByVariables("gRef", "gDiffData", "gEmpty"); GraphCollection gEmpty = getConfig().getGraphCollectionFactory() .createEmptyCollection(); // direct operator call collectAndAssertTrue(equality.execute(gRef, gClone)); collectAndAssertFalse(equality.execute(gRef, gDiffData)); collectAndAssertFalse(equality.execute(gRef, gSmall)); collectAndAssertFalse(equality.execute(gRef, gEmpty)); // convenience method collectAndAssertTrue(gRef.equalsByGraphElementData(gClone)); collectAndAssertFalse(gRef.equalsByGraphElementData(gDiffData)); collectAndAssertFalse(gRef.equalsByGraphElementData(gSmall)); collectAndAssertFalse(gRef.equalsByGraphElementData(gEmpty)); }
@Test public void testCollectionEqualityByGraphElementIds() throws Exception { FlinkAsciiGraphLoader loader = getTestGraphLoader(); CollectionEquality equality = new CollectionEquality( new GraphHeadToEmptyString(), new VertexToIdString(), new EdgeToIdString(), true); GraphCollection gRef = loader .getGraphCollectionByVariables("gRef", "gClone", "gEmpty"); GraphCollection gClone = loader .getGraphCollectionByVariables("gClone", "gRef", "gEmpty"); GraphCollection gSmall = loader .getGraphCollectionByVariables("gRef", "gRef"); GraphCollection gDiffId = loader .getGraphCollectionByVariables("gRef", "gDiffId", "gEmpty"); GraphCollection gEmpty = getConfig().getGraphCollectionFactory() .createEmptyCollection(); // direct operator call collectAndAssertTrue(equality.execute(gRef, gClone)); collectAndAssertFalse(equality.execute(gRef, gDiffId)); collectAndAssertFalse(equality.execute(gRef, gSmall)); collectAndAssertFalse(equality.execute(gRef, gEmpty)); // convenience method collectAndAssertTrue(gRef.equalsByGraphElementIds(gClone)); collectAndAssertFalse(gRef.equalsByGraphElementIds(gDiffId)); collectAndAssertFalse(gRef.equalsByGraphElementIds(gSmall)); collectAndAssertFalse(gRef.equalsByGraphElementIds(gEmpty)); }
.getGraphCollectionByVariables("gDiffData", "gEmpty"); GraphCollection gEmpty = getConfig().getGraphCollectionFactory() .createEmptyCollection();