jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1329912 - in /incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval: PathEngine.java PathEngine1.java PathEngineN.java PathEval.java PathEvaluator.java
Date Tue, 24 Apr 2012 18:23:29 GMT
Author: andy
Date: Tue Apr 24 18:23:29 2012
New Revision: 1329912

URL: http://svn.apache.org/viewvc?rev=1329912&view=rev
Log:
Some tidying up in preparation for a new evaluator with the latest SPARQL semantics.

Modified:
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine1.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngineN.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEval.java
    incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEvaluator.java

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine.java?rev=1329912&r1=1329911&r2=1329912&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine.java
Tue Apr 24 18:23:29 2012
@@ -32,7 +32,6 @@ import com.hp.hpl.jena.sparql.path.P_Neg
 import com.hp.hpl.jena.sparql.path.Path ;
 import com.hp.hpl.jena.sparql.path.eval.PathEvaluator.FilterExclude ;
 
-
 abstract public class PathEngine {
     
     protected abstract void doNegatedPropertySet(P_NegPropSet pathNotOneOf, Node node, Collection<Node>
output) ;
@@ -84,8 +83,6 @@ abstract public class PathEngine {
 
     protected abstract void doMultiLengthPath(Path pathStep, Node node, long min, long max,
Collection<Node> output) ;
 
-    //protected abstract void doArbitaryLengthPath(Path pathStep, Node node, Collection<Node>
output) ;
-
     protected abstract void doAlt(Path pathStepLeft, Path pathStepRight, Node node, Collection<Node>
output) ;
 
     protected abstract void doSeq(Path pathStepLeft, Path pathStepRight, Node node, Collection<Node>
output) ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine1.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine1.java?rev=1329912&r1=1329911&r2=1329912&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine1.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngine1.java
Tue Apr 24 18:23:29 2012
@@ -29,7 +29,11 @@ import com.hp.hpl.jena.sparql.path.P_Mod
 import com.hp.hpl.jena.sparql.path.P_NegPropSet ;
 import com.hp.hpl.jena.sparql.path.Path ;
 
-/** Path evaluation visitor that provide distinct nodes visited, */ 
+/** Path evaluation visitor that provide distinct nodes visited only.
+ * This is NOT SPARQL semantics.
+ * This class exists for experimentation.
+ * It is written to get the right results - not necessarily with maximum efficiency.
+ */
 final class PathEngine1 extends PathEngine
 {
     private final Graph graph ;
@@ -43,7 +47,9 @@ final class PathEngine1 extends PathEngi
     
     // Choose the underlying impl - different choice for debugging.
     @Override
-    protected Collection<Node> collector() { return new ArrayList<Node>()  ;
}
+    protected Collection<Node> collector() 
+    { return new ArrayList<Node>()  ; }
+    //{ return new HashSet<Node>()  ; }
     
     @Override
     protected void flipDirection()

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngineN.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngineN.java?rev=1329912&r1=1329911&r2=1329912&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngineN.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEngineN.java
Tue Apr 24 18:23:29 2012
@@ -35,9 +35,11 @@ import com.hp.hpl.jena.sparql.path.Path 
 
 // ----
 /** Path evaluator that produces duplicates.
- *  This is the algorithm in the SPARQL 1.1 spec.  
- * 
+ * This is NOT SPARQL semantics.
+ * This class exists for experimentation.
+ * It is written to get the right results - not necessarily with maximum efficiency.
  */
+
 final class PathEngineN extends PathEngine
 {
     private final Graph graph ;
@@ -87,7 +89,7 @@ final class PathEngineN extends PathEngi
     }
 
     @Override
-    public void doSeq(Path pathStepLeft, Path pathStepRight, Node node, Collection<Node>
output)
+    protected void doSeq(Path pathStepLeft, Path pathStepRight, Node node, Collection<Node>
output)
     {
         Path part1 = forwardMode ? pathStepLeft : pathStepRight ;
         Path part2 = forwardMode ? pathStepRight : pathStepLeft ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEval.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEval.java?rev=1329912&r1=1329911&r2=1329912&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEval.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEval.java
Tue Apr 24 18:23:29 2012
@@ -28,25 +28,40 @@ import com.hp.hpl.jena.sparql.path.Path 
 
 public class PathEval
 {
-    /** Evaluate a path */ 
+    /** Evaluate a path : SPARQL semantics */ 
     static public Iterator<Node> eval(Graph graph, Node node, Path path)
     {
+        //return PathEvaluator.eval(graph, node, path, new PathEngineSPARQL(graph, true))
;
         return PathEvaluator.eval(graph, node, path, new PathEngineN(graph, true)) ;
     }
 
-    /** Evaluate a path : unique results */ 
-    static public Iterator<Node> eval1(Graph graph, Node node, Path path)
+    /** Evaluate a path */ 
+    static public Iterator<Node> evalReverse(Graph graph, Node node, Path path)
     {
-        return PathEvaluator.eval(graph, node, path, new PathEngine1(graph, true)) ;
+        //return PathEvaluator.eval(graph, node, path, new PathEngineSPARQL(graph, false))
;
+        return PathEvaluator.eval(graph, node, path, new PathEngineN(graph, false)) ;
     }
 
-    /** Evaluate a path */ 
-    static public Iterator<Node> evalReverse(Graph graph, Node node, Path path)
+    
+    /** Evaluate a path : counting semantics */ 
+    static public Iterator<Node> evalN(Graph graph, Node node, Path path)
+    {
+        return PathEvaluator.eval(graph, node, path, new PathEngineN(graph, true)) ;
+    }
+
+    /** Evaluate a path : counting semantics */ 
+    static public Iterator<Node> evalReverseN(Graph graph, Node node, Path path)
     {
         return PathEvaluator.eval(graph, node, path, new PathEngineN(graph, false)) ;
     }
 
     /** Evaluate a path : unique results */ 
+    static public Iterator<Node> eval1(Graph graph, Node node, Path path)
+    {
+        return PathEvaluator.eval(graph, node, path, new PathEngine1(graph, true)) ;
+    }
+
+    /** Evaluate a path : unique results */ 
     static public Iterator<Node> evalReverse1(Graph graph, Node node, Path path)
     {
         return PathEvaluator.eval(graph, node, path, new PathEngine1(graph, false)) ;

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEvaluator.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEvaluator.java?rev=1329912&r1=1329911&r2=1329912&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEvaluator.java
(original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/path/eval/PathEvaluator.java
Tue Apr 24 18:23:29 2012
@@ -133,10 +133,10 @@ final class PathEvaluator implements Pat
             engine.doFixedLengthPath(pathMod.getSubPath(), node, pathMod.getFixedLength(),
output) ;
         else
             engine.doMultiLengthPath(pathMod.getSubPath(),
-                              node,
-                              pathMod.getMin(),
-                              pathMod.getMax(), 
-                              output) ;
+                                     node,
+                                     pathMod.getMin(),
+                                     pathMod.getMax(), 
+                                     output) ;
     }
 
     @Override
@@ -157,8 +157,7 @@ final class PathEvaluator implements Pat
     {
         // Regardless of engine, do distinct. 
         PathEngine engine2 = engine ;
-        if ( engine instanceof PathEngineN )
-            engine = new PathEngine1(graph, engine.direction()) ;
+        engine = new PathEngine1(graph, engine.direction()) ;
         engine.doZeroOrMore(path.getSubPath(), node, output) ;
         engine = engine2 ;
     }
@@ -166,8 +165,14 @@ final class PathEvaluator implements Pat
     @Override
     public void visit(P_ZeroOrMoreN path)
     {
-        // Do as per engine.
+        // TEMP: Do as engine.
         engine.doZeroOrMore(path.getSubPath(), node, output) ;
+        
+//        // Regardless of engine, do counting. 
+//        PathEngine engine2 = engine ;
+//        engine = new PathEngineN(graph, engine.direction()) ;
+//        engine.doZeroOrMore(path.getSubPath(), node, output) ;
+//        engine = engine2 ;
     }
     
 
@@ -176,8 +181,7 @@ final class PathEvaluator implements Pat
     {
         // Regardless of engine, do distinct. 
         PathEngine engine2 = engine ;
-        if ( engine instanceof PathEngineN )
-            engine = new PathEngine1(graph, engine.direction()) ;
+        engine = new PathEngine1(graph, engine.direction()) ;
         engine.doOneOrMore(path.getSubPath(), node, output) ;
         engine = engine2 ;
     }
@@ -185,8 +189,13 @@ final class PathEvaluator implements Pat
     @Override
     public void visit(P_OneOrMoreN path)
     {
-        // Do as per engine.
+        // TEMP Do as engine.
         engine.doOneOrMore(path.getSubPath(), node, output) ;
+        
+//        PathEngine engine2 = engine ;
+//        engine = new PathEngineN(graph, engine.direction()) ;
+//        engine.doOneOrMore(path.getSubPath(), node, output) ;
+//        engine = engine2 ;
     }
     
     
@@ -203,15 +212,9 @@ final class PathEvaluator implements Pat
     @Override
     public void visit(P_Distinct pathDistinct)
     {
-        doDistinct(pathDistinct.getSubPath()) ;
-    }
-    
-    protected void doDistinct(Path path)
-    {
         PathEngine engine2 = engine ;
-        if ( engine instanceof PathEngineN )
-            engine = new PathEngine1(graph, engine.direction()) ;
-        engine.eval(graph, path, node, output) ;
+        engine = new PathEngine1(graph, engine.direction()) ;
+        engine.eval(graph, pathDistinct.getSubPath(), node, output) ;
         engine = engine2 ;
     }
 
@@ -219,8 +222,7 @@ final class PathEvaluator implements Pat
     public void visit(P_Multi pathMulti)
     {
         PathEngine engine2 = engine ;
-        if ( engine instanceof PathEngine1 )
-            engine = new PathEngineN(graph, engine.direction()) ;
+        engine = new PathEngineN(graph, engine.direction()) ;
         engine.eval(graph, pathMulti.getSubPath(), node, output) ;
         engine = engine2 ;
     }



Mime
View raw message