jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [8/8] jena git commit: JENA-1028: OpDisjunction and Op1 operations.
Date Wed, 16 Sep 2015 15:18:45 GMT
JENA-1028: OpDisjunction and Op1 operations.


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

Branch: refs/heads/master
Commit: 96563de05192c7dbdbd0bfc025613be06aeffe52
Parents: 8956f92
Author: Andy Seaborne <andy@apache.org>
Authored: Wed Sep 16 10:15:57 2015 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Wed Sep 16 16:18:10 2015 +0100

----------------------------------------------------------------------
 .../jena/sparql/engine/main/VarFinder.java      | 71 +++++++++-----------
 1 file changed, 32 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/96563de0/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java
index e04de77..b6824a4 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java
@@ -139,17 +139,17 @@ public class VarFinder
 
         @Override
         public void visit(OpJoin opJoin) {
-            joinAcc(opJoin.getLeft());
-            joinAcc(opJoin.getRight());
+            mergeVars(opJoin.getLeft());
+            mergeVars(opJoin.getRight());
         }
 
         @Override
         public void visit(OpSequence opSequence) {
             for ( Op op : opSequence.getElements() )
-                joinAcc(op);
+                mergeVars(op);
         }
 
-        private void joinAcc(Op op) {
+        private void mergeVars(Op op) {
             VarUsageVisitor usage = VarUsageVisitor.apply(op);
             defines.addAll(usage.defines);
             optDefines.addAll(usage.optDefines);
@@ -164,7 +164,7 @@ public class VarFinder
 
         @Override
         public void visit(OpMinus opMinus) {
-            joinAcc(opMinus.getLeft()) ;
+            mergeVars(opMinus.getLeft()) ;
             VarUsageVisitor usage = VarUsageVisitor.apply(opMinus.getRight());
             // Everything in the right side is really a filter.  
             filterMentions.addAll(usage.defines) ;
@@ -203,20 +203,13 @@ public class VarFinder
 
         @Override
         public void visit(OpUnion opUnion) {
-            VarUsageVisitor leftUsage = VarUsageVisitor.apply(opUnion.getLeft());
-            VarUsageVisitor rightUsage = VarUsageVisitor.apply(opUnion.getRight());
-
-            // defines = union(left.define, right.define) ??
-            // Can be both definite and optional (different sides).
-            defines.addAll(leftUsage.defines);
-            optDefines.addAll(leftUsage.optDefines);
-            filterMentions.addAll(leftUsage.filterMentions);
-            assignMentions.addAll(leftUsage.assignMentions);
-            
-            defines.addAll(rightUsage.defines);
-            optDefines.addAll(rightUsage.optDefines);
-            filterMentions.addAll(rightUsage.filterMentions);
-            assignMentions.addAll(rightUsage.assignMentions);
+            mergeVars(opUnion.getLeft());
+            mergeVars(opUnion.getRight());
+        }
+        
+        @Override
+        public void visit(OpDisjunction opDisjunction) {
+            opDisjunction.getElements().forEach(op->mergeVars(op));
         }
 
         @Override
@@ -278,47 +271,47 @@ public class VarFinder
             VarUtils.addVarNodes(defines, opPropFunc.getSubjectArgs().getArgList()) ;
             VarUtils.addVarNodes(defines, opPropFunc.getObjectArgs().getArgList()) ;
         }
-        
-        // Not implemented: with checking. 
 
-        private void no() { 
-            throw new NotImplemented() ;
-        }
+        // Ops that add nothing to variable scoping.
+        // Some can't appear without being inside a project anyway
+        // but we process generally where possible. 
         
         @Override
-        public void visit(OpProcedure opProc) { no() ; }
-
+        public void visit(OpReduced opReduced)      { mergeVars(opReduced.getSubOp()) ; }
 
         @Override
-        public void visit(OpService opService) { no(); }
+        public void visit(OpDistinct opDistinct)    { mergeVars(opDistinct.getSubOp()) ;
}
 
         @Override
-        public void visit(OpDatasetNames dsNames) { no(); }
+        public void visit(OpSlice opSlice)          { mergeVars(opSlice.getSubOp()) ; }
 
         @Override
-        public void visit(OpLabel opLabel) { no(); }
+        public void visit(OpLabel opLabel)          { mergeVars(opLabel.getSubOp()) ; }
 
         @Override
-        public void visit(OpDiff opDiff) { no(); }
-
-        @Override
-        public void visit(OpDisjunction opDisjunction) { no(); }
+        public void visit(OpList opList)            { mergeVars(opList.getSubOp()) ; }
+        
+        // Not implemented: with checking. 
 
+        private void no() { 
+            throw new NotImplemented() ;
+        }
+        
         @Override
-        public void visit(OpList opList) { no(); }
+        public void visit(OpProcedure opProc) { no() ; }
 
         @Override
-        public void visit(OpOrder opOrder) { no(); }
+        public void visit(OpService opService) { no(); }
 
         @Override
-        public void visit(OpReduced opReduced) { no(); }
+        public void visit(OpDatasetNames dsNames) { no(); }
 
         @Override
-        public void visit(OpDistinct opDistinct) { no(); }
+        public void visit(OpDiff opDiff) { no(); }
 
         @Override
-        public void visit(OpSlice opSlice) { no(); }
-
+        public void visit(OpOrder opOrder) { no(); }
+        
         @Override
         public void visit(OpGroup opGroup) { no(); }
 


Mime
View raw message