jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1190018 - in /incubator/jena/Jena2/ARQ/trunk/src: main/java/com/hp/hpl/jena/sparql/algebra/ main/java/com/hp/hpl/jena/sparql/algebra/op/ main/java/com/hp/hpl/jena/sparql/algebra/optimize/ main/java/com/hp/hpl/jena/sparql/engine/main/ main/...
Date Thu, 27 Oct 2011 20:49:39 GMT
Author: andy
Date: Thu Oct 27 20:49:38 2011
New Revision: 1190018

URL: http://svn.apache.org/viewvc?rev=1190018&view=rev
Log:
Add OpQuad ; Create (triple,quad) block to join converter.

Added:
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuad.java
  (with props)
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java
  (with props)
    incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestPattern2Join.java
  (with props)
Modified:
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitor.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorBase.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorByType.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/Transform.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformBase.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformCopy.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformWrapper.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpBase.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpDatasetNames.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpJoin.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuadPattern.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/ExecutionDispatch.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/OpExecutor.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/ref/EvaluatorDispatch.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/Tags.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/builders/BuilderOp.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/writers/WriterOp.java
    incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/TS_Algebra.java

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java
Thu Oct 27 20:49:38 2011
@@ -122,6 +122,11 @@ public class OpAsQuery
         { currentGroup().addElement(process(opTriple.getTriple())) ; }
 
         @Override
