marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sschaff...@apache.org
Subject git commit: support subqueries in JOIN (MARMOTTA-538)
Date Wed, 17 Sep 2014 16:33:50 GMT
Repository: marmotta
Updated Branches:
  refs/heads/develop 6d81ef534 -> f222bf4c5


support subqueries in JOIN (MARMOTTA-538)


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/f222bf4c
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/f222bf4c
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/f222bf4c

Branch: refs/heads/develop
Commit: f222bf4c57c08fd0c5abc16d2e374c46bf07d884
Parents: 6d81ef5
Author: Sebastian Schaffert <sschaffert@apache.org>
Authored: Wed Sep 17 18:34:08 2014 +0200
Committer: Sebastian Schaffert <sschaffert@apache.org>
Committed: Wed Sep 17 18:34:08 2014 +0200

----------------------------------------------------------------------
 .../marmotta/kiwi/sparql/builder/GroupFinder.java     | 14 +++++++++++---
 .../kiwi/sparql/builder/PatternCollector.java         |  6 ++++++
 .../marmotta/kiwi/sparql/builder/SQLSubQuery.java     |  6 +++---
 .../sparql/evaluation/KiWiEvaluationStrategyImpl.java |  2 ++
 4 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/f222bf4c/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/GroupFinder.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/GroupFinder.java
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/GroupFinder.java
index 515cf7d..f492439 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/GroupFinder.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/GroupFinder.java
@@ -17,9 +17,7 @@
 
 package org.apache.marmotta.kiwi.sparql.builder;
 
-import org.openrdf.query.algebra.Group;
-import org.openrdf.query.algebra.GroupElem;
-import org.openrdf.query.algebra.TupleExpr;
+import org.openrdf.query.algebra.*;
 import org.openrdf.query.algebra.helpers.QueryModelVisitorBase;
 
 import java.util.ArrayList;
@@ -47,4 +45,14 @@ public class GroupFinder extends QueryModelVisitorBase<RuntimeException>
{
         elements.addAll(node.getGroupElements());
         super.meet(node);
     }
+
+    @Override
+    public void meet(Projection node) throws RuntimeException {
+        // stop at projection, subquery
+    }
+
+    @Override
+    public void meet(Union node) throws RuntimeException {
+        // stop at union, subquery
+    }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/f222bf4c/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/PatternCollector.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/PatternCollector.java
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/PatternCollector.java
index bb8f254..1f44ca1 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/PatternCollector.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/PatternCollector.java
@@ -86,4 +86,10 @@ public class PatternCollector extends QueryModelVisitorBase<RuntimeException>
{
         parts.getLast().getSubqueries().add(new SQLUnion("U" + (++counter),node, bindings,
dataset, converter, dialect));
     }
 
+    @Override
+    public void meet(Projection node) throws RuntimeException {
+        // subqueries are represented with a projection inside a JOIN; we don't continue
collection
+
+        parts.getLast().getSubqueries().add(new SQLSubQuery("S" + (++counter), node, bindings,
dataset, converter, dialect));
+    }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/f222bf4c/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLSubQuery.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLSubQuery.java
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLSubQuery.java
index b6c7215..4f6ca41 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLSubQuery.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/builder/SQLSubQuery.java
@@ -21,7 +21,7 @@ import org.apache.marmotta.kiwi.persistence.KiWiDialect;
 import org.apache.marmotta.kiwi.sparql.exception.UnsatisfiableQueryException;
 import org.openrdf.query.BindingSet;
 import org.openrdf.query.Dataset;
-import org.openrdf.query.algebra.SubQueryValueOperator;
+import org.openrdf.query.algebra.Projection;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -38,11 +38,11 @@ public class SQLSubQuery extends SQLAbstractSubquery {
 
     private Set<SQLVariable> variables = new HashSet<>();
 
-    public SQLSubQuery(String alias, SubQueryValueOperator query, BindingSet bindings, Dataset
dataset, ValueConverter converter, KiWiDialect dialect) throws UnsatisfiableQueryException
{
+    public SQLSubQuery(String alias, Projection query, BindingSet bindings, Dataset dataset,
ValueConverter converter, KiWiDialect dialect) throws UnsatisfiableQueryException {
         super(alias);
 
         // we build a full subquery for each of the UNION's arguments
-        builder = new SQLBuilder(query.getSubQuery(), bindings, dataset, converter, dialect);
+        builder = new SQLBuilder(query.getArg(), bindings, dataset, converter, dialect);
 
         for(SQLVariable svl : builder.getVariables().values()) {
             variables.add(svl);

http://git-wip-us.apache.org/repos/asf/marmotta/blob/f222bf4c/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
index 89da038..4259e49 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
@@ -336,6 +336,8 @@ public class KiWiEvaluationStrategyImpl extends EvaluationStrategyImpl{
             return isSupported(((Distinct) expr).getArg());
         } else if(expr instanceof Union) {
             return isSupported(((Union) expr).getLeftArg()) && isSupported(((Union)expr).getRightArg());
+        } else if(expr instanceof Projection) {
+            return isSupported(((Projection) expr).getArg());
         } else if(expr instanceof Order) {
             for(OrderElem elem : ((Order) expr).getElements()) {
                 if(!isSupported(elem.getExpr())) {


Mime
View raw message