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/04/12 12:47:32 UTC
svn commit: r1467234 -
/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena432_SubQueryRewrites.java
Author: andy
Date: Fri Apr 12 10:47:31 2013
New Revision: 1467234
URL: http://svn.apache.org/r1467234
Log:
Towards a test case for JENA-432
Added:
jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena432_SubQueryRewrites.java
Added: jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena432_SubQueryRewrites.java
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena432_SubQueryRewrites.java?rev=1467234&view=auto
==============================================================================
--- jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena432_SubQueryRewrites.java (added)
+++ jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena432_SubQueryRewrites.java Fri Apr 12 10:47:31 2013
@@ -0,0 +1,82 @@
+/**
+ * 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 java.util.Set ;
+
+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.algebra.OpVars ;
+import com.hp.hpl.jena.sparql.core.Var ;
+import com.hp.hpl.jena.sparql.sse.SSE ;
+
+public class Jena432_SubQueryRewrites
+{
+ public static void main(String... args) throws Exception
+ {
+ if ( false )
+ {
+ Op op = SSE.parseOp("(leftjoin (bgp (?s1 ?p1 ?o1)) (project (?s2) (bgp (?s2 ?p2 ?o2))))") ;
+ System.out.println(op) ;
+ Set<Var> vars = OpVars.patternVars(op) ;
+ System.out.println(vars) ;
+ System.exit(0) ;
+ }
+ String qs1 = StrUtils.strjoinNL
+ ( "SELECT *",
+ "WHERE {",
+ " ?test ?p1 ?o1.",
+ //" FILTER ( ?test = <http://localhost/t1> || ?test = <http://localhost/t2> )",
+ //" FILTER ( ?test = <http://localhost/t1> )",
+ " OPTIONAL {",
+ " SELECT ?s1", // Not ?test
+ " { ?s1 ?p2 ?o2 }", //" GROUP BY ?s1",
+ " }" ,
+ "}" ) ;
+
+ // No (conditional) optimization.
+ String qs2 = StrUtils.strjoinNL
+ ( "SELECT *",
+ "WHERE {",
+ " ?test ?p1 ?o1.",
+ " OPTIONAL {",
+ " SELECT ?s1",
+ " { ?s1 ?p2 ?o2 }", //" GROUP BY ?s1",
+ " }" ,
+ "}" ) ;
+
+ String qs = qs2 ;
+ Query query = QueryFactory.create(qs) ;
+ Op op = Algebra.compile(query) ;
+ System.out.println(query) ;
+ System.out.println(op) ;
+// Op op1 = Transformer.transform(new TransformFilterDisjunction(), op) ;
+// Op op1 = Transformer.transform(new TransformFilterEquality(), op) ;
+
+ //Op opX = SSE.parseOp("") ;
+ Op op1 = Algebra.optimize(op) ;
+ System.out.println(op1) ;
+ }
+
+}
+