+        public void visit(OpQuad opQuad)
+        { throw new ARQNotImplemented("OpQuad") ; }
+
+
+        @Override
         public void visit(OpProcedure opProcedure)
         {
             throw new ARQNotImplemented("OpProcedure") ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitor.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitor.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitor.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitor.java
Thu Oct 27 20:49:38 2011
@@ -26,6 +26,7 @@ public interface OpVisitor
     public void visit(OpBGP opBGP) ;
     public void visit(OpQuadPattern quadPattern) ;
     public void visit(OpTriple opTriple) ;
+    public void visit(OpQuad opQuad) ;
     public void visit(OpPath opPath) ;
     public void visit(OpTable opTable) ;
     public void visit(OpNull opNull) ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorBase.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorBase.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorBase.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorBase.java
Thu Oct 27 20:49:38 2011
@@ -23,132 +23,70 @@ import com.hp.hpl.jena.sparql.algebra.op
 
 public class OpVisitorBase implements OpVisitor
 {
-
-    @Override
-    public void visit(OpBGP opBGP)
-    {}
-
-    @Override
-    public void visit(OpQuadPattern quadPattern)
-    {}
-    
-    @Override
-    public void visit(OpTriple opTriple)
-    {}
-
-    @Override
-    public void visit(OpPath opPath)
-    {}
-
-    @Override
-    public void visit(OpProcedure opProc)
-    {}
-    
-    @Override
-    public void visit(OpPropFunc opPropFunc)
-    {}
-    
-    @Override
-    public void visit(OpJoin opJoin)
-    {}
-
-    @Override
-    public void visit(OpSequence opSequence)
-    {}
-    
-    @Override
-    public void visit(OpDisjunction opDisjunction)
-    {}
-
-    @Override
-    public void visit(OpLeftJoin opLeftJoin)
-    {}
-
-    @Override
-    public void visit(OpConditional opCond)
-    {}
-
-    @Override
-    public void visit(OpMinus opMinus)
-    {}
-    
-    @Override
-    public void visit(OpDiff opDiff)
-    {}
-    
-    @Override
-    public void visit(OpUnion opUnion)
-    {}
-
-    @Override
-    public void visit(OpFilter opFilter)
-    {}
-
-    @Override
-    public void visit(OpGraph opGraph)
-    {}
-
-    @Override
-    public void visit(OpService opService)
-    {}
-
-    @Override
-    public void visit(OpDatasetNames dsNames)
-    {}
-
-    @Override
-    public void visit(OpTable opUnit)
-    {}
-
-    @Override
-    public void visit(OpExt opExt)
-    {}
-
-    @Override
-    public void visit(OpNull opNull)
-    {}
-
-    @Override
-    public void visit(OpLabel opLabel)
-    {}
-
-    @Override
-    public void visit(OpAssign opAssign)
-    {}
-
-    @Override
-    public void visit(OpExtend opExtend)
-    {}
-
-    @Override
-    public void visit(OpList opList)
-    {}
-
-    @Override
-    public void visit(OpOrder opOrder)
-    {}
-
-    @Override
-    public void visit(OpProject opProject)
-    {}
-
-    @Override
-    public void visit(OpDistinct opDistinct)
-    {}
-
-    @Override
-    public void visit(OpReduced opReduced)
-    {}
-
-    @Override
-    public void visit(OpSlice opSlice)
-    {}
-
-    @Override
-    public void visit(OpGroup opGroup)
-    {}
-    
-    @Override
-    public void visit(OpTopN opTop)
-    {}
+
+    @Override public void visit(OpBGP opBGP)                    {}
+
+    @Override public void visit(OpQuadPattern quadPattern)      {}
+    
+    @Override public void visit(OpTriple opTriple)              {}
+ 
+    @Override public void visit(OpQuad opQuad)                  {}
+
+    @Override public void visit(OpPath opPath)                  {}
+
+    @Override public void visit(OpProcedure opProc)             {}
+    
+    @Override public void visit(OpPropFunc opPropFunc)          {}
+    
+    @Override public void visit(OpJoin opJoin)                  {}
+
+    @Override public void visit(OpSequence opSequence)          {}
+    
+    @Override public void visit(OpDisjunction opDisjunction)    {}
+
+    @Override public void visit(OpLeftJoin opLeftJoin)          {}
+
+    @Override public void visit(OpConditional opCond)           {}
+
+    @Override public void visit(OpMinus opMinus)                {}
+    
+    @Override public void visit(OpDiff opDiff)                  {}
+    
+    @Override public void visit(OpUnion opUnion)                {}
+
+    @Override public void visit(OpFilter opFilter)              {}
+
+    @Override public void visit(OpGraph opGraph)                {}
+
+    @Override public void visit(OpService opService)            {}
+
+    @Override public void visit(OpDatasetNames dsNames)         {}
+
+    @Override public void visit(OpTable opTable)                {}
+
+    @Override public void visit(OpExt opExt)                    {}
+
+    @Override public void visit(OpNull opNull)                  {}
+
+    @Override public void visit(OpLabel opLabel)                {}
+
+    @Override public void visit(OpAssign opAssign)              {}
+
+    @Override public void visit(OpExtend opExtend)              {}
+
+    @Override public void visit(OpList opList)                  {}
+
+    @Override public void visit(OpOrder opOrder)                {}
+
+    @Override public void visit(OpProject opProject)            {}
+
+    @Override public void visit(OpDistinct opDistinct)          {}
+
+    @Override public void visit(OpReduced opReduced)            {}
+
+    @Override public void visit(OpSlice opSlice)                {}
+
+    @Override public void visit(OpGroup opGroup)                {}
+    
+    @Override public void visit(OpTopN opTop)                   {}
 }

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorByType.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorByType.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorByType.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/OpVisitorByType.java
Thu Oct 27 20:49:38 2011
@@ -49,6 +49,10 @@ public abstract class OpVisitorByType im
     { visit0(opTriple) ; }
     
     @Override
+    public void visit(OpQuad opQuad)
+    { visit0(opQuad) ; }
+
+    @Override
     public void visit(OpPath opPath)
     { visit0(opPath) ; }
     

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/Transform.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/Transform.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/Transform.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/Transform.java
Thu Oct 27 20:49:38 2011
@@ -28,6 +28,7 @@ public interface Transform
     public Op transform(OpTable opUnit) ;
     public Op transform(OpBGP opBGP) ;
     public Op transform(OpTriple opTriple) ;
+    public Op transform(OpQuad opQuad) ;
     public Op transform(OpPath opPath) ;
     public Op transform(OpDatasetNames dsNames) ;
     public Op transform(OpQuadPattern quadPattern) ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformBase.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformBase.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformBase.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformBase.java
Thu Oct 27 20:49:38 2011
@@ -31,6 +31,8 @@ public class TransformBase implements Tr
     @Override
     public Op transform(OpTriple opTriple)                  { return opTriple ; }
     @Override
+    public Op transform(OpQuad opQuad)                      { return opQuad ; }
+    @Override
     public Op transform(OpPath opPath)                      { return opPath ; } 
 
     @Override

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformCopy.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformCopy.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformCopy.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformCopy.java
Thu Oct 27 20:49:38 2011
@@ -41,7 +41,9 @@ public class TransformCopy implements Tr
     @Override
     public Op transform(OpQuadPattern opQuadPattern)                { return xform(opQuadPattern)
; }
     @Override
-    public Op transform(OpTriple opTriple)                          { return xform(opTriple)
; }
+    public Op transform(OpTriple opTriple)                          { return xform(opTriple)
; }
+    @Override
+    public Op transform(OpQuad opQuad)                              { return xform(opQuad)
; }
     @Override
     public Op transform(OpPath opPath)                              { return xform(opPath)
; }
 

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformWrapper.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformWrapper.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformWrapper.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/TransformWrapper.java
Thu Oct 27 20:49:38 2011
@@ -22,7 +22,7 @@ import java.util.List ;
 
 import com.hp.hpl.jena.sparql.algebra.op.* ;
 
-/** Wrap another tranform and pass on the transform operation */
+/** Wrap another transform and pass on the transform operation */
 public class TransformWrapper implements Transform
 {
     protected final Transform transform ;
@@ -39,6 +39,8 @@ public class TransformWrapper implements
     @Override
     public Op transform(OpTriple opTriple)                  { return transform.transform(opTriple)
; }
     @Override
+    public Op transform(OpQuad opQuad)                      { return transform.transform(opQuad)
; }
+    @Override
     public Op transform(OpPath opPath)                      { return transform.transform(opPath)
; } 
 
     @Override

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpBase.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpBase.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpBase.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpBase.java
Thu Oct 27 20:49:38 2011
@@ -73,6 +73,7 @@ public abstract class OpBase extends Pri
     static final int HashSequence               = 0xB8 ;
     static final int HashLabel                  = 0xB9 ;
     static final int HashTriple                 = 0xBA ;
+    static final int HashQuad                 = 0xBB ;
 
 
 }

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpDatasetNames.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpDatasetNames.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpDatasetNames.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpDatasetNames.java
Thu Oct 27 20:49:38 2011
@@ -22,6 +22,7 @@ import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.sparql.algebra.Op ;
 import com.hp.hpl.jena.sparql.algebra.OpVisitor ;
 import com.hp.hpl.jena.sparql.algebra.Transform ;
+import com.hp.hpl.jena.sparql.sse.Tags ;
 import com.hp.hpl.jena.sparql.util.NodeIsomorphismMap ;
 
 public class OpDatasetNames extends Op0
@@ -36,7 +37,7 @@ public class OpDatasetNames extends Op0
     }
 
     @Override
