jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1198733 [2/13] - in /incubator/jena/Scratch/AFS/Dev/trunk: src-archive/riot/comms/ src-archive/riot/comms/client/ src-archive/riot/comms/server0/ src-archive/riot/comms/server1/nio/ src-archive/riot/comms/server1/socket/ src-archive/riot/c...
Date Mon, 07 Nov 2011 13:36:34 GMT
Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/comms/server1/token/Handler.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/comms/server1/token/Handler.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/comms/server1/token/Handler.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/comms/server1/token/Handler.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,11 +16,11 @@
  * limitations under the License.
  */
 
-package riot.comms.server1.token;
-
-
-
-public interface Handler
-{
-    public void loop() ;
+package riot.comms.server1.token;
+
+
+
+public interface Handler
+{
+    public void loop() ;
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/comms/server1/token/HandlerFactory.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/comms/server1/token/HandlerFactory.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/comms/server1/token/HandlerFactory.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/comms/server1/token/HandlerFactory.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,13 +16,13 @@
  * limitations under the License.
  */
 
-package riot.comms.server1.token;
-
-import riot.comms.TokenStreamEndpoint ;
-
-
-/** Factory for handlers of new channels */
-public interface HandlerFactory
-{
-    public Handler create(TokenStreamEndpoint stream) ;
+package riot.comms.server1.token;
+
+import riot.comms.TokenStreamEndpoint ;
+
+
+/** Factory for handlers of new channels */
+public interface HandlerFactory
+{
+    public Handler create(TokenStreamEndpoint stream) ;
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/io/section/TokenInputSection.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/io/section/TokenInputSection.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/io/section/TokenInputSection.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/io/section/TokenInputSection.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,98 +16,98 @@
  * limitations under the License.
  */
 
-package riot.io.section;
-
-import java.util.Iterator ;
-import java.util.List ;
-import java.util.NoSuchElementException ;
-
-import org.openjena.atlas.lib.Pool ;
-import org.openjena.riot.tokens.Token ;
-import riot.comms.End ;
-import riot.comms.TokenComms ;
-import riot.comms.TokenStreamEndpoint ;
-import riot.io.TokenInputStream ;
-
-
-
-/** Iterate until the endLog marker is seen.
- */
-
-public class TokenInputSection implements TokenInputStream
-{
-    // Should be a TokenInputStream (interface)
-    
-    private boolean finished = false ;
-    private final TokenInputStream tokens ;
-    private List<Token> list = null ;
-    private Pool<TokenStreamEndpoint> pool ;
-    private End atEnd ;
-    
-    public TokenInputSection(TokenInputStream tokenInputStream, End atEnd)
-    {
-        this.tokens = tokenInputStream ;
-        this.atEnd = atEnd ;
-    }
-
-    @Override
-    public boolean hasNext()
-    {
-        if ( finished )
-            return false ;
-        if ( list != null )
-            return true ;
-        if ( ! tokens.hasNext() )
-        {
-            close() ;
-            finished = true ;
-            return false ;
-        }
-        
-        list = tokens.next() ;
-        if ( TokenComms.isEndSectionMarker(list) || TokenComms.isEndStreamMarker(list)) 
-        {
-            close() ;
-            finished = true ;
-            return false ;
-        }
-        // It's not the endLog of a section. 
-        return true ;
-    }
-
-    @Override
-    public List<Token> next()
-    {
-        if ( ! hasNext() )
-            throw new NoSuchElementException() ;
-        List<Token> r = list ;
-        list = null ;
-        return r ;
-    }
-    
-    public List<Token> nextOrNull()
-    {
-        if ( ! hasNext() )
-            return null ;
-        List<Token> r = list ;
-        list = null ;
-        return r ;
-    }
-    
-    @Override
-    public void remove()
-    { throw new UnsupportedOperationException() ; }
-
-    @Override
-    public Iterator<List<Token>> iterator()
-    {
-        return this ;
-    }
-
-    @Override
-    public void close()
-    {
-        if ( atEnd != null )
-            atEnd.end() ;
-    }
+package riot.io.section;
+
+import java.util.Iterator ;
+import java.util.List ;
+import java.util.NoSuchElementException ;
+
+import org.openjena.atlas.lib.Pool ;
+import org.openjena.riot.tokens.Token ;
+import riot.comms.End ;
+import riot.comms.TokenComms ;
+import riot.comms.TokenStreamEndpoint ;
+import riot.io.TokenInputStream ;
+
+
+
+/** Iterate until the endLog marker is seen.
+ */
+
+public class TokenInputSection implements TokenInputStream
+{
+    // Should be a TokenInputStream (interface)
+    
+    private boolean finished = false ;
+    private final TokenInputStream tokens ;
+    private List<Token> list = null ;
+    private Pool<TokenStreamEndpoint> pool ;
+    private End atEnd ;
+    
+    public TokenInputSection(TokenInputStream tokenInputStream, End atEnd)
+    {
+        this.tokens = tokenInputStream ;
+        this.atEnd = atEnd ;
+    }
+
+    @Override
+    public boolean hasNext()
+    {
+        if ( finished )
+            return false ;
+        if ( list != null )
+            return true ;
+        if ( ! tokens.hasNext() )
+        {
+            close() ;
+            finished = true ;
+            return false ;
+        }
+        
+        list = tokens.next() ;
+        if ( TokenComms.isEndSectionMarker(list) || TokenComms.isEndStreamMarker(list)) 
+        {
+            close() ;
+            finished = true ;
+            return false ;
+        }
+        // It's not the endLog of a section. 
+        return true ;
+    }
+
+    @Override
+    public List<Token> next()
+    {
+        if ( ! hasNext() )
+            throw new NoSuchElementException() ;
+        List<Token> r = list ;
+        list = null ;
+        return r ;
+    }
+    
+    public List<Token> nextOrNull()
+    {
+        if ( ! hasNext() )
+            return null ;
+        List<Token> r = list ;
+        list = null ;
+        return r ;
+    }
+    
+    @Override
+    public void remove()
+    { throw new UnsupportedOperationException() ; }
+
+    @Override
+    public Iterator<List<Token>> iterator()
+    {
+        return this ;
+    }
+
+    @Override
+    public void close()
+    {
+        if ( atEnd != null )
+            atEnd.end() ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/io/section/TokenOutputSection.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/io/section/TokenOutputSection.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/io/section/TokenOutputSection.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-archive/riot/io/section/TokenOutputSection.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,30 +16,30 @@
  * limitations under the License.
  */
 
-package riot.io.section;
-
-import riot.comms.End ;
-import riot.io.TokenOutputStream ;
-import riot.io.TokenOutputStreamWrapper ;
-
-public class TokenOutputSection extends TokenOutputStreamWrapper
-{
-    private TokenOutputStream stream ;
-    private End atEnd ;
-
-    public TokenOutputSection(TokenOutputStream stream, End atEnd)
-    {
-        super(stream) ;
-        this.atEnd = atEnd ;
-        startSection() ;
-    }
-    
-    @Override
-    public void close()
-    { 
-        endSection() ;
-        flush() ; 
-        if ( atEnd != null )
-            atEnd.end() ;
-    } 
+package riot.io.section;
+
+import riot.comms.End ;
+import riot.io.TokenOutputStream ;
+import riot.io.TokenOutputStreamWrapper ;
+
+public class TokenOutputSection extends TokenOutputStreamWrapper
+{
+    private TokenOutputStream stream ;
+    private End atEnd ;
+
+    public TokenOutputSection(TokenOutputStream stream, End atEnd)
+    {
+        super(stream) ;
+        this.atEnd = atEnd ;
+        startSection() ;
+    }
+    
+    @Override
+    public void close()
+    { 
+        endSection() ;
+        flush() ; 
+        if ( atEnd != null )
+            atEnd.end() ;
+    } 
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/BindingN.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/BindingN.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/BindingN.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/BindingN.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/DevAFS.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/DevAFS.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/DevAFS.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/DevAFS.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,26 +16,26 @@
  * limitations under the License.
  */
 
-package dev;
-
-public class DevAFS
-{
-    // De-mess top level directories.
-    // http://www.mongodb.org/display/DOCS/BSON
-    
-    /* Storage toys
-     * + FileHeader can contain quite a lot of info. ==> metafile. 
-     * + Variable length entries
-     * 
-     * Classes:
-     *   Fix length for logical-physical.
-     * Three files:
-     *   Data file - raw bytes
-     *   Offset file - (size, location) slots
-     *     -size => free
-     *   Free block file - (id, next) for a singly linked list
-     *     List starts are firts few blocks where (id = -max size , next=start)   
-     * Or: minimum size for a (fiuxed) chunk includes space for the free chain to be managed
-     */
-    
+package dev;
+
+public class DevAFS
+{
+    // De-mess top level directories.
+    // http://www.mongodb.org/display/DOCS/BSON
+    
+    /* Storage toys
+     * + FileHeader can contain quite a lot of info. ==> metafile. 
+     * + Variable length entries
+     * 
+     * Classes:
+     *   Fix length for logical-physical.
+     * Three files:
+     *   Data file - raw bytes
+     *   Offset file - (size, location) slots
+     *     -size => free
+     *   Free block file - (id, next) for a singly linked list
+     *     List starts are firts few blocks where (id = -max size , next=start)   
+     * Or: minimum size for a (fiuxed) chunk includes space for the free chain to be managed
+     */
+    
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/LogMain.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/LogMain.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/LogMain.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/LogMain.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,116 +16,116 @@
  * limitations under the License.
  */
 
-package dev;
-
-import java.io.ByteArrayInputStream ;
-import java.io.IOException ;
-import java.io.UnsupportedEncodingException ;
-
-import org.openjena.atlas.lib.StrUtils ;
-import org.openjena.atlas.logging.Log ;
-import org.openjena.atlas.logging.java.ConsoleHandlerStdout ;
-import org.slf4j.LoggerFactory ;
-
-public class LogMain
-{
-    static { Log.setLog4j() ; }
-    public static void main(String ... args) //throws SecurityException, IOException
-    {
-        mainSLF4j() ;
-        mainJUL() ;
-    }
-    
-    public static void logNetwork()
-    {
-        // org.apache.log4j.net.SimpleSocketServer 6000 log4j.properties
-        // org.apache.log4j.net.SocketServer 6000 log4j.properties DIR
-        //   log4j.properties logging
-        //   DIR is one config file per host
-
-        Log.setLog4j("log4j-net.properties") ;    // Re-initialize log4j.
-        LoggerFactory.getLogger("HELLO").info("Message") ;
-        System.out.println("Exit") ;
-        System.exit(0) ;
-    }
-    
-    private static void mainSLF4j()
-    {
-
-        org.slf4j.Logger logger_slf4j = org.slf4j.LoggerFactory.getLogger(dev.RunAFS.class) ;
-        logger_slf4j.error("org.slf4j") ;
-    }        
-        
-        
-        
-    private static void mainJUL()
-    {
-        String s = StrUtils.strjoinNL(
-                                      // Handlers - output
-                                      // All (comma separated)
-                                      //"handlers=java.util.logging.ConsoleHandler,atlas.logging.java.ConsoleHandlerStdout",
-                                      
-                                      // Atlas.
-                                      //"handlers=atlas.logging.java.ConsoleHandlerStdout" ,
-                                      
-                                      // Provided by the JRE
-                                      "handlers=java.util.logging.ConsoleHandler" ,
-                                      
-                                      // Formatting and levels
-                                      //"atlas.logging.java.ConsoleHandlerStdout.level=ALL",
-                                      //"atlas.logging.java.ConsoleHandlerStdout.formatter=atlas.logging.java.TextFormatter",
-                                      
-                                      "java.util.logging.ConsoleHandler.level=INFO"
-                                      //, "java.util.logging.ConsoleHandler.formatter=atlas.logging.java.TextFormatter"
-                                      ) ;   
-        
-        try
-        {
-            java.util.logging.LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(s.getBytes("UTF-8"))) ;
-        } catch (SecurityException ex)
-        {
-            ex.printStackTrace();
-        } catch (UnsupportedEncodingException ex)
-        {
-            ex.printStackTrace();
-        } catch (IOException ex)
-        {
-            ex.printStackTrace();
-        }
-
-        //System.setProperty("java.util.logging.config.file", "logging.properties") ;
-        //LogManager.getLogManager().readConfiguration() ;
-        
-        java.util.logging.Logger log = java.util.logging.Logger.getLogger(RunAFS.class.getName()) ;
-        //log.setLevel(Level.WARNING) ;
-
-        // Default output, Atlas/Java logging formatter.
-        log.info("Hello World") ;
-        
-        // Because the parent has the plumbed in ConsoleHandler
-        log.setUseParentHandlers(false) ;
-        log.addHandler(new ConsoleHandlerStdout()) ;
-        log.info("Hello World (part 2)") ;
-         
-//        // -- Remove any ConsoleHanlder
-//        Handler[] handlers = log.getHandlers() ;
-//        for ( Handler h : handlers )
-//        {
-//            if ( h instanceof ConsoleHandler )
-//                log.removeHandler(h) ;
-//        }
-        log.info("Hello World (part 3)") ;
-        System.out.println("(End)") ;
-        
-        
-//        // ---- 
-//        System.setProperty("log4j.configuration", "file:log4j.properties") ;
-//        
-//        
-//        org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger(Run.class);
-//        log4j.setLevel(org.apache.log4j.Level.ALL) ;
-//        log4j.info("Log4j direct") ;
-        
-        // Must have the right logger adapter on the classpath: slf4j-log4j... or slf4j-
-    }
+package dev;
+
+import java.io.ByteArrayInputStream ;
+import java.io.IOException ;
+import java.io.UnsupportedEncodingException ;
+
+import org.openjena.atlas.lib.StrUtils ;
+import org.openjena.atlas.logging.Log ;
+import org.openjena.atlas.logging.java.ConsoleHandlerStdout ;
+import org.slf4j.LoggerFactory ;
+
+public class LogMain
+{
+    static { Log.setLog4j() ; }
+    public static void main(String ... args) //throws SecurityException, IOException
+    {
+        mainSLF4j() ;
+        mainJUL() ;
+    }
+    
+    public static void logNetwork()
+    {
+        // org.apache.log4j.net.SimpleSocketServer 6000 log4j.properties
+        // org.apache.log4j.net.SocketServer 6000 log4j.properties DIR
+        //   log4j.properties logging
+        //   DIR is one config file per host
+
+        Log.setLog4j("log4j-net.properties") ;    // Re-initialize log4j.
+        LoggerFactory.getLogger("HELLO").info("Message") ;
+        System.out.println("Exit") ;
+        System.exit(0) ;
+    }
+    
+    private static void mainSLF4j()
+    {
+
+        org.slf4j.Logger logger_slf4j = org.slf4j.LoggerFactory.getLogger(dev.RunAFS.class) ;
+        logger_slf4j.error("org.slf4j") ;
+    }        
+        
+        
+        
+    private static void mainJUL()
+    {
+        String s = StrUtils.strjoinNL(
+                                      // Handlers - output
+                                      // All (comma separated)
+                                      //"handlers=java.util.logging.ConsoleHandler,atlas.logging.java.ConsoleHandlerStdout",
+                                      
+                                      // Atlas.
+                                      //"handlers=atlas.logging.java.ConsoleHandlerStdout" ,
+                                      
+                                      // Provided by the JRE
+                                      "handlers=java.util.logging.ConsoleHandler" ,
+                                      
+                                      // Formatting and levels
+                                      //"atlas.logging.java.ConsoleHandlerStdout.level=ALL",
+                                      //"atlas.logging.java.ConsoleHandlerStdout.formatter=atlas.logging.java.TextFormatter",
+                                      
+                                      "java.util.logging.ConsoleHandler.level=INFO"
+                                      //, "java.util.logging.ConsoleHandler.formatter=atlas.logging.java.TextFormatter"
+                                      ) ;   
+        
+        try
+        {
+            java.util.logging.LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(s.getBytes("UTF-8"))) ;
+        } catch (SecurityException ex)
+        {
+            ex.printStackTrace();
+        } catch (UnsupportedEncodingException ex)
+        {
+            ex.printStackTrace();
+        } catch (IOException ex)
+        {
+            ex.printStackTrace();
+        }
+
+        //System.setProperty("java.util.logging.config.file", "logging.properties") ;
+        //LogManager.getLogManager().readConfiguration() ;
+        
+        java.util.logging.Logger log = java.util.logging.Logger.getLogger(RunAFS.class.getName()) ;
+        //log.setLevel(Level.WARNING) ;
+
+        // Default output, Atlas/Java logging formatter.
+        log.info("Hello World") ;
+        
+        // Because the parent has the plumbed in ConsoleHandler
+        log.setUseParentHandlers(false) ;
+        log.addHandler(new ConsoleHandlerStdout()) ;
+        log.info("Hello World (part 2)") ;
+         
+//        // -- Remove any ConsoleHanlder
+//        Handler[] handlers = log.getHandlers() ;
+//        for ( Handler h : handlers )
+//        {
+//            if ( h instanceof ConsoleHandler )
+//                log.removeHandler(h) ;
+//        }
+        log.info("Hello World (part 3)") ;
+        System.out.println("(End)") ;
+        
+        
+//        // ---- 
+//        System.setProperty("log4j.configuration", "file:log4j.properties") ;
+//        
+//        
+//        org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger(Run.class);
+//        log4j.setLevel(org.apache.log4j.Level.ALL) ;
+//        log4j.info("Log4j direct") ;
+        
+        // Must have the right logger adapter on the classpath: slf4j-log4j... or slf4j-
+    }
 }

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=1198733&r1=1198732&r2=1198733&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 Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package dev;
+package dev;
 
 import java.util.Iterator ;
 
@@ -31,16 +31,16 @@ import com.hp.hpl.jena.iri.IRIFactory ;
 import com.hp.hpl.jena.iri.Violation ;
 import com.hp.hpl.jena.iri.ViolationCodes ;
 import com.hp.hpl.jena.tdb.base.record.Record ;
-
-public class RunAFS
-{
-    static { Log.setLog4j() ; }
-    
-    public static void exit(int code)
-    {
-        System.out.println("DONE") ;
-        System.exit(code) ;
-    }
+
+public class RunAFS
+{
+    static { Log.setLog4j() ; }
+    
+    public static void exit(int code)
+    {
+        System.out.println("DONE") ;
+        System.exit(code) ;
+    }
     
     static byte[] key1 = { 2 , 4 , 6 , 8  } ;
     static byte[] key2 = { 2 , 4 , 6 , 10  } ;
@@ -48,8 +48,8 @@ public class RunAFS
     static byte[] key4 = { 2 , 4 , 6,  8 , 10 } ;
     static byte[] key5 = { 2 , 4 , 3 , 1 } ;
     static byte[] key6 = { 0 , 1 , 2 , 3 , 4  } ;
-    
-    public static void main(String ... args) throws Exception
+    
+    public static void main(String ... args) throws Exception
     {
         RadixTree t = new RadixTree() ;
         byte[][] keys = { key1, key2, key3, key4, key5, key6 } ;
@@ -105,151 +105,151 @@ public class RunAFS
 //        return sb.toString() ;
 //    }
 
-    static IRIFactory iriFactory = new IRIFactory();
-    static {
-        // IRIFactory.iriImplementation() ...
-        iriFactory.useSpecificationIRI(true);
-        iriFactory.useSchemeSpecificRules("*",true);
-
-        iriFactory.shouldViolation(false,true);
-
-        // Moderate it -- allow unwise chars and any scheme name.
-        iriFactory.setIsError(ViolationCodes.UNWISE_CHARACTER,false);
-        iriFactory.setIsWarning(ViolationCodes.UNWISE_CHARACTER,false);
-
-        iriFactory.setIsError(ViolationCodes.UNREGISTERED_IANA_SCHEME,false);
-        iriFactory.setIsWarning(ViolationCodes.UNREGISTERED_IANA_SCHEME,false);
-
-        iriFactory.create("");
-
-    }
-    
-    private static void iriTest(String iriStr)
-    {
-        System.out.println("IRI =  "+iriStr) ;
-        IRIFactory factory = iriFactory ;
-        
-        IRI iri = factory.create(iriStr) ;
-        System.out.println("IRI => "+iri.toDisplayString()) ;
-        
-        
-        Iterator<Violation> iter = iri.violations(true) ;
-        for ( ; iter.hasNext();  )
-        {
-            Violation v = iter.next();
-            String x = (v.isError()?"ERROR":"WARN ") ;
-            
-            int code = v.getViolationCode() ;
-            
-//            // Treat these with low priority.
-//            if ( code == Violation.LOWERCASE_PREFERRED ||
-//                code == Violation.PERCENT_ENCODING_SHOULD_BE_UPPERCASE )
-//            {
-//                continue ;
-//            }
-            
-            System.out.printf("%s  %s\n", x, v.getShortMessage()) ;
-        }
-    }
-    
-    private static void varBlock()
-    {
-        byte[] d1 = {1,2,3,4} ;
-        byte[] d2 = {(byte)0xFF, (byte)0xFE} ;
-
-        byte[] d3 = {5,4,5,4,3,2,3,2,1,1} ;
-        byte[] d4 = {(byte)0xFF, (byte)0xFE, (byte)0xFD, (byte)0xFC, (byte)0xFB} ;
-        
-        {
-            VarRecordBuffer vrb = new VarRecordBuffer(50) ;
-            vrb.dump();
-            vrb.put(d1,d2) ;
-            vrb.dump();
-            vrb.put(d3,d4) ;
-            vrb.dump();
-            System.out.println(vrb) ;
-            Record r = vrb.get(0) ;
-
-            System.out.println(r) ;
-            System.exit(0) ;
-        }
-        
-        VarRecordBuffer vrb = new VarRecordBuffer(40) ;
-        byte[] k1 = new byte[]{1,2} ;
-        byte[] v1 = new byte[]{(byte)0xA9, (byte)0xA8, (byte)0xA7 }; //, (byte)0xA6} ;
-
-        byte[] k2 = new byte[]{3,4} ;
-        byte[] v2 = new byte[]{(byte)0xFF, (byte)0xFE, (byte)0xFD, (byte)0xFC} ;
-        
-        byte[] k3 = new byte[]{5,6} ;
-        byte[] v3 = new byte[]{(byte)0xBF, (byte)0xBE} ;//, (byte)0xBD, (byte)0xBC} ;
-        
-        //byte[] v3 = new byte[100] ;
-
-        divider() ;
-
-        boolean PRINT = false ;
-            
-        if ( PRINT ) System.out.println("k="+str(k1)+", v="+str(v1)) ;
-        vrb.put(0, k1, v1) ;
-        if ( PRINT ) vrb.dump();
-        if ( PRINT ) System.out.println(vrb) ;
-
-        if ( PRINT )divider() ;
-
-        // Push up.
-        if ( PRINT ) System.out.println("k="+str(k2)+", v="+str(v2)) ;
-        vrb.put(0, k2, v2) ;
-        if ( PRINT ) vrb.dump();
-        if ( PRINT ) System.out.println(vrb) ;
-
-        if ( PRINT ) divider() ;
-        
-        if ( PRINT ) System.out.println("k="+str(k3)+", v="+str(v3)) ;
-        vrb.put(2, k3, v3) ;
-        if ( PRINT ) vrb.dump();
-        if ( PRINT ) System.out.println(vrb) ;
-
-        PRINT = false ;
-        if ( PRINT ) divider() ;
-        if ( PRINT ) vrb.dump();
-        if ( PRINT ) System.out.println(vrb) ;
-        vrb.delete(1) ;
-        if ( PRINT ) vrb.dump();
-        System.out.println(vrb) ;
-        
-        
-    }
-
-    private static String str(byte[] bytes)
-    {
-        StringBuilder sb = new StringBuilder() ;
-        char sep = 0 ;
-        for ( byte b : bytes )
-        {
-            if ( sep != 0 )
-                sb.append(sep) ;
-            else
-                sep = ' ' ;
-                
-            sb.append(String.format("%02X", b)) ;
-        }
-        return sb.toString() ;
-    }
-
- 
-    // ---- Helpers
-    
-    private static final String NL = "\n" ;
-
-    public static String divider = "---- ----" ;
-
-    private static String nextDivider = null ;
-    
-    public static void divider()
-    {
-        if ( nextDivider != null )
-            System.out.println(nextDivider) ;
-        nextDivider = divider ;
-    }
+    static IRIFactory iriFactory = new IRIFactory();
+    static {
+        // IRIFactory.iriImplementation() ...
+        iriFactory.useSpecificationIRI(true);
+        iriFactory.useSchemeSpecificRules("*",true);
+
+        iriFactory.shouldViolation(false,true);
+
+        // Moderate it -- allow unwise chars and any scheme name.
+        iriFactory.setIsError(ViolationCodes.UNWISE_CHARACTER,false);
+        iriFactory.setIsWarning(ViolationCodes.UNWISE_CHARACTER,false);
+
+        iriFactory.setIsError(ViolationCodes.UNREGISTERED_IANA_SCHEME,false);
+        iriFactory.setIsWarning(ViolationCodes.UNREGISTERED_IANA_SCHEME,false);
+
+        iriFactory.create("");
+
+    }
+    
+    private static void iriTest(String iriStr)
+    {
+        System.out.println("IRI =  "+iriStr) ;
+        IRIFactory factory = iriFactory ;
+        
+        IRI iri = factory.create(iriStr) ;
+        System.out.println("IRI => "+iri.toDisplayString()) ;
+        
+        
+        Iterator<Violation> iter = iri.violations(true) ;
+        for ( ; iter.hasNext();  )
+        {
+            Violation v = iter.next();
+            String x = (v.isError()?"ERROR":"WARN ") ;
+            
+            int code = v.getViolationCode() ;
+            
+//            // Treat these with low priority.
+//            if ( code == Violation.LOWERCASE_PREFERRED ||
+//                code == Violation.PERCENT_ENCODING_SHOULD_BE_UPPERCASE )
+//            {
+//                continue ;
+//            }
+            
+            System.out.printf("%s  %s\n", x, v.getShortMessage()) ;
+        }
+    }
+    
+    private static void varBlock()
+    {
+        byte[] d1 = {1,2,3,4} ;
+        byte[] d2 = {(byte)0xFF, (byte)0xFE} ;
+
+        byte[] d3 = {5,4,5,4,3,2,3,2,1,1} ;
+        byte[] d4 = {(byte)0xFF, (byte)0xFE, (byte)0xFD, (byte)0xFC, (byte)0xFB} ;
+        
+        {
+            VarRecordBuffer vrb = new VarRecordBuffer(50) ;
+            vrb.dump();
+            vrb.put(d1,d2) ;
+            vrb.dump();
+            vrb.put(d3,d4) ;
+            vrb.dump();
+            System.out.println(vrb) ;
+            Record r = vrb.get(0) ;
+
+            System.out.println(r) ;
+            System.exit(0) ;
+        }
+        
+        VarRecordBuffer vrb = new VarRecordBuffer(40) ;
+        byte[] k1 = new byte[]{1,2} ;
+        byte[] v1 = new byte[]{(byte)0xA9, (byte)0xA8, (byte)0xA7 }; //, (byte)0xA6} ;
+
+        byte[] k2 = new byte[]{3,4} ;
+        byte[] v2 = new byte[]{(byte)0xFF, (byte)0xFE, (byte)0xFD, (byte)0xFC} ;
+        
+        byte[] k3 = new byte[]{5,6} ;
+        byte[] v3 = new byte[]{(byte)0xBF, (byte)0xBE} ;//, (byte)0xBD, (byte)0xBC} ;
+        
+        //byte[] v3 = new byte[100] ;
+
+        divider() ;
+
+        boolean PRINT = false ;
+            
+        if ( PRINT ) System.out.println("k="+str(k1)+", v="+str(v1)) ;
+        vrb.put(0, k1, v1) ;
+        if ( PRINT ) vrb.dump();
+        if ( PRINT ) System.out.println(vrb) ;
+
+        if ( PRINT )divider() ;
+
+        // Push up.
+        if ( PRINT ) System.out.println("k="+str(k2)+", v="+str(v2)) ;
+        vrb.put(0, k2, v2) ;
+        if ( PRINT ) vrb.dump();
+        if ( PRINT ) System.out.println(vrb) ;
+
+        if ( PRINT ) divider() ;
+        
+        if ( PRINT ) System.out.println("k="+str(k3)+", v="+str(v3)) ;
+        vrb.put(2, k3, v3) ;
+        if ( PRINT ) vrb.dump();
+        if ( PRINT ) System.out.println(vrb) ;
+
+        PRINT = false ;
+        if ( PRINT ) divider() ;
+        if ( PRINT ) vrb.dump();
+        if ( PRINT ) System.out.println(vrb) ;
+        vrb.delete(1) ;
+        if ( PRINT ) vrb.dump();
+        System.out.println(vrb) ;
+        
+        
+    }
+
+    private static String str(byte[] bytes)
+    {
+        StringBuilder sb = new StringBuilder() ;
+        char sep = 0 ;
+        for ( byte b : bytes )
+        {
+            if ( sep != 0 )
+                sb.append(sep) ;
+            else
+                sep = ' ' ;
+                
+            sb.append(String.format("%02X", b)) ;
+        }
+        return sb.toString() ;
+    }
+
+ 
+    // ---- Helpers
+    
+    private static final String NL = "\n" ;
+
+    public static String divider = "---- ----" ;
+
+    private static String nextDivider = null ;
+    
+    public static void divider()
+    {
+        if ( nextDivider != null )
+            System.out.println(nextDivider) ;
+        nextDivider = divider ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/SizeIndexes.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/SizeIndexes.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/SizeIndexes.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/SizeIndexes.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/StringUTF8.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/StringUTF8.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/StringUTF8.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/StringUTF8.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,85 +16,85 @@
  * limitations under the License.
  */
 
-package dev;
-
-import java.nio.ByteBuffer ;
-
-import migrate.lib.VarInteger ;
-import org.openjena.atlas.lib.Pair ;
-import org.openjena.atlas.lib.StrUtils ;
-
-public class StringUTF8
-{
-    // See also:
-    // http://www.unicode.org/reports/tr6/ -- a compression scheme for Unicode. 
-    // ftp://ftp.unicode.org/Public/PROGRAMS/SCSU/
-    
-    
-    /* A compact string.
-     * Stored as:
-     * [int - allocation space]
-     * int - length
-     * bytes - UTF8 
-     * except:
-     *   ints are held as Varints
-     *   bytes (FF, 00) is "http://"
-     *   bytes (FF, 01) is "http://www."
-     *   
-     *   FF is an illegal UTF8 byte, as a first byte of a UTF-8 codepoint sequence.
-     *   F5-FF would be 4 byte sequences above 10FFFF
-     *   80-BF not in a first byte.  
-     *   
-     *   Eventually, will be a slice of a very large ByteBuffer and we will do our own malloc.
-     *   
-     * 00000000-01111111   00-7F   0-127       Single-byte encoding (compatible with US-ASCII)
-     * 10000000-10111111   80-BF   128-191     Second, third, or fourth byte of a multi-byte sequence
-     * 11000000-11000001   C0-C1   192-193     Overlong encoding: start of 2-byte sequence, but would encode a code point ≤ 127
-     * 11000010-11011111   C2-DF   194-223     Start of 2-byte sequence
-     * 11100000-11101111   E0-EF   224-239     Start of 3-byte sequence
-     * 11110000-11110100   F0-F4   240-244     Start of 4-byte sequence
-     * 11110101-11110111   F5-F7   245-247     Restricted by RFC 3629: start of 4-byte sequence for codepoint above 10FFFF
-     * 11111000-11111011   F8-FB   248-251     Restricted by RFC 3629: start of 5-byte sequence
-     * 11111100-11111101   FC-FD   252-253     Restricted by RFC 3629: start of 6-byte sequence
-     * 11111110-11111111   FE-FF   254-255     Invalid: not defined by original UTF-8 specification
-     *     
-     */
-    
-    public static StringUTF8 alloc(String string)
-    {
-        return null ;
-    }
-    
-    // V1 - object allocation.
-    
-    private VarInteger length ;
-    private ByteBuffer bytes ;
-    private StringUTF8(String string)
-    {
-        // A copy ...
-        byte[] rawbytes = StrUtils.asUTF8bytes(string) ;
-        bytes = ByteBuffer.wrap(rawbytes) ;
-        length = VarInteger.valueOf(rawbytes.length) ;
-    }
-    
-    public String asString() {return StrUtils.fromUTF8bytes(bytes.array()) ; }
-    
-    @Override
-    public String toString() { return asString() ; }
-    
-    
-    static ByteBuffer space1 = ByteBuffer.allocate(1000*1000) ;
-    
-    private static Pair<VarInteger, VarInteger> allocSpace(String string)
-    {
-        return null ;
-    }
-    
-    private static ByteBuffer allocSpace(VarInteger allocSpaceId, VarInteger allocId)
-    {
-        if ( allocSpaceId.value() != 0 )
-            throw new IllegalArgumentException() ;
-        return space1 ;
-    }
-    
+package dev;
+
+import java.nio.ByteBuffer ;
+
+import migrate.lib.VarInteger ;
+import org.openjena.atlas.lib.Pair ;
+import org.openjena.atlas.lib.StrUtils ;
+
+public class StringUTF8
+{
+    // See also:
+    // http://www.unicode.org/reports/tr6/ -- a compression scheme for Unicode. 
+    // ftp://ftp.unicode.org/Public/PROGRAMS/SCSU/
+    
+    
+    /* A compact string.
+     * Stored as:
+     * [int - allocation space]
+     * int - length
+     * bytes - UTF8 
+     * except:
+     *   ints are held as Varints
+     *   bytes (FF, 00) is "http://"
+     *   bytes (FF, 01) is "http://www."
+     *   
+     *   FF is an illegal UTF8 byte, as a first byte of a UTF-8 codepoint sequence.
+     *   F5-FF would be 4 byte sequences above 10FFFF
+     *   80-BF not in a first byte.  
+     *   
+     *   Eventually, will be a slice of a very large ByteBuffer and we will do our own malloc.
+     *   
+     * 00000000-01111111   00-7F   0-127       Single-byte encoding (compatible with US-ASCII)
+     * 10000000-10111111   80-BF   128-191     Second, third, or fourth byte of a multi-byte sequence
+     * 11000000-11000001   C0-C1   192-193     Overlong encoding: start of 2-byte sequence, but would encode a code point ≤ 127
+     * 11000010-11011111   C2-DF   194-223     Start of 2-byte sequence
+     * 11100000-11101111   E0-EF   224-239     Start of 3-byte sequence
+     * 11110000-11110100   F0-F4   240-244     Start of 4-byte sequence
+     * 11110101-11110111   F5-F7   245-247     Restricted by RFC 3629: start of 4-byte sequence for codepoint above 10FFFF
+     * 11111000-11111011   F8-FB   248-251     Restricted by RFC 3629: start of 5-byte sequence
+     * 11111100-11111101   FC-FD   252-253     Restricted by RFC 3629: start of 6-byte sequence
+     * 11111110-11111111   FE-FF   254-255     Invalid: not defined by original UTF-8 specification
+     *     
+     */
+    
+    public static StringUTF8 alloc(String string)
+    {
+        return null ;
+    }
+    
+    // V1 - object allocation.
+    
+    private VarInteger length ;
+    private ByteBuffer bytes ;
+    private StringUTF8(String string)
+    {
+        // A copy ...
+        byte[] rawbytes = StrUtils.asUTF8bytes(string) ;
+        bytes = ByteBuffer.wrap(rawbytes) ;
+        length = VarInteger.valueOf(rawbytes.length) ;
+    }
+    
+    public String asString() {return StrUtils.fromUTF8bytes(bytes.array()) ; }
+    
+    @Override
+    public String toString() { return asString() ; }
+    
+    
+    static ByteBuffer space1 = ByteBuffer.allocate(1000*1000) ;
+    
+    private static Pair<VarInteger, VarInteger> allocSpace(String string)
+    {
+        return null ;
+    }
+    
+    private static ByteBuffer allocSpace(VarInteger allocSpaceId, VarInteger allocId)
+    {
+        if ( allocSpaceId.value() != 0 )
+            throw new IllegalArgumentException() ;
+        return space1 ;
+    }
+    
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/TestModelCreation.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/TestModelCreation.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/TestModelCreation.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/TestModelCreation.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,29 +16,29 @@
  * limitations under the License.
  */
 
-package dev;
-
-import java.util.HashMap ;
-import java.util.Map ;
-
-import com.hp.hpl.jena.sparql.util.Timer ;
-
-public class TestModelCreation
-{
-    public static void main(String...argv)
-    {
-        //org.openjena.atlas.logging.Log.setLog4j() ;
-        int N = 1000000 ;
-        Object[] objects = new Object[100] ;
-        Timer t = new Timer() ;
-        t.startTimer() ;
-        for ( int i = 0 ; i < N; i++ )
-        {
-            //Model m = ModelFactory.createDefaultModel() ;
-            Map<Object, Object> m = new HashMap<Object, Object>() ;
-            objects[i%100] = m ;
-        }
-        long millis = t.endTimer() ;
-        System.out.printf("Time = %.2fs for %,d creations. Rate = %,.2f objects/s\n", millis/1000.0, N, N*(1000.0/millis)) ;
-    }
+package dev;
+
+import java.util.HashMap ;
+import java.util.Map ;
+
+import com.hp.hpl.jena.sparql.util.Timer ;
+
+public class TestModelCreation
+{
+    public static void main(String...argv)
+    {
+        //org.openjena.atlas.logging.Log.setLog4j() ;
+        int N = 1000000 ;
+        Object[] objects = new Object[100] ;
+        Timer t = new Timer() ;
+        t.startTimer() ;
+        for ( int i = 0 ; i < N; i++ )
+        {
+            //Model m = ModelFactory.createDefaultModel() ;
+            Map<Object, Object> m = new HashMap<Object, Object>() ;
+            objects[i%100] = m ;
+        }
+        long millis = t.endTimer() ;
+        System.out.printf("Time = %.2fs for %,d creations. Rate = %,.2f objects/s\n", millis/1000.0, N, N*(1000.0/millis)) ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/Graph2.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/Graph2.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/Graph2.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/Graph2.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,110 +16,110 @@
  * limitations under the License.
  */
 
-package dev.g2;
-
-import java.util.Iterator ;
-
-import org.openjena.atlas.iterator.Iter ;
-import org.openjena.atlas.iterator.Transform ;
-import org.openjena.atlas.lib.ColumnMap ;
-import org.openjena.atlas.lib.Tuple ;
-
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.graph.Triple ;
-import com.hp.hpl.jena.graph.TripleMatch ;
-import com.hp.hpl.jena.graph.query.QueryHandler ;
-import com.hp.hpl.jena.shared.PrefixMapping ;
-import com.hp.hpl.jena.shared.impl.PrefixMappingImpl ;
-import com.hp.hpl.jena.sparql.graph.GraphBase2 ;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator ;
-import com.hp.hpl.jena.util.iterator.NiceIterator ;
-
-public class Graph2 extends GraphBase2
-{
-    //TupleDex  
-    TupleDex indexes[] = { new TupleDex(new ColumnMap("SPO", "SPO")) , 
-                           new TupleDex(new ColumnMap("SPO", "POS")) ,
-                           new TupleDex(new ColumnMap("SPO", "OSP")) } ; 
-    @Override
-    protected PrefixMapping createPrefixMapping()
-    {
-        return new PrefixMappingImpl() ;
-    }
-
-    @Override
-    protected ExtendedIterator<Triple> graphBaseFind(TripleMatch m)
-    {
-        Node s = m.getMatchSubject() ;
-        Node p = m.getMatchPredicate() ;
-        Node o = m.getMatchObject() ;
-        
-        // A bit mixed between tuples and S,P,O - solve with Tuple>Triple
-        Tuple<Node> tuple = Tuple.create(s,p,o) ;
-        int indexNumSlots = -1 ;
-        int index = -1 ;
-        TupleDex tupleIndex = null ;
-        
-        for ( int i = 0 ; i < indexes.length ; i++ )
-        {
-            TupleDex idx = indexes[i] ;
-            if ( idx != null )
-            {
-                int w = idx.weight(tuple) ;
-                if ( w > indexNumSlots )
-                {
-                    indexNumSlots = w ;
-                    tupleIndex = idx ;
-                }
-            }
-        }
-        
-        if ( tupleIndex == null )
-            // Scan
-            tupleIndex = indexes[0] ;
-
-        Iterator<Triple> iter = Iter.map(tupleIndex.find(tuple), transform) ;
-        return new MapperIteratorTriples(iter) ;
-    }
-
-    // Convert from Iterator<Triple> to ExtendedIterator
-    static class MapperIteratorTriples extends NiceIterator<Triple>
-    {
-        private final Iterator<Triple> iter ;
-        MapperIteratorTriples(Iterator<Triple> iter) { this.iter = iter ; }
-        @Override public boolean hasNext() { return iter.hasNext() ; } 
-        @Override public Triple next() { return iter.next(); }
-        @Override public void remove() { iter.remove(); }
-    }
-    
-    @Override
-    public QueryHandler queryHandler()
-    {
-        return null ;
-    }
-    
-    @Override
-    public void performAdd( Triple t )
-    {
-        Tuple<Node> tuple = Tuple.create(t.getSubject(), t.getPredicate(), t.getObject()) ;
-        for ( TupleDex index : indexes )
-            index.add(tuple) ;
-    }
-    
-    @Override
-    public void performDelete( Triple t )
-    {
-        Tuple<Node> tuple = Tuple.create(t.getSubject(), t.getPredicate(), t.getObject()) ;
-        for ( TupleDex index : indexes )
-            index.remove(tuple) ;
-    }
-    
-    static Transform<Tuple<Node>, Triple> transform = new Transform<Tuple<Node>, Triple>() {
-
-        @Override
-        public Triple convert(Tuple<Node> tuple)
-        {
-            return new Triple(tuple.get(0), tuple.get(1), tuple.get(2)) ;
-        }} ;
-
+package dev.g2;
+
+import java.util.Iterator ;
+
+import org.openjena.atlas.iterator.Iter ;
+import org.openjena.atlas.iterator.Transform ;
+import org.openjena.atlas.lib.ColumnMap ;
+import org.openjena.atlas.lib.Tuple ;
+
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.Triple ;
+import com.hp.hpl.jena.graph.TripleMatch ;
+import com.hp.hpl.jena.graph.query.QueryHandler ;
+import com.hp.hpl.jena.shared.PrefixMapping ;
+import com.hp.hpl.jena.shared.impl.PrefixMappingImpl ;
+import com.hp.hpl.jena.sparql.graph.GraphBase2 ;
+import com.hp.hpl.jena.util.iterator.ExtendedIterator ;
+import com.hp.hpl.jena.util.iterator.NiceIterator ;
+
+public class Graph2 extends GraphBase2
+{
+    //TupleDex  
+    TupleDex indexes[] = { new TupleDex(new ColumnMap("SPO", "SPO")) , 
+                           new TupleDex(new ColumnMap("SPO", "POS")) ,
+                           new TupleDex(new ColumnMap("SPO", "OSP")) } ; 
+    @Override
+    protected PrefixMapping createPrefixMapping()
+    {
+        return new PrefixMappingImpl() ;
+    }
+
+    @Override
+    protected ExtendedIterator<Triple> graphBaseFind(TripleMatch m)
+    {
+        Node s = m.getMatchSubject() ;
+        Node p = m.getMatchPredicate() ;
+        Node o = m.getMatchObject() ;
+        
+        // A bit mixed between tuples and S,P,O - solve with Tuple>Triple
+        Tuple<Node> tuple = Tuple.create(s,p,o) ;
+        int indexNumSlots = -1 ;
+        int index = -1 ;
+        TupleDex tupleIndex = null ;
+        
+        for ( int i = 0 ; i < indexes.length ; i++ )
+        {
+            TupleDex idx = indexes[i] ;
+            if ( idx != null )
+            {
+                int w = idx.weight(tuple) ;
+                if ( w > indexNumSlots )
+                {
+                    indexNumSlots = w ;
+                    tupleIndex = idx ;
+                }
+            }
+        }
+        
+        if ( tupleIndex == null )
+            // Scan
+            tupleIndex = indexes[0] ;
+
+        Iterator<Triple> iter = Iter.map(tupleIndex.find(tuple), transform) ;
+        return new MapperIteratorTriples(iter) ;
+    }
+
+    // Convert from Iterator<Triple> to ExtendedIterator
+    static class MapperIteratorTriples extends NiceIterator<Triple>
+    {
+        private final Iterator<Triple> iter ;
+        MapperIteratorTriples(Iterator<Triple> iter) { this.iter = iter ; }
+        @Override public boolean hasNext() { return iter.hasNext() ; } 
+        @Override public Triple next() { return iter.next(); }
+        @Override public void remove() { iter.remove(); }
+    }
+    
+    @Override
+    public QueryHandler queryHandler()
+    {
+        return null ;
+    }
+    
+    @Override
+    public void performAdd( Triple t )
+    {
+        Tuple<Node> tuple = Tuple.create(t.getSubject(), t.getPredicate(), t.getObject()) ;
+        for ( TupleDex index : indexes )
+            index.add(tuple) ;
+    }
+    
+    @Override
+    public void performDelete( Triple t )
+    {
+        Tuple<Node> tuple = Tuple.create(t.getSubject(), t.getPredicate(), t.getObject()) ;
+        for ( TupleDex index : indexes )
+            index.remove(tuple) ;
+    }
+    
+    static Transform<Tuple<Node>, Triple> transform = new Transform<Tuple<Node>, Triple>() {
+
+        @Override
+        public Triple convert(Tuple<Node> tuple)
+        {
+            return new Triple(tuple.get(0), tuple.get(1), tuple.get(2)) ;
+        }} ;
+
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/Index.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/Index.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/Index.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/Index.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,24 +16,24 @@
  * limitations under the License.
  */
 
-package dev.g2 ;
-
-import java.util.Iterator;
-
-/** A simplified "map" interface */
-public interface Index<K, V>
-{
-    public V get(K key) ;
-
-    public void put(K key, V value) ;
-
-    public void remove(K key) ;
-
-    public int size() ;
-
-    public boolean isEmpty() ;
-
-    //public Collection<V> values() { return map.values() ; }
-    public Iterator<K> keys() ;
-
+package dev.g2 ;
+
+import java.util.Iterator;
+
+/** A simplified "map" interface */
+public interface Index<K, V>
+{
+    public V get(K key) ;
+
+    public void put(K key, V value) ;
+
+    public void remove(K key) ;
+
+    public int size() ;
+
+    public boolean isEmpty() ;
+
+    //public Collection<V> values() { return map.values() ; }
+    public Iterator<K> keys() ;
+
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/IndexImpl.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/IndexImpl.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/IndexImpl.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/IndexImpl.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,37 +16,37 @@
  * limitations under the License.
  */
 
-package dev.g2;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.openjena.atlas.lib.DS;
-
-/** Simplified map */
-public class IndexImpl<K, V> implements Index<K, V> 
-{
-    private Map<K,V> map = DS.map() ;
-    
-    public IndexImpl() {}
-    
-    @Override
-    public V get(K key) { return map.get(key) ; }
-    @Override
-    public void put(K key, V value) { map.put(key, value) ; }
-    
-    @Override
-    public void remove(K key) { map.remove(key) ; }
-    
-    @Override
-    public int size() { return map.size() ; }
-    @Override
-    public boolean isEmpty() { return map.isEmpty() ; }
-    
-    //public Collection<V> values() { return map.values() ; }
-    @Override
-    public Iterator<K> keys() { return map.keySet().iterator() ; }
-    
-    @Override
-    public String toString() { return map.toString() ; }
+package dev.g2;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.openjena.atlas.lib.DS;
+
+/** Simplified map */
+public class IndexImpl<K, V> implements Index<K, V> 
+{
+    private Map<K,V> map = DS.map() ;
+    
+    public IndexImpl() {}
+    
+    @Override
+    public V get(K key) { return map.get(key) ; }
+    @Override
+    public void put(K key, V value) { map.put(key, value) ; }
+    
+    @Override
+    public void remove(K key) { map.remove(key) ; }
+    
+    @Override
+    public int size() { return map.size() ; }
+    @Override
+    public boolean isEmpty() { return map.isEmpty() ; }
+    
+    //public Collection<V> values() { return map.values() ; }
+    @Override
+    public Iterator<K> keys() { return map.keySet().iterator() ; }
+    
+    @Override
+    public String toString() { return map.toString() ; }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/MultiBunch.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/MultiBunch.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/MultiBunch.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/MultiBunch.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,40 +16,40 @@
  * limitations under the License.
  */
 
-package dev.g2;
-
-import java.util.Iterator;
-
-import org.openjena.atlas.lib.Pair;
-
-/** A storage of (K, Set<V>) - i.e. a multivalued map; only one occurence of each distinct V per K */ 
-public interface MultiBunch<K,V>
-{
-//    /** Lookup a key : iterator preferred */ 
-//    public Collection<V> get(K key) ;
-    
-    public boolean contains(K key, V value) ;
-    
-    /** All keys */
-    public Iterator<K> keys() ;
-    
-    /** All values associated with a key */
-    public Iterator<V> iterator(K key) ;
-    
-    /** Everything */
-    public Iterator<Pair<K,V>> iterator() ;
-
-    /** Add a key/value pair, return true if the bunch was altered */
-    public boolean add(K key, V value) ;
-
-    /** Remove a key/value pair, return true if the bunch was altered */
-    public boolean remove(K key, V value) ;
-
-    /** Remove all key/value pairs */
-    public void clear() ;
-
-    public boolean isEmpty() ;
-    
-    public long size() ;
-
+package dev.g2;
+
+import java.util.Iterator;
+
+import org.openjena.atlas.lib.Pair;
+
+/** A storage of (K, Set<V>) - i.e. a multivalued map; only one occurence of each distinct V per K */ 
+public interface MultiBunch<K,V>
+{
+//    /** Lookup a key : iterator preferred */ 
+//    public Collection<V> get(K key) ;
+    
+    public boolean contains(K key, V value) ;
+    
+    /** All keys */
+    public Iterator<K> keys() ;
+    
+    /** All values associated with a key */
+    public Iterator<V> iterator(K key) ;
+    
+    /** Everything */
+    public Iterator<Pair<K,V>> iterator() ;
+
+    /** Add a key/value pair, return true if the bunch was altered */
+    public boolean add(K key, V value) ;
+
+    /** Remove a key/value pair, return true if the bunch was altered */
+    public boolean remove(K key, V value) ;
+
+    /** Remove all key/value pairs */
+    public void clear() ;
+
+    public boolean isEmpty() ;
+    
+    public long size() ;
+
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/MultiBunchSimple.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/MultiBunchSimple.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/MultiBunchSimple.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/MultiBunchSimple.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,124 +16,124 @@
  * limitations under the License.
  */
 
-package dev.g2;
-
-import org.openjena.atlas.iterator.Iter;
-import org.openjena.atlas.iterator.IteratorConcat;
-import org.openjena.atlas.iterator.NullIterator;
-import org.openjena.atlas.iterator.Transform;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.openjena.atlas.lib.Pair;
-
-/** TEMPORARY implementation */ 
-public class MultiBunchSimple<K, V> implements MultiBunch<K, V>
-{
-    private Index<K, Collection<V>> index ;
-    //static Iterator<V> zero = new NullIterator<V>() ;
-    
-    public MultiBunchSimple()
-    {
-        clear() ;
-    }
-    
-    @Override
-    public boolean add(K key, V value)
-    {
-        Collection<V> set = index.get(key) ;
-        if ( set == null )
-        {
-            set = new ArrayList<V>() ;
-            index.put(key, set) ;
-        }
-        return set.add(value) ;
-    }
-    
-    @Override
-    public boolean remove(K key, V value)
-    {
-        Collection<V> set = index.get(key) ;
-        if ( set == null )
-            return false ;
-        return set.remove(value) ;
-    }
-
-    @Override
-    public void clear()
-    { index = new IndexImpl<K,  Collection<V>>() ;}
-
-    @Override
-    public boolean contains(K key, V value)
-    {
-        Collection<V> set = index.get(key) ;
-        if ( set == null )
-            return false ;
-        return set.contains(value) ;
-    }
-
-    @Override
-    public boolean isEmpty()
-    {
-        if ( index.isEmpty() ) return true ;
-        for( Iterator<K> iter = index.keys() ; iter.hasNext(); )
-        {
-            K key = iter.next() ;
-            if ( ! index.get(key).isEmpty() )
-                return false ;
-        }
-        return false ;
-    }
-
-    @Override
-    public long size()
-    {
-        long num = 0 ;
-        for( Iterator<K> iter = index.keys() ; iter.hasNext(); )
-        {
-            K key = iter.next() ;
-            num += index.get(key).size() ;
-        }
-        return num ;
-    }
-
-    @Override
-    public Iterator<V> iterator(K key)
-    {
-        Collection<V> set = index.get(key) ;
-        if ( set == null )
-            return new NullIterator<V>() ;
-        return set.iterator() ;
-    }
-
-    @Override
-    public Iterator<Pair<K, V>> iterator()
-    {
-        IteratorConcat<Pair<K,V>> concat = new IteratorConcat<Pair<K,V>>() ;
-        Iterator<K> keys = index.keys() ;
-        for ( ; keys.hasNext(); )
-        {
-            final K key = keys.next() ;
-            Transform<V, Pair<K,V>> t = new Transform<V, Pair<K,V>>(){
-
-                @Override
-                public Pair<K, V> convert(V value)
-                {
-                    return new Pair<K,V>(key, value) ;
-                }} ;
-            concat.add(Iter.map(index.get(key), t)) ;
-        }
-        return concat ;
-    }
-
-    @Override
-    public Iterator<K> keys()
-    {
-        return index.keys() ;
-    }
-    
-    @Override
-    public String toString() { return index.toString() ; }
+package dev.g2;
+
+import org.openjena.atlas.iterator.Iter;
+import org.openjena.atlas.iterator.IteratorConcat;
+import org.openjena.atlas.iterator.NullIterator;
+import org.openjena.atlas.iterator.Transform;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.openjena.atlas.lib.Pair;
+
+/** TEMPORARY implementation */ 
+public class MultiBunchSimple<K, V> implements MultiBunch<K, V>
+{
+    private Index<K, Collection<V>> index ;
+    //static Iterator<V> zero = new NullIterator<V>() ;
+    
+    public MultiBunchSimple()
+    {
+        clear() ;
+    }
+    
+    @Override
+    public boolean add(K key, V value)
+    {
+        Collection<V> set = index.get(key) ;
+        if ( set == null )
+        {
+            set = new ArrayList<V>() ;
+            index.put(key, set) ;
+        }
+        return set.add(value) ;
+    }
+    
+    @Override
+    public boolean remove(K key, V value)
+    {
+        Collection<V> set = index.get(key) ;
+        if ( set == null )
+            return false ;
+        return set.remove(value) ;
+    }
+
+    @Override
+    public void clear()
+    { index = new IndexImpl<K,  Collection<V>>() ;}
+
+    @Override
+    public boolean contains(K key, V value)
+    {
+        Collection<V> set = index.get(key) ;
+        if ( set == null )
+            return false ;
+        return set.contains(value) ;
+    }
+
+    @Override
+    public boolean isEmpty()
+    {
+        if ( index.isEmpty() ) return true ;
+        for( Iterator<K> iter = index.keys() ; iter.hasNext(); )
+        {
+            K key = iter.next() ;
+            if ( ! index.get(key).isEmpty() )
+                return false ;
+        }
+        return false ;
+    }
+
+    @Override
+    public long size()
+    {
+        long num = 0 ;
+        for( Iterator<K> iter = index.keys() ; iter.hasNext(); )
+        {
+            K key = iter.next() ;
+            num += index.get(key).size() ;
+        }
+        return num ;
+    }
+
+    @Override
+    public Iterator<V> iterator(K key)
+    {
+        Collection<V> set = index.get(key) ;
+        if ( set == null )
+            return new NullIterator<V>() ;
+        return set.iterator() ;
+    }
+
+    @Override
+    public Iterator<Pair<K, V>> iterator()
+    {
+        IteratorConcat<Pair<K,V>> concat = new IteratorConcat<Pair<K,V>>() ;
+        Iterator<K> keys = index.keys() ;
+        for ( ; keys.hasNext(); )
+        {
+            final K key = keys.next() ;
+            Transform<V, Pair<K,V>> t = new Transform<V, Pair<K,V>>(){
+
+                @Override
+                public Pair<K, V> convert(V value)
+                {
+                    return new Pair<K,V>(key, value) ;
+                }} ;
+            concat.add(Iter.map(index.get(key), t)) ;
+        }
+        return concat ;
+    }
+
+    @Override
+    public Iterator<K> keys()
+    {
+        return index.keys() ;
+    }
+    
+    @Override
+    public String toString() { return index.toString() ; }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/TupleDex.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/TupleDex.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/TupleDex.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/TupleDex.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,204 +16,204 @@
  * limitations under the License.
  */
 
-package dev.g2;
-
-import org.openjena.atlas.iterator.*;
-
-import java.util.Iterator;
-
-import org.openjena.atlas.lib.ColumnMap;
-import org.openjena.atlas.lib.Tuple;
-
-import com.hp.hpl.jena.graph.Node;
-
-public class TupleDex 
-{
-    // Currently assumes 3-Tuple.
-    // Later support into N-tuple with a M<=N key 
-    // Reconsider naming.
-    
-    Index<Node, MultiBunch<Node, Node>> index = new IndexImpl<Node, MultiBunch<Node, Node>>() ;
-    ColumnMap colMap ;
-    Transform<Tuple<Node>, Tuple<Node>> unmap ;
-
-    
-    static Iterator<Tuple<Node>> zero = new NullIterator<Tuple<Node>>() ;
-    
-    public TupleDex(ColumnMap cm){ 
-        this.colMap = cm ;
-        this.unmap = new Transform<Tuple<Node>, Tuple<Node>> () {
-            @Override
-            public Tuple<Node> convert(Tuple<Node> item)
-            {
-                return colMap.unmap(item) ;
-            }} ;
-    }
-    
-    public boolean add(Tuple<Node> tuple)
-    {
-        Node n1 = colMap.fetchSlot(0, tuple) ; 
-        Node n2 = colMap.fetchSlot(1, tuple) ;
-        Node n3 = colMap.fetchSlot(2, tuple) ;
-        
-        MultiBunch<Node, Node> bunch = index.get(n1) ;
-        // XXX Adjust the MultiBunch implementation as it grows.
-        if ( bunch == null )
-        {
-            bunch = new MultiBunchSimple<Node, Node>() ;
-            index.put(n1, bunch) ;
-        }
-        return bunch.add(n2, n3) ;
-        
-    }
-    
-    public boolean remove(Tuple<Node> tuple)
-    {
-        Node n1 = colMap.fetchSlot(0, tuple) ; 
-        Node n2 = colMap.fetchSlot(1, tuple) ;
-        Node n3 = colMap.fetchSlot(2, tuple) ;
-    
-        MultiBunch<Node, Node> bunch = index.get(n1) ;
-        if ( bunch == null )
-            return false ;
-        boolean b = bunch.remove(n2, n3) ;
-        // Could adjust the MultiBunch implementation as it shrinks
-        // but if we are doing a lot of removals (e.g. implicit removeAll), then that makes work 
-        if ( bunch.isEmpty() )
-            index.put(n1, null) ;
-        return b ;
-    }
-
-    public Iterator<Tuple<Node>> find(Tuple<Node> tuple)
-    {
-        tuple = colMap.map(tuple) ;
-        Iterator<Tuple<Node>> iter = find(tuple.get(0), tuple.get(1), tuple.get(2)) ;
-        return Iter.map(iter, unmap) ; 
-    }
-    
-    private Iterator<Tuple<Node>> find(final Node x, final Node y, Node z)
-    {
-        if ( x == null )
-        {
-            // X=? (Maybe Y and Z - 4 cases) 
-            Iterator<Node> iter1 = index.keys() ;
-            IteratorConcat<Tuple<Node>> iter = new IteratorConcat<Tuple<Node>>() ;
-            for ( ; iter1.hasNext() ; )
-            {
-                Node node1 = iter1.next() ;
-                MultiBunch<Node, Node> bunch = index.get(node1) ;
-//                if ( bunch == null )
-//                    continue ;  // ???!!!
-                iter.add(find1(node1, bunch, y, z)) ;
-            }
-            return iter ;
-        }
-        
-        MultiBunch<Node, Node> bunch = index.get(x) ;
-        
-        if ( bunch == null )
-            return zero ;
-
-        if ( y != null )
-        {
-            if ( z != null )
-            {
-                // X Y Z - 1 case
-                if ( bunch.contains(y, z) )
-                    return new SingletonIterator<Tuple<Node>>(Tuple.create(x,y,z)) ;
-                else
-                    return zero ;
-            }
-            // X Y ? - 1 case
-            Iterator<Node> zPart = bunch.iterator(y) ;
-            return find2(x, y, zPart) ;
-        }
-        // y is null.
-        // X ? ? or X ? Z - 2 cases 
-        // Total cases: 8
-        
-        // -----
-        return find1(x, bunch, y, z) ;
-    }
-
-    private Iterator<Tuple<Node>> find1(Node x, MultiBunch<Node, Node> bunch, final Node y, final Node z)
-    {
-//        if ( bunch == null )
-//            return zero ;
-        
-        IteratorConcat<Tuple<Node>> iter = new IteratorConcat<Tuple<Node>>() ;
-        
-        Iterator<Node> iter1 = bunch.keys() ;
-        
-        for ( ; iter1.hasNext() ;  )
-        {
-            Node key = iter1.next() ;
-            Iterator<Node> part3 = bunch.iterator(key) ;
-            Iterator<Tuple<Node>> iter2 = find2(x, key, part3) ;
-            iter.add(iter2) ;
-        }
-        if ( y == null && z == null )
-            return iter ;
-        // Some sort of scan.
-        Filter<Tuple<Node>> filter = new Filter<Tuple<Node>>() {
-            @Override
-            public boolean accept(Tuple<Node> tuple)
-            {
-                if ( y != null && !y.equals(tuple.get(1)) ) return false ;
-                if ( z != null && !z.equals(tuple.get(2)) ) return false ;
-                return true ;
-            }} ;
-        return Iter.filter(iter, filter) ; 
-    }
-    
-    private Iterator<Tuple<Node>> find2(final Node x, final Node y, Iterator<Node> part)
-    {
-        Transform<Node, Tuple<Node>> t = new Transform<Node, Tuple<Node>>(){
-            @Override
-            public Tuple<Node> convert(Node item)
-            {
-                return Tuple.create(x, y, item) ;
-            }} ;
-        Iterator<Tuple<Node>> iter2 = Iter.map(part, t) ;
-        return iter2 ;
-    }
-    
-    private static void checkNotNull(Node x)
-    {
-        if ( x == null ) throw new RuntimeException("Null") ;
-    }
-    private static void checkNull(Node x)
-    {
-        if ( x != null ) throw new RuntimeException("Not null: "+x) ;
-    }
-
-    public int weight(Tuple<Node> tuple)
-    {
-//        System.out.println("Index: "+this) ;
-//        System.out.println("Weight: "+tuple) ;
-//        
-//        System.out.println("  "+colMap.fetchSlot(0, tuple)) ;
-//        System.out.println("  "+colMap.fetchSlot(1, tuple)) ;
-//        System.out.println("  "+colMap.fetchSlot(2, tuple)) ;
-//        System.out.println("Mapped: "+colMap.map(tuple)) ;
-//        
-        if ( undef(colMap.fetchSlot(0, tuple)) ) return 0 ;
-        if ( undef(colMap.fetchSlot(1, tuple)) ) return 1 ;
-        if ( undef(colMap.fetchSlot(2, tuple)) ) return 2 ;
-        return 3 ;
-    }
-    
-    private boolean undef(Object x)
-    { return x == null ; }
-
-    @Override
-    public String toString()
-    {
-        return label() ;
-    }
-    
-    public String label()
-    {
-        return colMap.getLabel() ; 
-    }
+package dev.g2;
+
+import org.openjena.atlas.iterator.*;
+
+import java.util.Iterator;
+
+import org.openjena.atlas.lib.ColumnMap;
+import org.openjena.atlas.lib.Tuple;
+
+import com.hp.hpl.jena.graph.Node;
+
+public class TupleDex 
+{
+    // Currently assumes 3-Tuple.
+    // Later support into N-tuple with a M<=N key 
+    // Reconsider naming.
+    
+    Index<Node, MultiBunch<Node, Node>> index = new IndexImpl<Node, MultiBunch<Node, Node>>() ;
+    ColumnMap colMap ;
+    Transform<Tuple<Node>, Tuple<Node>> unmap ;
+
+    
+    static Iterator<Tuple<Node>> zero = new NullIterator<Tuple<Node>>() ;
+    
+    public TupleDex(ColumnMap cm){ 
+        this.colMap = cm ;
+        this.unmap = new Transform<Tuple<Node>, Tuple<Node>> () {
+            @Override
+            public Tuple<Node> convert(Tuple<Node> item)
+            {
+                return colMap.unmap(item) ;
+            }} ;
+    }
+    
+    public boolean add(Tuple<Node> tuple)
+    {
+        Node n1 = colMap.fetchSlot(0, tuple) ; 
+        Node n2 = colMap.fetchSlot(1, tuple) ;
+        Node n3 = colMap.fetchSlot(2, tuple) ;
+        
+        MultiBunch<Node, Node> bunch = index.get(n1) ;
+        // XXX Adjust the MultiBunch implementation as it grows.
+        if ( bunch == null )
+        {
+            bunch = new MultiBunchSimple<Node, Node>() ;
+            index.put(n1, bunch) ;
+        }
+        return bunch.add(n2, n3) ;
+        
+    }
+    
+    public boolean remove(Tuple<Node> tuple)
+    {
+        Node n1 = colMap.fetchSlot(0, tuple) ; 
+        Node n2 = colMap.fetchSlot(1, tuple) ;
+        Node n3 = colMap.fetchSlot(2, tuple) ;
+    
+        MultiBunch<Node, Node> bunch = index.get(n1) ;
+        if ( bunch == null )
+            return false ;
+        boolean b = bunch.remove(n2, n3) ;
+        // Could adjust the MultiBunch implementation as it shrinks
+        // but if we are doing a lot of removals (e.g. implicit removeAll), then that makes work 
+        if ( bunch.isEmpty() )
+            index.put(n1, null) ;
+        return b ;
+    }
+
+    public Iterator<Tuple<Node>> find(Tuple<Node> tuple)
+    {
+        tuple = colMap.map(tuple) ;
+        Iterator<Tuple<Node>> iter = find(tuple.get(0), tuple.get(1), tuple.get(2)) ;
+        return Iter.map(iter, unmap) ; 
+    }
+    
+    private Iterator<Tuple<Node>> find(final Node x, final Node y, Node z)
+    {
+        if ( x == null )
+        {
+            // X=? (Maybe Y and Z - 4 cases) 
+            Iterator<Node> iter1 = index.keys() ;
+            IteratorConcat<Tuple<Node>> iter = new IteratorConcat<Tuple<Node>>() ;
+            for ( ; iter1.hasNext() ; )
+            {
+                Node node1 = iter1.next() ;
+                MultiBunch<Node, Node> bunch = index.get(node1) ;
+//                if ( bunch == null )
+//                    continue ;  // ???!!!
+                iter.add(find1(node1, bunch, y, z)) ;
+            }
+            return iter ;
+        }
+        
+        MultiBunch<Node, Node> bunch = index.get(x) ;
+        
+        if ( bunch == null )
+            return zero ;
+
+        if ( y != null )
+        {
+            if ( z != null )
+            {
+                // X Y Z - 1 case
+                if ( bunch.contains(y, z) )
+                    return new SingletonIterator<Tuple<Node>>(Tuple.create(x,y,z)) ;
+                else
+                    return zero ;
+            }
+            // X Y ? - 1 case
+            Iterator<Node> zPart = bunch.iterator(y) ;
+            return find2(x, y, zPart) ;
+        }
+        // y is null.
+        // X ? ? or X ? Z - 2 cases 
+        // Total cases: 8
+        
+        // -----
+        return find1(x, bunch, y, z) ;
+    }
+
+    private Iterator<Tuple<Node>> find1(Node x, MultiBunch<Node, Node> bunch, final Node y, final Node z)
+    {
+//        if ( bunch == null )
+//            return zero ;
+        
+        IteratorConcat<Tuple<Node>> iter = new IteratorConcat<Tuple<Node>>() ;
+        
+        Iterator<Node> iter1 = bunch.keys() ;
+        
+        for ( ; iter1.hasNext() ;  )
+        {
+            Node key = iter1.next() ;
+            Iterator<Node> part3 = bunch.iterator(key) ;
+            Iterator<Tuple<Node>> iter2 = find2(x, key, part3) ;
+            iter.add(iter2) ;
+        }
+        if ( y == null && z == null )
+            return iter ;
+        // Some sort of scan.
+        Filter<Tuple<Node>> filter = new Filter<Tuple<Node>>() {
+            @Override
+            public boolean accept(Tuple<Node> tuple)
+            {
+                if ( y != null && !y.equals(tuple.get(1)) ) return false ;
+                if ( z != null && !z.equals(tuple.get(2)) ) return false ;
+                return true ;
+            }} ;
+        return Iter.filter(iter, filter) ; 
+    }
+    
+    private Iterator<Tuple<Node>> find2(final Node x, final Node y, Iterator<Node> part)
+    {
+        Transform<Node, Tuple<Node>> t = new Transform<Node, Tuple<Node>>(){
+            @Override
+            public Tuple<Node> convert(Node item)
+            {
+                return Tuple.create(x, y, item) ;
+            }} ;
+        Iterator<Tuple<Node>> iter2 = Iter.map(part, t) ;
+        return iter2 ;
+    }
+    
+    private static void checkNotNull(Node x)
+    {
+        if ( x == null ) throw new RuntimeException("Null") ;
+    }
+    private static void checkNull(Node x)
+    {
+        if ( x != null ) throw new RuntimeException("Not null: "+x) ;
+    }
+
+    public int weight(Tuple<Node> tuple)
+    {
+//        System.out.println("Index: "+this) ;
+//        System.out.println("Weight: "+tuple) ;
+//        
+//        System.out.println("  "+colMap.fetchSlot(0, tuple)) ;
+//        System.out.println("  "+colMap.fetchSlot(1, tuple)) ;
+//        System.out.println("  "+colMap.fetchSlot(2, tuple)) ;
+//        System.out.println("Mapped: "+colMap.map(tuple)) ;
+//        
+        if ( undef(colMap.fetchSlot(0, tuple)) ) return 0 ;
+        if ( undef(colMap.fetchSlot(1, tuple)) ) return 1 ;
+        if ( undef(colMap.fetchSlot(2, tuple)) ) return 2 ;
+        return 3 ;
+    }
+    
+    private boolean undef(Object x)
+    { return x == null ; }
+
+    @Override
+    public String toString()
+    {
+        return label() ;
+    }
+    
+    public String label()
+    {
+        return colMap.getLabel() ; 
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/TupleIndex.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/TupleIndex.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/TupleIndex.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src-dev/dev/g2/TupleIndex.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,75 +16,75 @@
  * limitations under the License.
  */
 
-package dev.g2;
-
-import org.openjena.atlas.iterator.IteratorConcat;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-
-import org.openjena.atlas.lib.DS;
-
-public class TupleIndex<T> //extends Index<T, Index<T, Collection<T>>>
-{
-    // Top : Hash of T -> (T, T*) 
-    private Index<T, IndexImpl<T, Collection<T>>> map = new IndexImpl<T, IndexImpl<T, Collection<T>>>() ;
-    
-    public TupleIndex() {}
-    
-    public Index<T, Collection<T>> get(T key1) { return map.get(key1) ; }
-    
-    public Collection<T> get(T key1, T key2) { return map.get(key1).get(key2) ; }
-    
-    public Iterator<T> keys() { return map.keys() ; }
-    
-    public void put(T key1, T key2, T value)
-    { 
-        IndexImpl<T, Collection<T>> x = map.get(key1) ;
-        if ( x == null )
-        {
-            x = new IndexImpl<T, Collection<T>>() ;
-            map.put(key1, x) ;
-        }
-        
-        Collection<T> z = x.get(key2) ;
-        if ( z == null )
-        {
-            z = DS.list() ;
-            x.put(key2, z) ;
-        }
-        z.add(value) ;
-    }
-    
-    public void remove(T key1, T key2)
-    {
-        Index<T, Collection<T>> x = map.get(key1) ;
-        if ( x == null )
-            return ;
-        x.remove(key2) ;
-        if ( x.size() == 0 )
-            map.remove(key1) ;
-    }
-    
-    public Iterator<T> flatten()
-    {
-        // Accumulating iterator.
-        IteratorConcat<T> all = new IteratorConcat<T>() ;
-        for ( Iterator<T> iter = map.keys() ; iter.hasNext() ; )
-        {
-            T k1 = iter.next();
-            Index<T, Collection<T>> x =  map.get(k1) ;
-            for (Iterator<T> iter2 = x.keys() ; iter.hasNext() ; )
-            {
-                T k2 = iter2.next();
-                Collection<T> y = x.get(k2) ;
-                all.add(y.iterator()) ;
-            }
-        }
-        return all ;
-    }
-    
-    public int size() { return map.size() ; }
-    public boolean isEmpty() { return map.isEmpty() ; }
+package dev.g2;
+
+import org.openjena.atlas.iterator.IteratorConcat;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+
+import org.openjena.atlas.lib.DS;
+
+public class TupleIndex<T> //extends Index<T, Index<T, Collection<T>>>
+{
+    // Top : Hash of T -> (T, T*) 
+    private Index<T, IndexImpl<T, Collection<T>>> map = new IndexImpl<T, IndexImpl<T, Collection<T>>>() ;
+    
+    public TupleIndex() {}
+    
+    public Index<T, Collection<T>> get(T key1) { return map.get(key1) ; }
+    
+    public Collection<T> get(T key1, T key2) { return map.get(key1).get(key2) ; }
+    
+    public Iterator<T> keys() { return map.keys() ; }
+    
+    public void put(T key1, T key2, T value)
+    { 
+        IndexImpl<T, Collection<T>> x = map.get(key1) ;
+        if ( x == null )
+        {
+            x = new IndexImpl<T, Collection<T>>() ;
+            map.put(key1, x) ;
+        }
+        
+        Collection<T> z = x.get(key2) ;
+        if ( z == null )
+        {
+            z = DS.list() ;
+            x.put(key2, z) ;
+        }
+        z.add(value) ;
+    }
+    
+    public void remove(T key1, T key2)
+    {
+        Index<T, Collection<T>> x = map.get(key1) ;
+        if ( x == null )
+            return ;
+        x.remove(key2) ;
+        if ( x.size() == 0 )
+            map.remove(key1) ;
+    }
+    
+    public Iterator<T> flatten()
+    {
+        // Accumulating iterator.
+        IteratorConcat<T> all = new IteratorConcat<T>() ;
+        for ( Iterator<T> iter = map.keys() ; iter.hasNext() ; )
+        {
+            T k1 = iter.next();
+            Index<T, Collection<T>> x =  map.get(k1) ;
+            for (Iterator<T> iter2 = x.keys() ; iter.hasNext() ; )
+            {
+                T k2 = iter2.next();
+                Collection<T> y = x.get(k2) ;
+                all.add(y.iterator()) ;
+            }
+        }
+        return all ;
+    }
+    
+    public int size() { return map.size() ; }
+    public boolean isEmpty() { return map.isEmpty() ; }
 }



Mime
View raw message