jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1455264 - in /jena/Scratch/AFS/Jena-Dev/trunk/src: dev/Jena389_FilterNotExistsSubQuery.java reports/archive/Jena389_FilterNotExistsSubQuery.java
Date Mon, 11 Mar 2013 18:01:00 GMT
Author: andy
Date: Mon Mar 11 18:00:59 2013
New Revision: 1455264

URL: http://svn.apache.org/r1455264
Log: (empty)

Added:
    jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena389_FilterNotExistsSubQuery.java
      - copied, changed from r1446696, jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java
Removed:
    jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java

Copied: jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena389_FilterNotExistsSubQuery.java
(from r1446696, jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java)
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena389_FilterNotExistsSubQuery.java?p2=jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena389_FilterNotExistsSubQuery.java&p1=jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java&r1=1446696&r2=1455264&rev=1455264&view=diff
==============================================================================
--- jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java (original)
+++ jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena389_FilterNotExistsSubQuery.java
Mon Mar 11 18:00:59 2013
@@ -16,14 +16,14 @@
  * limitations under the License.
  */
 
-package dev;
+package reports.archive;
 
 import org.apache.jena.atlas.lib.StrUtils ;
 
-import com.hp.hpl.jena.query.Query ;
-import com.hp.hpl.jena.query.QueryFactory ;
 import com.hp.hpl.jena.sparql.algebra.Algebra ;
 import com.hp.hpl.jena.sparql.algebra.Op ;
+import com.hp.hpl.jena.sparql.sse.SSE ;
+
 
 public class Jena389_FilterNotExistsSubQuery
 {
@@ -32,54 +32,13 @@ public class Jena389_FilterNotExistsSubQ
         caseSubQueryExisits() ;
         System.exit(0) ;
     }
+    //    NodeTransformLib.transform
     
     public static void caseSubQueryExisits()
     {
         // Issue:
         // Transformer (for {} in expressions) and NodeTransformOp walk into expressions
- can happen twice.
         // ExprTrans
-        
-        // See Transformer and commented out 
-        
-//      @Override
-//      public void visit(OpLeftJoin op) 
-//      { 
-//          Op left = null ;
-//          Op right = null ;
-//  
-//          // Must do right-left because the pushes onto the stack were left-right. 
-//          if ( op.getRight() != null )
-//              right = pop() ;
-//          if ( op.getLeft() != null )
-//              left = pop() ;
-//          
-//          ExprList exprList = transform(op.getExprs(), exprTransform) ;
-//          
-//          boolean changed = ( left != op.getLeft() || right != op.getRight() || exprList
!= op.getExprs() ) ;
-//          OpLeftJoin op2 = changed ? OpLeftJoin.createLeftJoin(left, right, exprList) :
op ;
-//          Op opX = op2.apply(transform, left, right) ;
-//          push(opX) ;
-//      }
-
-        // ----- NodeTransformOp
-        // This finds everywhere that node can lurk in an alegbra expression:
-        //   BGPs, paths, triples, quads
-        //   GRAPH, GRAPH{} (DatasetNames)
-        //   Project
-        // ???? Needs checking.
-        // But not in expressions (that's handled by Transformer)
-        //    Filters, including inside EXISTS and expressions in LeftJoin
-        //    OrderBy, GroupBy
-        //    Tables
-        //    Projects
-        // Just the AS variable:
-        //    Extend, Assign
-        // ----- NodeTransformOp
-        
-        // Nor:
-        //   Conditional (no expression)
-        
-        
         // JENA-389
         // Wrong rewrite of FILTER -- too many //  
         String qs1 = StrUtils.strjoinNL(
@@ -103,13 +62,58 @@ public class Jena389_FilterNotExistsSubQ
                                        "    OPTIONAL{ ?x ?y ?z FILTER NOT EXISTS {?x1 ?q
?z} }",
                                        "   }",
                                        "}") ;
-        String qs = qs1 ;
-        System.out.println(qs) ;
-        Query query = QueryFactory.create(qs) ;
-        Op op0 = Algebra.compile(query) ;
-        System.out.println(op0) ;
+        // test case.
+//        String qs = qs1 ;
+//        System.out.println(qs) ;
+//        Query query = QueryFactory.create(qs) ;
+//        Op op0 = Algebra.compile(query) ;
+//        System.out.println("---- Compiled") ;
+//        System.out.println(op0) ;
+
+        
+        // Reduced to essential step.
+        String alg1 = StrUtils.strjoinNL
+            ("(project (?Z)" ,
+             "  (project (?Z)" ,
+             "    (extend ((?Z ?.0))" ,
+             "      (group () ((?.0 (count ?x1)))" ,
+             "        (filter (notexists (bgp (triple ?s ?q ?a)))" ,
+             "          (bgp (triple ?x1 ?p ?b)))))))") ;
+
+        String alg2 = StrUtils.strjoinNL
+            ("(filter (notexists (bgp (triple <B> <q> ?v)))" ,
+             "   (bgp (triple <A> <p> ?x)))") ;
+
+        Op op0 = SSE.parseOp(alg1) ;
+        System.out.println("---- Compiled") ;
+        System.out.print(op0) ;
+        
+        System.out.println("---- Scoped") ;
+        
+        // Finds the BGP in the NOT EXISTS
+        //   Via the transform
+        //   Via the exprtransform
+        
+        
+        // Op op1 =  TransformScopeRename.transform(op0) ;
+        // Essence;
+        //Rename.renameVars() with const ?Z
+        //Collection<Var> consts = Arrays.asList() ; //Var.alloc("Z")) ; 
+        //Op op1 = Rename.renameVars(op0, consts) ;
+        
+        //Op op1 = NodeTransformLib.transform(new RenameAnyVars(consts, ":"), op0) ;
+        // becomes;
+        
+//        NodeTransform nt = new Rename2.RenameAnyVars(consts, ":") ;
+//        Transform opTransform = new NodeTransformOp2(nt) ; 
+//        Op op1 = Transformer.transform(opTransform, /*null,*/ op0, null, null) ;
+        
+        // change NodeTransformOp2 to not follow 
+        // Sholddn't Transformer follw expressions in Assign/Extend?
+        // Transformer.transform(transform, exprTransform, op) ;
+        
+        //System.out.println("---- Optimized") ;
         Op op1 = Algebra.optimize(op0) ;
-        System.out.println(op1) ;
-        System.out.println("------------") ;
+        System.out.print(op1) ;
     }
 }



Mime
View raw message