diff --git a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraph.java b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraph.java index 879b8870df1a..998dc25a1ee7 100644 --- a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraph.java +++ b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraph.java @@ -15,10 +15,14 @@ */ package org.gradoop.flink.model.api.epgm; +import org.apache.flink.api.java.DataSet; import org.gradoop.common.model.api.entities.GraphHead; import org.gradoop.common.model.api.entities.Edge; import org.gradoop.common.model.api.entities.Vertex; import org.gradoop.flink.model.api.layouts.LogicalGraphLayout; +import org.gradoop.flink.model.impl.functions.bool.Not; +import org.gradoop.flink.model.impl.functions.bool.Or; +import org.gradoop.flink.model.impl.functions.bool.True; import org.gradoop.flink.util.GradoopFlinkConfig; /** @@ -58,4 +62,18 @@ public interface BaseGraph< * @return a factory that can be used to create a {@link GC} instance. */ BaseGraphCollectionFactory getCollectionFactory(); + + //---------------------------------------------------------------------------- + // Utility methods + //---------------------------------------------------------------------------- + + @Override + default DataSet isEmpty() { + return getVertices() + .map(new True<>()) + .distinct() + .union(getConfig().getExecutionEnvironment().fromElements(false)) + .reduce(new Or()) + .map(new Not()); + } } diff --git a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphCollection.java b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphCollection.java index 59461f148288..195c4cab69af 100644 --- a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphCollection.java +++ b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphCollection.java @@ -23,6 +23,9 @@ import org.gradoop.common.model.impl.id.GradoopId; import org.gradoop.common.model.impl.id.GradoopIdSet; import org.gradoop.flink.model.api.layouts.GraphCollectionLayout; +import org.gradoop.flink.model.impl.functions.bool.Not; +import org.gradoop.flink.model.impl.functions.bool.Or; +import org.gradoop.flink.model.impl.functions.bool.True; import org.gradoop.flink.model.impl.functions.epgm.BySameId; import org.gradoop.flink.model.impl.functions.graphcontainment.InAnyGraph; import org.gradoop.flink.model.impl.functions.graphcontainment.InGraph; @@ -98,4 +101,18 @@ default GC getGraphs(final GradoopIdSet identifiers) { return getFactory().fromDataSets(newGraphHeads, vertices, edges); } + + //---------------------------------------------------------------------------- + // Utility methods + //---------------------------------------------------------------------------- + + @Override + default DataSet isEmpty() { + return getGraphHeads() + .map(new True<>()) + .distinct() + .union(getConfig().getExecutionEnvironment().fromElements(false)) + .reduce(new Or()) + .map(new Not()); + } } diff --git a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphCollectionOperators.java b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphCollectionOperators.java index ff10b7f4c6fd..9021177b7273 100644 --- a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphCollectionOperators.java +++ b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphCollectionOperators.java @@ -299,6 +299,16 @@ default DataSet equalsByGraphData(GC otherCollection) { // Utility methods //---------------------------------------------------------------------------- + /** + * Returns a 1-element dataset containing a {@code boolean} value which indicates if the collection + * is empty. + * + * A collection is considered empty, if it contains no logical graphs. + * + * @return 1-element dataset containing {@code true}, if the collection is empty or {@code false} if not + */ + DataSet isEmpty(); + /** * Returns a distinct collection of base graphs. Graph equality is based on graph identifiers. * diff --git a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphOperators.java b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphOperators.java index 146a7fe77fca..1ebfdf5beffc 100644 --- a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphOperators.java +++ b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphOperators.java @@ -16,6 +16,7 @@ package org.gradoop.flink.model.api.epgm; import org.apache.flink.api.common.functions.FilterFunction; +import org.apache.flink.api.java.DataSet; import org.gradoop.common.model.api.entities.Edge; import org.gradoop.common.model.api.entities.GraphHead; import org.gradoop.common.model.api.entities.Vertex; @@ -34,6 +35,9 @@ import org.gradoop.flink.model.impl.operators.exclusion.Exclusion; import org.gradoop.flink.model.impl.operators.grouping.Grouping; import org.gradoop.flink.model.impl.operators.grouping.GroupingStrategy; +import org.gradoop.flink.model.impl.operators.matching.common.MatchStrategy; +import org.gradoop.flink.model.impl.operators.matching.common.statistics.GraphStatistics; +import org.gradoop.flink.model.impl.operators.matching.single.cypher.CypherPatternMatching; import org.gradoop.flink.model.impl.operators.neighborhood.Neighborhood; import org.gradoop.flink.model.impl.operators.neighborhood.ReduceEdgeNeighborhood; import org.gradoop.flink.model.impl.operators.neighborhood.ReduceVertexNeighborhood; @@ -66,6 +70,118 @@ public interface BaseGraphOperators< // Unary Operators //---------------------------------------------------------------------------- + /** + * Evaluates the given query using the Cypher query engine. The engine uses default morphism strategies, + * which is vertex homomorphism and edge isomorphism. The vertex and edge data of the data graph elements + * is attached to the resulting vertices. + *