-    public String getName()                 { return "DatasetNames" ; }
+    public String getName()                 { return Tags.tagDatasetNames ; } 
 
     @Override
     public Op apply(Transform transform)    { return transform.transform(this) ; } 

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpJoin.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpJoin.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpJoin.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpJoin.java
Thu Oct 27 20:49:38 2011
@@ -31,7 +31,7 @@ public class OpJoin extends Op2
     public static Op create(Op left, Op right)
     {
         // Don't simplify here - changes SPARQL for OPTIONAL {{ FILTER }}
-        // The  {{}} reslts in (join unit (filter ...)) the filter is not moved
+        // The  {{}} results in (join unit (filter ...)) the filter is not moved
         // into the LeftJoin.  
         
 //        // Inline simplification (too early - changes SPARQL for OPTIONAL {{ FILTER }}


Added: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuad.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuad.java?rev=1190018&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuad.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuad.java
Thu Oct 27 20:49:38 2011
@@ -0,0 +1,100 @@
+/**
+ * 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 com.hp.hpl.jena.sparql.algebra.op;
+
+import com.hp.hpl.jena.sparql.algebra.Op ;
+import com.hp.hpl.jena.sparql.algebra.OpVisitor ;
+import com.hp.hpl.jena.sparql.algebra.Transform ;
+import com.hp.hpl.jena.sparql.core.BasicPattern ;
+import com.hp.hpl.jena.sparql.core.Quad ;
+import com.hp.hpl.jena.sparql.core.QuadPattern ;
+import com.hp.hpl.jena.sparql.sse.Tags ;
+import com.hp.hpl.jena.sparql.util.NodeIsomorphismMap ;
+import com.hp.hpl.jena.sparql.util.Utils ;
+
+/** Algebra operation for a single quad.
+ * @see OpTriple
+ */ 
+public class OpQuad extends Op0
+{
+    private final Quad quad ;
+    private OpQuadPattern opQuadPattern = null ;
+    
+    public OpQuad(Quad quad)
+    {
+        this.quad = quad ;
+    }
+    
+    public final Quad getQuad() { return quad ; }
+    
+
+    public OpQuadPattern asQuadPattern()
+    {
+        if ( opQuadPattern == null )
+        {
+            BasicPattern bp = new BasicPattern() ;
+            bp.add(getQuad().asTriple()) ;
+            opQuadPattern = new OpQuadPattern(quad.getGraph(),bp) ;
+        }
+        return opQuadPattern ;
+    }
+    
+    @Override
+    public Op apply(Transform transform)
+    { return transform.transform(this) ; }
+
+    @Override
+    public Op copy()
+    {
+        return new OpQuad(quad) ;
+    }
+
+    @Override
+    public boolean equalTo(Op other, NodeIsomorphismMap labelMap)
+    {
+        if ( ! (other instanceof OpQuad) )
+            return false ;
+        OpQuad opQuad = (OpQuad)other ;
+        return Utils.quadIso(getQuad(), opQuad.getQuad(), labelMap) ;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return OpBase.HashTriple ^ quad.hashCode() ;
+    }
+
+    @Override
+    public void visit(OpVisitor opVisitor)
+    { opVisitor.visit(this) ; }
+
+    @Override
+    public String getName()
+    {
+        return Tags.tagTriple ;
+    }
+
+    public boolean equivalent(OpQuadPattern opQuads)
+    {
+        QuadPattern quads = opQuads.getPattern() ;
+        if ( quads.size() != 1 ) return false ;
+        Quad q = quads.get(0) ;
+        return quad.equals(q) ;  
+    }
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuad.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuadPattern.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuadPattern.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuadPattern.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/op/OpQuadPattern.java
Thu Oct 27 20:49:38 2011
@@ -71,13 +71,6 @@ public class OpQuadPattern extends Op0
         return quads ;
     } 
     
-//    @Deprecated
-//    public List<Quad> getQuads()
-//    {
-//        initQuads() ;
-//        return quads.getList() ;
-//    }
-    
     public Node getGraphNode()              { return graphNode ; } 
     public BasicPattern getBasicPattern()   { return triples ; }
     public boolean isEmpty()                { return triples.size() == 0 ; }

Added: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java?rev=1190018&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java
Thu Oct 27 20:49:38 2011
@@ -0,0 +1,72 @@
+/**
+ * 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 com.hp.hpl.jena.sparql.algebra.optimize;
+
+import com.hp.hpl.jena.graph.Triple ;
+import com.hp.hpl.jena.sparql.algebra.Op ;
+import com.hp.hpl.jena.sparql.algebra.TransformCopy ;
+import com.hp.hpl.jena.sparql.algebra.op.* ;
+import com.hp.hpl.jena.sparql.core.BasicPattern ;
+import com.hp.hpl.jena.sparql.core.Quad ;
+import com.hp.hpl.jena.sparql.core.QuadPattern ;
+
+public class TransformPattern2Join extends TransformCopy
+{
+    @Override
+    public Op transform(OpBGP opBGP)                        { return expand(opBGP.getPattern())
; }
+    
+    @Override
+    public Op transform(OpQuadPattern quadPattern)          { return expand(quadPattern.getPattern())
; }
+
+    public static Op expand(BasicPattern bgp)
+    {
+        if ( bgp.getList().isEmpty() )
+            return OpTable.unit() ;
+        Op op = null ;
+        for ( Triple t : bgp.getList() )
+        {
+            OpTriple x = new OpTriple(t) ;
+            op = join(op, x) ;
+        }
+        return op ;
+    }
+    
+    public static Op expand(QuadPattern quads)
+    {
+        if ( quads.getList().isEmpty() )
+            return OpTable.unit() ;
+        Op op = null ;
+        for ( Quad q : quads.getList() )
+        {
+            OpQuad x = new OpQuad(q) ;
+            op = join(op, x) ;
+        }
+        return op ;
+    }
+    
+    
+    private static Op join(Op left, Op right)
+    {
+        if ( left == null || OpJoin.isJoinIdentify(left) )
+          return right ;
+      if ( right == null || OpJoin.isJoinIdentify(right) )
+          return left ;
+      return OpJoin.create(left, right) ;
+  }
+}

Propchange: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/ExecutionDispatch.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/ExecutionDispatch.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/ExecutionDispatch.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/ExecutionDispatch.java
Thu Oct 27 20:49:38 2011
@@ -75,6 +75,14 @@ class ExecutionDispatch implements OpVis
     }
 
     @Override
+    public void visit(OpQuad opQuad)
+    {
+        QueryIterator input = pop() ;
+        QueryIterator qIter = opExecutor.execute(opQuad, input) ;
+        push(qIter) ;
+    }
+
+    @Override
     public void visit(OpPath opPath)
     {
         QueryIterator input = pop() ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/OpExecutor.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/OpExecutor.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/OpExecutor.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/main/OpExecutor.java
Thu Oct 27 20:49:38 2011
@@ -136,6 +136,12 @@ public class OpExecutor
         return execute(opTriple.asBGP(), input) ;
     }
 
+    protected QueryIterator execute(OpQuad opQuad, QueryIterator input)
+    {
+        return execute(opQuad.asQuadPattern(), input) ;
+    }
+
+
     protected QueryIterator execute(OpQuadPattern quadPattern, QueryIterator input)
     {
         // Convert to BGP forms to execute in this graph-centric engine.

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/ref/EvaluatorDispatch.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/ref/EvaluatorDispatch.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/ref/EvaluatorDispatch.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/engine/ref/EvaluatorDispatch.java
Thu Oct 27 20:49:38 2011
@@ -81,6 +81,11 @@ public class EvaluatorDispatch implement
     }
 
     @Override
+    public void visit(OpQuad opQuad)
+    {
+        visit(opQuad.asQuadPattern()) ;
+    }
+    @Override
     public void visit(OpPath opPath)
     {
         Table table = evaluator.pathPattern(opPath.getTriplePath()) ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/Tags.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/Tags.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/Tags.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/Tags.java Thu
Oct 27 20:49:38 2011
@@ -71,6 +71,7 @@ public class Tags
     public static final String tagDiff          = "diff" ;
     public static final String tagMinus         = "minus" ;
     public static final String tagUnion         = "union" ;
+    public static final String tagDatasetNames  = "datasetnames" ;
 
     public static final String tagToList        = "tolist" ;
     public static final String tagOrderBy       = "order" ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/builders/BuilderOp.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/builders/BuilderOp.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/builders/BuilderOp.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/builders/BuilderOp.java
Thu Oct 27 20:49:38 2011
@@ -76,6 +76,7 @@ public class BuilderOp
         addBuild(Tags.tagBGP,           buildBGP) ;
         addBuild(Tags.tagQuadPattern,   buildQuadPattern) ;
         addBuild(Tags.tagTriple,        buildTriple) ;
+        addBuild(Tags.tagQuad,          buildQuad) ;
         addBuild(Tags.tagTriplePath,    buildTriplePath) ;
         addBuild(Tags.tagFilter,        buildFilter) ;
         addBuild(Tags.tagGraph,         buildGraph) ;
@@ -89,6 +90,7 @@ public class BuilderOp
         addBuild(Tags.tagDiff,          buildDiff) ;
         addBuild(Tags.tagMinus,         buildMinus) ;
         addBuild(Tags.tagUnion,         buildUnion) ;
+        addBuild(Tags.tagDatasetNames,  buildDatasetNames) ;
         addBuild(Tags.tagConditional,   buildConditional) ;
 
         addBuild(Tags.tagToList,        buildToList) ;
@@ -283,6 +285,13 @@ public class BuilderOp
             return new OpTriple(t) ;
         }} ;
     
+    final protected Build buildQuad = new Build(){
+        @Override
+        public Op make(ItemList list)
+        {
+            Quad q = BuilderGraph.buildQuad(list) ;
+            return new OpQuad(q) ;
+        }} ;
     
     final protected Build buildTriplePath = new Build(){
         @Override
@@ -416,6 +425,17 @@ public class BuilderOp
         }
     } ;
     
+    final protected Build buildDatasetNames = new Build()
+    {
+        @Override
+        public Op make(ItemList list)
+        {
+            BuilderLib.checkLength(2, list, Tags.tagDatasetNames) ;
+            Node n = BuilderNode.buildNode(list.get(1)) ;
+            return new OpDatasetNames(n) ;
+        }
+    } ;
+    
     final protected Build buildConditional = new Build()
     {
         @Override

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/writers/WriterOp.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/writers/WriterOp.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/writers/WriterOp.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/sse/writers/WriterOp.java
Thu Oct 27 20:49:38 2011
@@ -226,6 +226,13 @@ public class WriterOp
         }
 
         @Override
+        public void visit(OpQuad opQuad)
+        {
+            formatQuad(opQuad.getQuad()) ;
+        }
+
+
+        @Override
         public void visit(OpPath opPath)
         {
             //start(opPath, NoNL) ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/TS_Algebra.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/TS_Algebra.java?rev=1190018&r1=1190017&r2=1190018&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/TS_Algebra.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/TS_Algebra.java
Thu Oct 27 20:49:38 2011
@@ -20,6 +20,7 @@ package com.hp.hpl.jena.sparql.algebra;
 
 
 import com.hp.hpl.jena.sparql.algebra.optimize.TestOptimizer ;
+import com.hp.hpl.jena.sparql.algebra.optimize.TestPattern2Join ;
 import com.hp.hpl.jena.sparql.algebra.optimize.TestVarRename ;
 
 import junit.framework.TestSuite ;
@@ -32,7 +33,8 @@ import org.junit.runners.Suite ;
     , TestClassify.class
     , TestFilterTransform.class
     , TestVarRename.class
-    , TestOptimizer.class
+    , TestOptimizer.class
+    , TestPattern2Join.class
 //    , TestUnionGraph.class
 //    , TestUnionTransformTriples.class
 //    , TestUnionTransformQuads.class

Added: incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestPattern2Join.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestPattern2Join.java?rev=1190018&view=auto
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestPattern2Join.java
(added)
+++ incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestPattern2Join.java
Thu Oct 27 20:49:38 2011
@@ -0,0 +1,106 @@
+/**
+ * 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 com.hp.hpl.jena.sparql.algebra.optimize;
+
+import org.junit.Test ;
+import org.openjena.atlas.junit.BaseTest ;
+import org.openjena.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.Transformer ;
+import com.hp.hpl.jena.sparql.sse.SSE ;
+
+public class TestPattern2Join extends BaseTest
+{
+    
+    @Test public void bgp2join_01() { test3("{}", 
+                                           "(table unit)") ; }
+    
+    @Test public void bgp2join_02() { test3("{?s ?p ?o}", 
+                                           "(triple ?s ?p ?o)") ; }
+    
+    @Test public void bgp2join_03() { test3("{?s1 ?p1 ?o1 . ?s2 ?p2 ?o2 . }", 
+                                           "(join ",
+                                           "  (triple ?s1 ?p1 ?o1)",
+                                           "  (triple ?s2 ?p2 ?o2) )") ; }
+    
+    @Test public void bgp2join_04() { test3("{?s1 ?p1 ?o1 . ?s2 ?p2 ?o2 . ?s3 ?p3 ?o3 . }",

+                                           "(join ",
+                                           "   (join (triple ?s1 ?p1 ?o1) (triple ?s2 ?p2
?o2))",
+                                           "   (triple ?s3 ?p3 ?o3) )") ; }
+    
+    @Test public void qp2join_01() { test4("{GRAPH ?g { }}", "(datasetnames ?g)") ; }
+
+    @Test public void qp2join_02() { test4("{GRAPH ?g { ?s ?p ?o  }}", "(quad ?g ?s ?p ?o)")
; }
+
+    @Test public void qp2join_03() { test4("{GRAPH ?g { ?s1 ?p1 ?o1 . ?s2 ?p2 ?o2 .  }}",
+                                             "(join ",
+                                             "  (quad ?g ?s1 ?p1 ?o1)",
+                                             "  (quad ?g ?s2 ?p2 ?o2) )") ; }
+    
+    @Test public void qp2join_04() { test4("{GRAPH ?g { ?s1 ?p1 ?o1 . ?s2 ?p2 ?o2 . ?s3 ?p3
?o3 .}}", 
+                                           "(join ",
+                                           "   (join (quad ?g ?s1 ?p1 ?o1) (quad ?g ?s2 ?p2
?o2))",
+                                           "   (quad ?g ?s3 ?p3 ?o3) )") ; }
+    
+    @Test public void qp2join_05() { test4("{GRAPH ?g { ?s1 ?p1 ?o1 . ?s2 ?p2 ?o2 . ?s3 ?p3
?o3 .}}", 
+                                           "(join ",
+                                           "   (join (quad ?g ?s1 ?p1 ?o1) (quad ?g ?s2 ?p2
?o2))",
+                                           "   (quad ?g ?s3 ?p3 ?o3) )") ; }
+
+    @Test public void qp2join_06() { test4("{GRAPH ?g1 { ?s1 ?p1 ?o1 } GRAPH ?g2 { ?s2 ?p2
?o2 } }", 
+                                           "(join (quadpattern (?g1 ?s1 ?p1 ?o1)) (quadpattern
(?g2 ?s2 ?p2 ?o2)) )") ; }
+
+    
+    @Test public void qp2join_07() { test4("{GRAPH ?g1 { ?s1 ?p1 ?o1 . ?s9 ?p9 ?o9} GRAPH
?g2 { ?s2 ?p2 ?o2 . ?s8 ?p8 ?o8}}",     
+                                           "(join ",
+                                           "   (join (quad ?g1 ?s1 ?p1 ?o1) (quad ?g1 ?s9
?p9 ?o9))",
+                                           "   (join (quad ?g2 ?s2 ?p2 ?o2) (quad ?g2 ?s8
?p8 ?o8))",
+                                           ")") ; }
+
+
+    private static void test3(String pattern, String... joinForm)
+    {
+        Query q = QueryFactory.create("PREFIX : <http://example/> SELECT * "+pattern)
;
+        Op op = Algebra.compile(q.getQueryPattern()) ;
+        test(op, joinForm) ;
+    }
+    
+    private static void test4(String pattern, String... joinForm)
+    {
+        Query q = QueryFactory.create("PREFIX : <http://example/> SELECT * "+pattern)
;
+        Op op = Algebra.compile(q.getQueryPattern()) ;
+        op = Algebra.toQuadForm(op) ;
+        test(op, joinForm) ;
+    }
+    
+    private static void test(Op input, String... joinForm)
+    {
+        System.out.println(input) ;
+
+        Op op2 = Transformer.transform(new TransformPattern2Join() , input) ;
+        String x = StrUtils.strjoinNL(joinForm) ;
+        Op opExpected = SSE.parseOp("(prefix ((: <http://example/>)) "+x+")") ;
+        assertEquals(op2, opExpected) ; 
+    }
+}
+

Propchange: incubator/jena/Jena2/ARQ/trunk/src/test/java/com/hp/hpl/jena/sparql/algebra/optimize/TestPattern2Join.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message