jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1244126 - in /incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev: RunAFS.java path/PathEngine1.java path/PathEngineN.java path/PathEval2.java path/PathEvaluator.java path/PathEvaluatorBase.java
Date Tue, 14 Feb 2012 17:05:39 GMT
Author: andy
Date: Tue Feb 14 17:05:38 2012
New Revision: 1244126

URL: http://svn.apache.org/viewvc?rev=1244126&view=rev
Log: (empty)

Added:
    incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluator.java
      - copied, changed from r1243952, incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluatorBase.java
Removed:
    incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluatorBase.java
Modified:
    incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java
    incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngine1.java
    incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngineN.java
    incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEval2.java

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java?rev=1244126&r1=1244125&r2=1244126&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/RunAFS.java Tue Feb 14 17:05:38 2012
@@ -65,7 +65,8 @@ public class RunAFS
         String prefix = "prefix ((: <http://example/>))" ;
         
         //String pathStr = "(mod 0 2 :q)" ;
-        String pathStr = "(pathN 2 :q)" ;
+        //String pathStr = "(pathN 2 :q)" ;
+        String pathStr = "(path+ :r)" ;
         
         String qs = StrUtils.strjoinNL(
            "("+prefix,
@@ -114,14 +115,17 @@ public class RunAFS
 
         System.out.println(WriterPath.asString(path)) ;
 
-        String SEP = "\n  " ;
+//      String SEP1 = ": " ;
+//      String SEP2 = "   " ;
+      String SEP1 = "\n  " ;
+      String SEP2 = SEP1 ;
         
-        System.out.printf("Eval1: (%d)%s", nodes1.size(), SEP) ;
-        System.out.print(Iter.asString(nodes1, SEP)) ;
+        System.out.printf("Eval1: (%d)%s", nodes1.size(), SEP1) ;
+        System.out.print(Iter.asString(nodes1, SEP2)) ;
         System.out.println() ;
         
-        System.out.printf("EvalN: (%d)%s", nodes2.size(), SEP) ;
-        System.out.print(Iter.asString(nodes2, SEP)) ;
+        System.out.printf("EvalN: (%d)%s", nodes2.size(), SEP1) ;
+        System.out.print(Iter.asString(nodes2, SEP2)) ;
         System.out.println() ;
         
         if ( false )

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngine1.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngine1.java?rev=1244126&r1=1244125&r2=1244126&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngine1.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngine1.java Tue Feb 14 17:05:38
2012
@@ -18,6 +18,7 @@
 
 package dev.path;
 
+//import java.util.ArrayList ;
 import java.util.ArrayList ;
 import java.util.Collection ;
 import java.util.Iterator ;
@@ -40,6 +41,10 @@ class PathEngine1 extends PathEngine
         this.graph = graph ;
         this.forwardMode = forward ;
     }
+    
+    // Choose the underlying impl - different choice for debugging.
+    private static Collection<Node> collector() { return new ArrayList<Node>()
 ; }
+    
 
     @Override
     protected void doMultiLengthPath(Path pathStep, Node node, long min1, long max1, Collection<Node>
output)
@@ -52,11 +57,11 @@ class PathEngine1 extends PathEngine
             min1 = 0 ;
 
         // do 0-min1 steps, not collecting.
-        Collection<Node> collectStartPoints = new ArrayList<Node>() ;
+        Collection<Node> collectStartPoints = collector() ;
 
         if ( min1 > 0 )
             //WRONG - this is {0,min1} not {min1}
-            doFixedLength(pathStep, node, min1, collectStartPoints) ;
+            doFixedLengthPath(pathStep, node, min1, collectStartPoints) ;
         else
             collectStartPoints.add(node) ;
 
@@ -65,7 +70,7 @@ class PathEngine1 extends PathEngine
         // {N,M} = {N} then {0,M-N} 
         int length = (int)(max1-min1) ;
 
-        Collection<Node> visited = new ArrayList<Node>() ;
+        Collection<Node> visited = collector() ;
         for ( Node n : collectStartPoints )
             doFixedLengthPath(pathStep, n, length, visited) ;
 
@@ -74,37 +79,45 @@ class PathEngine1 extends PathEngine
     }
 
 