+ * Note, that this method used no statistics about the data graph which may result in bad runtime + * performance. Use {@link #query(String, GraphStatistics)} to provide statistics for the query planner. + * + * @param query Cypher query + * @return graph collection containing matching subgraphs + */ + default GC query(String query) { + return query(query, new GraphStatistics(1, 1, 1, 1)); + } + + /** + * Evaluates the given query using the Cypher query engine. The engine uses default morphism strategies, + * which is vertex homomorphism and edge isomorphism. The vertex and edge data of the data graph elements + * is attached to the resulting vertices. + *

+ * Note, that this method used no statistics about the data graph which may result in bad runtime + * performance. Use {@link #query(String, String, GraphStatistics)} to provide statistics for the query planner. + *

+ * In addition, the operator can be supplied with a construction pattern allowing the creation of new graph + * elements based on variable bindings of the match pattern. Consider the following example: + *
+ * {@code graph.query( + * "MATCH (a:Author)-[:WROTE]->(:Paper)<-[:WROTE]-(b:Author) WHERE a <> b", + * "(a)-[:CO_AUTHOR]->(b)")} + *

+ * The query pattern is looking for pairs of authors that worked on the same paper. + * The construction pattern defines a new edge of type CO_AUTHOR between the two entities. + * + * @param query Cypher query string + * @param constructionPattern Construction pattern + * @return graph collection containing the output of the construct pattern + */ + default GC query(String query, String constructionPattern) { + return query(query, constructionPattern, new GraphStatistics(1, 1, 1, 1)); + } + + /** + * Evaluates the given query using the Cypher query engine. The engine uses default morphism strategies, + * which is vertex homomorphism and edge isomorphism. The vertex and edge data of the data graph elements + * is attached to the resulting vertices. + * + * @param query Cypher query + * @param graphStatistics statistics about the data graph + * @return graph collection containing matching subgraphs + */ + default GC query(String query, GraphStatistics graphStatistics) { + return query(query, true, MatchStrategy.HOMOMORPHISM, MatchStrategy.ISOMORPHISM, + graphStatistics); + } + + /** + * Evaluates the given query using the Cypher query engine. The engine uses default morphism strategies, + * which is vertex homomorphism and edge isomorphism. The vertex and edge data of the data graph elements + * is attached to the resulting vertices. + *

+ * In addition, the operator can be supplied with a construction pattern allowing the creation of new graph + * elements based on variable bindings of the match pattern. Consider the following example: + *
+ * {@code graph.query( + * "MATCH (a:Author)-[:WROTE]->(:Paper)<-[:WROTE]-(b:Author) WHERE a <> b", + * "(a)-[:CO_AUTHOR]->(b)")} + *

+ * The query pattern is looking for pairs of authors that worked on the same paper. + * The construction pattern defines a new edge of type CO_AUTHOR between the two entities. + * + * @param query Cypher query + * @param constructionPattern Construction pattern + * @param graphStatistics statistics about the data graph + * @return graph collection containing the output of the construct pattern + */ + default GC query(String query, String constructionPattern, GraphStatistics graphStatistics) { + return query(query, constructionPattern, true, MatchStrategy.HOMOMORPHISM, + MatchStrategy.ISOMORPHISM, graphStatistics); + } + + /** + * Evaluates the given query using the Cypher query engine. + * + * @param query Cypher query + * @param attachData attach original vertex and edge data to the result + * @param vertexStrategy morphism setting for vertex mapping + * @param edgeStrategy morphism setting for edge mapping + * @param graphStatistics statistics about the data graph + * @return graph collection containing matching subgraphs + */ + default GC query(String query, boolean attachData, MatchStrategy vertexStrategy, + MatchStrategy edgeStrategy, GraphStatistics graphStatistics) { + return query(query, null, attachData, vertexStrategy, edgeStrategy, graphStatistics); + } + + /** + * Evaluates the given query using the Cypher query engine. + * + * @param query Cypher query + * @param constructionPattern Construction pattern + * @param attachData attach original vertex and edge data to the result + * @param vertexStrategy morphism setting for vertex mapping + * @param edgeStrategy morphism setting for edge mapping + * @param graphStatistics statistics about the data graph + * @return graph collection containing matching subgraphs + */ + default GC query(String query, String constructionPattern, boolean attachData, MatchStrategy vertexStrategy, + MatchStrategy edgeStrategy, GraphStatistics graphStatistics) { + return callForCollection(new CypherPatternMatching<>(query, constructionPattern, attachData, + vertexStrategy, edgeStrategy, graphStatistics)); + } + /** * Creates a copy of the base graph. *

@@ -376,6 +492,20 @@ default LG exclude(LG otherGraph) { return callForGraph(new Exclusion<>(), otherGraph); } + //---------------------------------------------------------------------------- + // Utility methods + //---------------------------------------------------------------------------- + + /** + * Returns a 1-element dataset containing a {@code boolean} value which indicates if the graph is empty. + * + * A graph is considered empty, if it contains no vertices. + * + * @return 1-element dataset containing {@code true}, if the collection is + * empty or {@code false} if not + */ + DataSet isEmpty(); + //---------------------------------------------------------------------------- // Call for Operators //---------------------------------------------------------------------------- diff --git a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/GraphCollectionOperators.java b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/GraphCollectionOperators.java index 9fa59070f2eb..d200e00adb77 100644 --- a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/GraphCollectionOperators.java +++ b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/GraphCollectionOperators.java @@ -15,7 +15,6 @@ */ package org.gradoop.flink.model.api.epgm; -import org.apache.flink.api.java.DataSet; import org.gradoop.common.model.impl.pojo.EPGMEdge; import org.gradoop.common.model.impl.pojo.EPGMGraphHead; import org.gradoop.common.model.impl.pojo.EPGMVertex; @@ -35,17 +34,6 @@ public interface GraphCollectionOperators // Auxiliary operators //---------------------------------------------------------------------------- - /** - * Returns a 1-element dataset containing a {@code boolean} value which - * indicates if the collection is empty. - * - * A collection is considered empty, if it contains no logical graphs. - * - * @return 1-element dataset containing {@code true}, if the collection is - * empty or {@code false} if not - */ - DataSet isEmpty(); - /** * Writes the graph collection to the given data sink. * diff --git a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/LogicalGraphOperators.java b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/LogicalGraphOperators.java index 3946914005d5..904d799f2233 100644 --- a/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/LogicalGraphOperators.java +++ b/gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/LogicalGraphOperators.java @@ -26,8 +26,6 @@ import org.gradoop.flink.model.impl.epgm.GraphCollection; import org.gradoop.flink.model.impl.epgm.LogicalGraph; import org.gradoop.flink.model.impl.operators.cypher.capf.result.CAPFQueryResult; -import org.gradoop.flink.model.impl.operators.matching.common.MatchStrategy; -import org.gradoop.flink.model.impl.operators.matching.common.statistics.GraphStatistics; import org.gradoop.flink.model.impl.operators.sampling.SamplingAlgorithm; import java.io.IOException; @@ -71,106 +69,6 @@ public interface LogicalGraphOperators */ CAPFQueryResult cypher(String query) throws Exception; - /** - * Evaluates the given query using the Cypher query engine. The engine uses default morphism - * strategies, which is vertex homomorphism and edge isomorphism. The vertex and edge data of - * the data graph elements is attached to the resulting vertices. - *

- * Note, that this method used no statistics about the data graph which may result in bad - * runtime performance. Use {@link LogicalGraphOperators#query(String, GraphStatistics)} to - * provide statistics for the query planner. - * - * @param query Cypher query - * @return graph collection containing matching subgraphs - */ - GraphCollection query(String query); - - /** - * Evaluates the given query using the Cypher query engine. The engine uses default morphism - * strategies, which is vertex homomorphism and edge isomorphism. The vertex and edge data of - * the data graph elements is attached to the resulting vertices. - *

- * Note, that this method used no statistics about the data graph which may result in bad - * runtime performance. Use {@link LogicalGraphOperators#query(String, GraphStatistics)} to - * provide statistics for the query planner. - *

- * In addition, the operator can be supplied with a construction pattern allowing the creation - * of new graph elements based on variable bindings of the match pattern. Consider the following example: - *

- * {@code graph.query( - * "MATCH (a:Author)-[:WROTE]->(:Paper)<-[:WROTE]-(b:Author) WHERE a <> b", - * "(a)-[:CO_AUTHOR]->(b)")} - *

- * The query pattern is looking for pairs of authors that worked on the same paper. - * The construction pattern defines a new edge of type CO_AUTHOR between the two entities. - * - * @param query Cypher query string - * @param constructionPattern Construction pattern - * @return graph collection containing the output of the construct pattern - */ - GraphCollection query(String query, String constructionPattern); - - /** - * Evaluates the given query using the Cypher query engine. The engine uses default morphism - * strategies, which is vertex homomorphism and edge isomorphism. The vertex and edge data of - * the data graph elements is attached to the resulting vertices. - * - * @param query Cypher query - * @param graphStatistics statistics about the data graph - * @return graph collection containing matching subgraphs - */ - GraphCollection query(String query, GraphStatistics graphStatistics); - - /** - * Evaluates the given query using the Cypher query engine. The engine uses default morphism - * strategies, which is vertex homomorphism and edge isomorphism. The vertex and edge data of - * the data graph elements is attached to the resulting vertices. - *

- * In addition, the operator can be supplied with a construction pattern allowing the creation - * of new graph elements based on variable bindings of the match pattern. Consider the following example: - *

- * {@code graph.query( - * "MATCH (a:Author)-[:WROTE]->(:Paper)<-[:WROTE]-(b:Author) WHERE a <> b", - * "(a)-[:CO_AUTHOR]->(b)")} - *

- * The query pattern is looking for pairs of authors that worked on the same paper. - * The construction pattern defines a new edge of type CO_AUTHOR between the two entities. - * - * @param query Cypher query - * @param constructionPattern Construction pattern - * @param graphStatistics statistics about the data graph - * @return graph collection containing the output of the construct pattern - */ - GraphCollection query(String query, String constructionPattern, GraphStatistics graphStatistics); - - /** - * Evaluates the given query using the Cypher query engine. - * - * @param query Cypher query - * @param attachData attach original vertex and edge data to the result - * @param vertexStrategy morphism setting for vertex mapping - * @param edgeStrategy morphism setting for edge mapping - * @param graphStatistics statistics about the data graph - * @return graph collection containing matching subgraphs - */ - GraphCollection query(String query, boolean attachData, MatchStrategy vertexStrategy, - MatchStrategy edgeStrategy, GraphStatistics graphStatistics); - - /** - * Evaluates the given query using the Cypher query engine. - * - * @param query Cypher query - * @param constructionPattern Construction pattern - * @param attachData attach original vertex and edge data to the result - * @param vertexStrategy morphism setting for vertex mapping - * @param edgeStrategy morphism setting for edge mapping - * @param graphStatistics statistics about the data graph - * @return graph collection containing matching subgraphs - */ - GraphCollection query(String query, String constructionPattern, boolean attachData, - MatchStrategy vertexStrategy, MatchStrategy edgeStrategy, - GraphStatistics graphStatistics); - /** * Creates a new graph from a randomly chosen subset of nodes and their associated edges. * @@ -260,16 +158,6 @@ GraphCollection groupEdgesByRollUp( */ LogicalGraph callForGraph(GraphsToGraphOperator operator, LogicalGraph... otherGraphs); - /** - * Returns a 1-element dataset containing a {@code boolean} value which indicates if the graph is empty. - * - * A graph is considered empty, if it contains no vertices. - * - * @return 1-element dataset containing {@code true}, if the collection is - * empty or {@code false} if not - */ - DataSet isEmpty(); - /** * Writes the graph to given data sink. * diff --git a/gradoop-flink/src/main/java/org/gradoop/flink/model/impl/epgm/GraphCollection.java b/gradoop-flink/src/main/java/org/gradoop/flink/model/impl/epgm/GraphCollection.java index 260c161b162b..4fda2ebee196 100644 --- a/gradoop-flink/src/main/java/org/gradoop/flink/model/impl/epgm/GraphCollection.java +++ b/gradoop-flink/src/main/java/org/gradoop/flink/model/impl/epgm/GraphCollection.java @@ -28,9 +28,6 @@ import org.gradoop.flink.model.api.layouts.GraphCollectionLayout; import org.gradoop.flink.model.api.operators.BinaryBaseGraphCollectionToValueOperator; import org.gradoop.flink.model.api.operators.UnaryBaseGraphCollectionToValueOperator; -import org.gradoop.flink.model.impl.functions.bool.Not; -import org.gradoop.flink.model.impl.functions.bool.Or; -import org.gradoop.flink.model.impl.functions.bool.True; import org.gradoop.flink.model.impl.layouts.transactional.tuples.GraphTransaction; import org.gradoop.flink.util.GradoopFlinkConfig; @@ -167,16 +164,6 @@ EPGMGraphHead, EPGMVertex, EPGMEdge, LogicalGraph, GraphCollection> getFactory() return config.getLogicalGraphFactory(); } - @Override - public DataSet isEmpty() { - return getGraphHeads() - .map(new True<>()) - .distinct() - .union(getConfig().getExecutionEnvironment().fromElements(false)) - .reduce(new Or()) - .map(new Not()); - } - @Override public void writeTo(DataSink dataSink) throws IOException { dataSink.write(this); diff --git a/gradoop-flink/src/main/java/org/gradoop/flink/model/impl/epgm/LogicalGraph.java b/gradoop-flink/src/main/java/org/gradoop/flink/model/impl/epgm/LogicalGraph.java index b9cd54b2c0ee..ccf8971bdfe6 100644 --- a/gradoop-flink/src/main/java/org/gradoop/flink/model/impl/epgm/LogicalGraph.java +++ b/gradoop-flink/src/main/java/org/gradoop/flink/model/impl/epgm/LogicalGraph.java @@ -32,16 +32,10 @@ import org.gradoop.flink.model.api.operators.BinaryBaseGraphToValueOperator; import org.gradoop.flink.model.api.operators.GraphsToGraphOperator; import org.gradoop.flink.model.api.operators.UnaryBaseGraphToValueOperator; -import org.gradoop.flink.model.impl.functions.bool.Not; -import org.gradoop.flink.model.impl.functions.bool.Or; -import org.gradoop.flink.model.impl.functions.bool.True; import org.gradoop.flink.model.impl.functions.epgm.PropertyGetter; import org.gradoop.flink.model.impl.operators.cypher.capf.query.CAPFQuery; import org.gradoop.flink.model.impl.operators.cypher.capf.result.CAPFQueryResult; import org.gradoop.flink.model.impl.operators.equality.GraphEquality; -import org.gradoop.flink.model.impl.operators.matching.common.MatchStrategy; -import org.gradoop.flink.model.impl.operators.matching.common.statistics.GraphStatistics; -import org.gradoop.flink.model.impl.operators.matching.single.cypher.CypherPatternMatching; import org.gradoop.flink.model.impl.operators.rollup.EdgeRollUp; import org.gradoop.flink.model.impl.operators.rollup.VertexRollUp; import org.gradoop.flink.model.impl.operators.sampling.SamplingAlgorithm; @@ -173,43 +167,6 @@ public CAPFQueryResult cypher(String query, MetaData metaData) throws Exception return capfQuery.execute(this); } - @Override - public GraphCollection query(String query) { - return query(query, new GraphStatistics(1, 1, 1, 1)); - } - - @Override - public GraphCollection query(String query, String constructionPattern) { - return query(query, constructionPattern, new GraphStatistics(1, 1, 1, 1)); - } - - @Override - public GraphCollection query(String query, GraphStatistics graphStatistics) { - return query(query, true, - MatchStrategy.HOMOMORPHISM, MatchStrategy.ISOMORPHISM, graphStatistics); - } - - @Override - public GraphCollection query(String query, String constructionPattern, - GraphStatistics graphStatistics) { - return query(query, constructionPattern, true, - MatchStrategy.HOMOMORPHISM, MatchStrategy.ISOMORPHISM, graphStatistics); - } - - @Override - public GraphCollection query(String query, boolean attachData, MatchStrategy vertexStrategy, - MatchStrategy edgeStrategy, GraphStatistics graphStatistics) { - return query(query, null, attachData, vertexStrategy, edgeStrategy, graphStatistics); - } - - @Override - public GraphCollection query(String query, String constructionPattern, boolean attachData, - MatchStrategy vertexStrategy, MatchStrategy edgeStrategy, - GraphStatistics graphStatistics) { - return callForCollection(new CypherPatternMatching<>(query, constructionPattern, attachData, - vertexStrategy, edgeStrategy, graphStatistics)); - } - @Override public LogicalGraph sample(SamplingAlgorithm algorithm) { return callForGraph(algorithm); @@ -297,16 +254,6 @@ public GraphCollection splitBy(String propertyKey) { // Utility methods //---------------------------------------------------------------------------- - @Override - public DataSet isEmpty() { - return getVertices() - .map(new True<>()) - .distinct() - .union(getConfig().getExecutionEnvironment().fromElements(false)) - .reduce(new Or()) - .map(new Not()); - } - @Override public void writeTo(DataSink dataSink) throws IOException { dataSink.write(this); diff --git a/gradoop-temporal/src/main/java/org/gradoop/temporal/model/api/TemporalGraphOperators.java b/gradoop-temporal/src/main/java/org/gradoop/temporal/model/api/TemporalGraphOperators.java index cccdb053d961..378973c3e629 100644 --- a/gradoop-temporal/src/main/java/org/gradoop/temporal/model/api/TemporalGraphOperators.java +++ b/gradoop-temporal/src/main/java/org/gradoop/temporal/model/api/TemporalGraphOperators.java @@ -17,7 +17,6 @@ import org.gradoop.flink.model.api.epgm.BaseGraphOperators; import org.gradoop.flink.model.impl.epgm.LogicalGraph; -import org.gradoop.flink.model.impl.operators.matching.common.statistics.GraphStatistics; import org.gradoop.temporal.model.api.functions.TemporalPredicate; import org.gradoop.temporal.model.impl.TemporalGraph; import org.gradoop.temporal.model.impl.TemporalGraphCollection; @@ -229,86 +228,6 @@ default TemporalGraph diff(TemporalPredicate firstSnapshot, TemporalPredicate se return callForGraph(new Diff(firstSnapshot, secondSnapshot, dimension)); } - /** - * Evaluates the given query using the Cypher query engine. The engine uses default morphism - * strategies, which is vertex homomorphism and edge isomorphism. The vertex and edge data of - * the data graph elements is attached to the resulting vertices. - * - * Note, that this method used no statistics about the data graph which may result in bad - * runtime performance. Use {@link TemporalGraphOperators#query(String, GraphStatistics)} to - * provide statistics for the query planner. - * - * @param query Cypher query - * @return graph collection containing matching subgraphs - */ - default TemporalGraphCollection query(String query) { - return query(query, new GraphStatistics(1, 1, 1, 1)); - } - - /** - * Evaluates the given query using the Cypher query engine. The engine uses default morphism - * strategies, which is vertex homomorphism and edge isomorphism. The vertex and edge data of - * the data graph elements is attached to the resulting vertices. - *

- * Note, that this method used no statistics about the data graph which may result in bad - * runtime performance. Use {@link TemporalGraphOperators#query(String, GraphStatistics)} to - * provide statistics for the query planner. - *

- * In addition, the operator can be supplied with a construction pattern allowing the creation - * of new graph elements based on variable bindings of the match pattern. Consider the following example: - *
- * {@code graph.query( - * "MATCH (a:Author)-[:WROTE]->(:Paper)<-[:WROTE]-(b:Author) WHERE a <> b", - * "(a)-[:CO_AUTHOR]->(b)") - * } - *

- * The query pattern is looking for pairs of authors that worked on the same paper. The - * construction pattern defines a new edge of type CO_AUTHOR between the two entities. - * - * @param query Cypher query string - * @param constructionPattern Construction pattern - * @return graph collection containing the output of the construct pattern - */ - default TemporalGraphCollection query(String query, String constructionPattern) { - return query(query, constructionPattern, new GraphStatistics(1, 1, 1, 1)); - } - - /** - * Evaluates the given query using the Cypher query engine. The engine uses default morphism - * strategies, which is vertex homomorphism and edge isomorphism. The vertex and edge data of - * the data graph elements is attached to the resulting vertices. - * - * @param query Cypher query - * @param graphStatistics statistics about the data graph - * @return graph collection containing matching subgraphs - */ - default TemporalGraphCollection query(String query, GraphStatistics graphStatistics) { - return query(query, null, graphStatistics); - } - - /** - * Evaluates the given query using the Cypher query engine. The engine uses default morphism - * strategies, which is vertex homomorphism and edge isomorphism. The vertex and edge data of - * the data graph elements is attached to the resulting vertices. - *

- * In addition, the operator can be supplied with a construction pattern allowing the creation - * of new graph elements based on variable bindings of the match pattern. Consider the following example: - *
- * {@code graph.query( - * "MATCH (a:Author)-[:WROTE]->(:Paper)<-[:WROTE]-(b:Author) WHERE a <> b", - * "(a)-[:CO_AUTHOR]->(b)") - * } - *

- * The query pattern is looking for pairs of authors that worked on the same paper. The - * construction pattern defines a new edge of type {@code CO_AUTHOR} between the two entities. - * - * @param query Cypher query - * @param constructionPattern Construction pattern - * @param graphStatistics statistics about the data graph - * @return graph collection containing the output of the construct pattern - */ - TemporalGraphCollection query(String query, String constructionPattern, GraphStatistics graphStatistics); - //---------------------------------------------------------------------------- // Utilities //---------------------------------------------------------------------------- diff --git a/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/TemporalGraph.java b/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/TemporalGraph.java index 3e8d32e8103d..29f3d1dae0d4 100644 --- a/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/TemporalGraph.java +++ b/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/TemporalGraph.java @@ -27,12 +27,6 @@ import org.gradoop.flink.model.api.operators.UnaryBaseGraphToValueOperator; import org.gradoop.flink.model.impl.epgm.LogicalGraph; import org.gradoop.flink.model.impl.epgm.LogicalGraphFactory; -import org.gradoop.flink.model.impl.functions.bool.Not; -import org.gradoop.flink.model.impl.functions.bool.Or; -import org.gradoop.flink.model.impl.functions.bool.True; -import org.gradoop.flink.model.impl.operators.matching.common.MatchStrategy; -import org.gradoop.flink.model.impl.operators.matching.common.statistics.GraphStatistics; -import org.gradoop.flink.model.impl.operators.matching.single.cypher.CypherPatternMatching; import org.gradoop.temporal.io.api.TemporalDataSink; import org.gradoop.temporal.model.api.TemporalGraphOperators; import org.gradoop.temporal.model.impl.functions.tpgm.TemporalEdgeToEdge; @@ -109,20 +103,6 @@ TemporalGraphCollection> getCollectionFactory() { return this.config.getTemporalGraphCollectionFactory(); } - /** - * Returns a 1-element dataset containing a {@link Boolean} value which indicates if the graph is empty. - * - * A graph is considered empty, if it contains no vertices. - * - * @return 1-element dataset containing {@link Boolean#TRUE}, if the collection is - * empty or {@link Boolean#FALSE} if not - */ - public DataSet isEmpty() { - return getVertices().map(new True<>()).distinct() - .union(getConfig().getExecutionEnvironment().fromElements(false)).reduce(new Or()) - .map(new Not()); - } - /** * Writes the graph to given data sink. * @@ -179,17 +159,6 @@ public DataSet getEdgesByLabel(String label) { return this.layout.getEdgesByLabel(label); } - //---------------------------------------------------------------------------- - // Unary Operators - //---------------------------------------------------------------------------- - - @Override - public TemporalGraphCollection query(String query, String constructionPattern, - GraphStatistics graphStatistics) { - return callForCollection(new CypherPatternMatching<>(query, constructionPattern, - true, MatchStrategy.HOMOMORPHISM, MatchStrategy.ISOMORPHISM, graphStatistics)); - } - //---------------------------------------------------------------------------- // Auxiliary Operators //---------------------------------------------------------------------------- diff --git a/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/TemporalGraphCollection.java b/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/TemporalGraphCollection.java index 3c651b7b6a3c..0aec739d270f 100644 --- a/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/TemporalGraphCollection.java +++ b/gradoop-temporal/src/main/java/org/gradoop/temporal/model/impl/TemporalGraphCollection.java @@ -26,9 +26,6 @@ import org.gradoop.flink.model.api.operators.UnaryBaseGraphCollectionToValueOperator; import org.gradoop.flink.model.impl.epgm.GraphCollection; import org.gradoop.flink.model.impl.epgm.GraphCollectionFactory; -import org.gradoop.flink.model.impl.functions.bool.Not; -import org.gradoop.flink.model.impl.functions.bool.Or; -import org.gradoop.flink.model.impl.functions.bool.True; import org.gradoop.flink.model.impl.layouts.transactional.tuples.GraphTransaction; import org.gradoop.flink.util.GradoopFlinkConfig; import org.gradoop.temporal.io.api.TemporalDataSink; @@ -109,21 +106,6 @@ TemporalGraphCollection> getGraphFactory() { return this.config.getTemporalGraphFactory(); } - /** - * Returns a 1-element dataset containing a {@link Boolean} value which indicates if the graph collection - * is empty. - * - * The graph is considered empty if it contains no graphs. - * - * @return 1-element dataset containing {@link Boolean#TRUE} if the collection is empty and - * {@link Boolean#FALSE} otherwise. - */ - public DataSet isEmpty() { - return getGraphHeads().map(new True<>()).distinct() - .union(getConfig().getExecutionEnvironment().fromElements(false)).reduce(new Or()) - .map(new Not()); - } - /** * Writes the graph collection to the given data sink. *