You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/02/07 16:04:11 UTC
svn commit: r1443532 - in /jena/Scratch/AFS/Jena-Dev/trunk/src/dev:
Jena340_TransformFilterNotExists.java Jena389_FilterNotExistsSubQuery.java
jena340/AlgebraQuad2.java jena340/OpWalker2.java jena340/Transformer2.java
Author: andy
Date: Thu Feb 7 15:04:11 2013
New Revision: 1443532
URL: http://svn.apache.org/viewvc?rev=1443532&view=rev
Log: (empty)
Added:
jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java
Removed:
jena/Scratch/AFS/Jena-Dev/trunk/src/dev/jena340/AlgebraQuad2.java
jena/Scratch/AFS/Jena-Dev/trunk/src/dev/jena340/OpWalker2.java
jena/Scratch/AFS/Jena-Dev/trunk/src/dev/jena340/Transformer2.java
Modified:
jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena340_TransformFilterNotExists.java
Modified: jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena340_TransformFilterNotExists.java
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena340_TransformFilterNotExists.java?rev=1443532&r1=1443531&r2=1443532&view=diff
==============================================================================
--- jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena340_TransformFilterNotExists.java (original)
+++ jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena340_TransformFilterNotExists.java Thu Feb 7 15:04:11 2013
@@ -23,23 +23,17 @@ import org.apache.jena.atlas.lib.StrUtil
import com.hp.hpl.jena.query.ARQ ;
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.algebra.Transform ;
+import com.hp.hpl.jena.sparql.algebra.* ;
import com.hp.hpl.jena.sparql.algebra.optimize.TransformPropertyFunction ;
import com.hp.hpl.jena.sparql.sse.SSE ;
import com.hp.hpl.jena.vocabulary.RDFS ;
-import dev.jena340.AlgebraQuad2 ;
-import dev.jena340.Transformer2 ;
-
public class Jena340_TransformFilterNotExists
{
public static void main(String[] args)
{
- //caseSubQueryExisits() ;
- caseExistsNG() ;
- //casePropertyFunctions();
+ //[DONE]caseExistsNG() ;
+ //[DONE]casePropertyFunctions();
System.exit(0) ;
// 1 -- PF does not apply onto quads
@@ -51,57 +45,40 @@ public class Jena340_TransformFilterNotE
// Different transformers manage expr {} differently?
}
- public static void caseSubQueryExisits()
+ public static void caseExistsNG()
{
- // JENA-389
- // Wrong rewrite of FILTER -- too many //
+ // JENA-340
+ // GRAPH in EXISTS not seen.
String qs = StrUtils.strjoinNL(
- "SELECT ?Z # bad",
- //"SELECT * # good",
- "{",
- " SELECT (COUNT(?x1) as ?Z)",
- " WHERE {",
- " ?x1 ?p ?z",
- " FILTER NOT EXISTS {?x1 ?q ?z}",
+ "PREFIX : <http://example/>" ,
+ "SELECT *" ,
+ "{" ,
+ " FILTER (! NOT EXISTS{" ,
+ " GRAPH :BAR { ?s ?p ?o }})",
+ " ?s1 ?p1 ?o1",
+ " GRAPH :GGG {",
+ " FILTER (true && NOT EXISTS{" ,
+ " GRAPH :FOO { ?s ?p ?o }})",
+ " ?s2 ?p2 ?o2",
" }",
- "}") ;
+ "}" ) ;
System.out.println(qs) ;
+ System.out.println("------------") ;
Query query = QueryFactory.create(qs) ;
Op op0 = Algebra.compile(query) ;
- System.out.println(op0) ;
- Op op1 = Algebra.optimize(op0) ;
- System.out.println(op1) ;
- System.out.println("------------") ;
- }
-
- public static void caseExistsNG()
- {
- // JENA-340
- // GRAPH in EXISTS not seen.
-// String qs = StrUtils.strjoinNL(
-// "PREFIX : <http://example/>" ,
-// "SELECT *" ,
-// "{" ,
-// " FILTER NOT EXISTS{" ,
-// " GRAPH :foo { ?s ?p ?o }",
-// "}}" ) ;
-// System.out.println(qs) ;
-// System.out.println("------------") ;
-// Query query = QueryFactory.create(qs) ;
- //Op op0 = Algebra.compile(query) ;
- String $ = StrUtils.strjoinNL("(graph <http://example/GGG>",
- " (filter (notexists",
- " (graph <http://example/AAA>",
- " (bgp (triple ?s ?p ?o))))",
- " (bgp (triple ?s ?p ?o)))",
- ")") ;
- Op op0 = SSE.parseOp($) ;
+// String $ = StrUtils.strjoinNL("(graph <http://example/GGG>",
+// " (filter (notexists",
+// " (graph <http://example/AAA>",
+// " (bgp (triple ?s ?p ?o))))",
+// " (bgp (triple ?s ?p ?o)))",
+// ")") ;
+// Op op0 = SSE.parseOp($) ;
System.out.println("** algebra") ;
System.out.print(op0) ;
System.out.println("------------") ;
//Op op1 = Algebra.toQuadForm(op0) ;
- Op op1 = AlgebraQuad2.quadize(op0) ;
+ Op op1 = AlgebraQuad.quadize(op0) ;
System.out.println("** quads") ;
System.out.print(op1) ;
System.out.println("------------") ;
@@ -116,6 +93,8 @@ public class Jena340_TransformFilterNotE
String qs = StrUtils.strjoinNL("PREFIX : <http://example/>",
"PREFIX rdfs: <"+RDFS.getURI()+">",
"SELECT * {",
+ "?s rdfs:member ?o",
+ " FILTER NOT EXISTS { ?s rdfs:member ?o }",
" GRAPH :g {" ,
" ?s rdfs:member ?o",
" FILTER NOT EXISTS { ?s rdfs:member ?o }",
@@ -127,8 +106,11 @@ public class Jena340_TransformFilterNotE
Op op0 = Algebra.compile(query) ;
System.out.println(op0) ;
Transform t = new TransformPropertyFunction(ARQ.getContext()) ;
- Op op3 = Transformer2.transform(t, op0) ;
+ Op op3 = Transformer.transform(t, op0) ;
+ Op op4 = Algebra.toQuadForm(op3) ;
System.out.println(op3) ;
+ System.out.println(op4) ;
+
if ( true ) return ;
Added: jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java?rev=1443532&view=auto
==============================================================================
--- jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java (added)
+++ jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena389_FilterNotExistsSubQuery.java Thu Feb 7 15:04:11 2013
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dev;
+
+import org.apache.jena.atlas.lib.StrUtils ;
+
+import com.hp.hpl.jena.query.ARQ ;
+import com.hp.hpl.jena.query.Query ;
+import com.hp.hpl.jena.query.QueryFactory ;
+import com.hp.hpl.jena.sparql.algebra.* ;
+import com.hp.hpl.jena.sparql.algebra.optimize.TransformPropertyFunction ;
+import com.hp.hpl.jena.sparql.sse.SSE ;
+import com.hp.hpl.jena.vocabulary.RDFS ;
+
+public class Jena389_FilterNotExistsSubQuery
+{
+ public static void main(String[] args)
+ {
+ caseSubQueryExisits() ;
+ System.exit(0) ;
+ }
+
+ public static void caseSubQueryExisits()
+ {
+ // JENA-389
+ // Wrong rewrite of FILTER -- too many //
+ String qs = StrUtils.strjoinNL(
+ "SELECT ?Z # bad",
+ //"SELECT * # good",
+ "{",
+ " SELECT (COUNT(?x1) as ?Z)",
+ " WHERE {",
+ " ?x1 ?p ?z",
+ " FILTER NOT EXISTS {?x1 ?q ?z}",
+ " }",
+ "}") ;
+ System.out.println(qs) ;
+ Query query = QueryFactory.create(qs) ;
+ Op op0 = Algebra.compile(query) ;
+ System.out.println(op0) ;
+ Op op1 = Algebra.optimize(op0) ;
+ System.out.println(op1) ;
+ System.out.println("------------") ;
+ }
+}