-    // Do {0,length} 
-    private void doFixedLengthPath(Path path, Node node, int length, Collection<Node>visited)
-    {
-        System.out.printf("doModPath (%d) %s\n", length, node) ;
-        ALP1(graph, forwardMode, 0, length, node, path, visited) ;
-    }
+//    // Do {0,length} 
+//    private void doFixedLengthPath(Path path, Node node, int length, Collection<Node>visited)
+//    {
+//        System.out.printf("doModPath (%d) %s\n", length, node) ;
+//        ALP1(graph, forwardMode, 0, length, node, path, visited) ;
+//    }
 
 
     @Override
     protected void doFixedLengthPath(Path pathStep, Node node, long fixedLength, Collection<Node>
output)
-    {}
-
-    private void doFixedLength(Path subPath, Node node, long count, Collection<Node>
output)
     {
-        // One step.
-        Collection<Node> visitedOne = new ArrayList<Node>() ;
-        PathEval2.eval1$(graph, node, subPath, forwardMode, visitedOne) ;
-        if ( count == 1 )
+        // Special for small?
+//        if ( fixedLength < 3 )
+//        {}
+        Collection<Node> visited = collector() ;
+        
+        if ( fixedLength == 0 )
+        {}
+        if ( fixedLength == 1 )
         {
-            // BAD
-            for ( Node n : visitedOne )
+            PathEval2.eval1$(graph, node, pathStep, forwardMode, visited) ;
+            for ( Node n : visited )
             {
-                if ( ! output.contains(n) )
+                if ( !output.contains(n) )
                     output.add(n) ;
             }
             return ;
         }
-
-        for ( Node n : visitedOne)
-            doFixedLength(subPath, n, count-1, output) ;
+        // TODO Incomplete
+        // Loop, not recurse.
+        Iterator<Node> iter = PathEval2.eval1(graph, node, pathStep, forwardMode) ;
+        for ( ; iter.hasNext() ; )
+        {
+            Node n = iter.next() ;
+            doFixedLengthPath(pathStep, n, fixedLength-1, output) ;
+        }
+        return ;
     }
+    
 
     @Override
     protected void doZeroOrMore(Path path, Node node, Collection<Node> output)

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngineN.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngineN.java?rev=1244126&r1=1244125&r2=1244126&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngineN.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEngineN.java Tue Feb 14 17:05:38
2012
@@ -34,7 +34,7 @@ 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 ;
 
-import dev.path.PathEvaluatorBase.FilterExclude ;
+import dev.path.PathEvaluator.FilterExclude ;
 
 // ----
 /** Path evaluator that produces duplicates.

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEval2.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEval2.java?rev=1244126&r1=1244125&r2=1244126&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEval2.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEval2.java Tue Feb 14 17:05:38
2012
@@ -93,7 +93,7 @@ public class PathEval2
     // ---- Worker ??
     static private void evalN$(Graph graph, Node node, Path p, boolean forward, Collection<Node>
acc)
     {
-        PathEvaluatorBase evaluator = new PathEvaluatorBase(graph, node, acc, forward, new
PathEngineN(graph, forward)) ;
+        PathEvaluator evaluator = new PathEvaluator(graph, node, acc, forward, new PathEngineN(graph,
forward)) ;
         p.visit(evaluator) ;
     }
 
@@ -131,7 +131,7 @@ public class PathEval2
     // ---- Worker ??
     static void eval1$(Graph graph, Node node, Path p, boolean forward, Collection<Node>
acc)
     {
-        PathEvaluatorBase evaluator = new PathEvaluatorBase(graph, node, acc, forward, new
PathEngine1(graph, forward)) ;
+        PathEvaluator evaluator = new PathEvaluator(graph, node, acc, forward, new PathEngine1(graph,
forward)) ;
         p.visit(evaluator) ;
     }
 

Copied: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluator.java (from r1243952,
incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluatorBase.java)
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluator.java?p2=incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluator.java&p1=incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluatorBase.java&r1=1243952&r2=1244126&rev=1244126&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluatorBase.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/path/PathEvaluator.java Tue Feb 14 17:05:38
2012
@@ -43,7 +43,7 @@ import com.hp.hpl.jena.sparql.path.P_Zer
 import com.hp.hpl.jena.sparql.path.Path ;
 import com.hp.hpl.jena.sparql.path.PathVisitor ;
 
-final class PathEvaluatorBase implements PathVisitor
+final class PathEvaluator implements PathVisitor
 {
     protected final Graph graph ;
     protected final Node node ;
@@ -55,7 +55,7 @@ final class PathEvaluatorBase implements
     //protected abstract Iterator<Node> doOne(Node property) ;
 
     // Pass in graph, node only to PathEngine?
-    protected PathEvaluatorBase(Graph g, Node n, Collection<Node> output, boolean forward,
PathEngine engine)
+    protected PathEvaluator(Graph g, Node n, Collection<Node> output, boolean forward,
PathEngine engine)
     {
         this.graph = g ; 
         this.node = n ;



Mime
View raw message