jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1430447 [10/10] - in /jena/branches/streaming-update: ./ apache-jena/ apache-jena/bat/ apache-jena/bin/ jena-arq/ jena-arq/src/main/java/com/hp/hpl/jena/sparql/graph/ jena-core/ jena-core/src/main/java/com/hp/hpl/jena/assembler/ jena-core/...
Date Tue, 08 Jan 2013 19:07:29 GMT
Modified: jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BulkLoader.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BulkLoader.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BulkLoader.java
(original)
+++ jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BulkLoader.java
Tue Jan  8 19:07:23 2013
@@ -18,14 +18,13 @@
 
 package com.hp.hpl.jena.tdb.store.bulkloader;
 
-import static org.openjena.riot.Lang.NQUADS ;
-import static org.openjena.riot.Lang.NTRIPLES ;
-
 import java.io.InputStream ;
 import java.util.List ;
 
 import org.apache.jena.atlas.event.EventType ;
-import org.openjena.riot.RiotReader ;
+import org.apache.jena.atlas.lib.Tuple ;
+import org.apache.jena.riot.RDFLanguages ;
+import org.apache.jena.riot.RiotReader ;
 import org.slf4j.Logger ;
 
 import com.hp.hpl.jena.graph.Node ;
@@ -33,6 +32,7 @@ import com.hp.hpl.jena.graph.Triple ;
 import com.hp.hpl.jena.sparql.core.Quad ;
 import com.hp.hpl.jena.sparql.util.Utils ;
 import com.hp.hpl.jena.tdb.TDB ;
+import com.hp.hpl.jena.tdb.TDBException ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTupleTable ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTupleTableView ;
 import com.hp.hpl.jena.tdb.solver.stats.Stats ;
@@ -83,102 +83,102 @@ public class BulkLoader
     /** Load into default graph */
     public static void loadDefaultGraph(DatasetGraphTDB dsg, List<String> urls, boolean
showProgress)
     {
-        Destination<Triple> dest = destinationDefaultGraph(dsg, showProgress) ;
+        BulkStreamRDF dest = destinationDefaultGraph(dsg, showProgress) ;
         loadTriples$(dest, urls) ;
     }
 
     /** Load into default graph */
     public static void loadDefaultGraph(DatasetGraphTDB dsg, InputStream input, boolean showProgress)
     {
-        Destination<Triple> dest = destinationDefaultGraph(dsg, showProgress) ;
+        BulkStreamRDF dest = destinationDefaultGraph(dsg, showProgress) ;
         loadTriples$(dest, input) ;
     }
 
-    private static Destination<Triple> destinationDefaultGraph(DatasetGraphTDB dsg,
boolean showProgress)
+    private static BulkStreamRDF destinationDefaultGraph(DatasetGraphTDB dsg, boolean showProgress)
     {
         NodeTupleTable ntt = dsg.getTripleTable().getNodeTupleTable() ;
-        return destination(dsg, ntt, showProgress) ;
+        return destinationGraph(dsg, ntt, showProgress) ;
     }
 
     /** Load into named graph */
     public static void loadNamedGraph(DatasetGraphTDB dsg, Node graphNode, List<String>
urls, boolean showProgress)
     {
-        Destination<Triple> dest = destinationNamedGraph(dsg, graphNode, showProgress)
;
+        BulkStreamRDF dest = destinationNamedGraph(dsg, graphNode, showProgress) ;
         loadTriples$(dest, urls) ;
     }
     
     /** Load into named graph */
     public static void loadNamedGraph(DatasetGraphTDB dsg, Node graphNode, InputStream input,
boolean showProgress)
     {
-        Destination<Triple> dest = destinationNamedGraph(dsg, graphNode, showProgress)
;
+        BulkStreamRDF dest = destinationNamedGraph(dsg, graphNode, showProgress) ;
         loadTriples$(dest, input) ;
     }
 
     /** Load into a dataset */
     public static void loadDataset(DatasetGraphTDB dsg, List<String> urls, boolean
showProgress)
     {
-        Destination<Quad> dest = destinationDataset(dsg, showProgress) ;
+        BulkStreamRDF dest = destinationDataset(dsg, showProgress) ;
         loadQuads$(dest, urls) ;
     }
     
     /** Load into a dataset */
     public static void loadDataset(DatasetGraphTDB dsg, InputStream input, boolean showProgress)
     {
-        Destination<Quad> dest = destinationDataset(dsg, showProgress) ;
+        BulkStreamRDF dest = destinationDataset(dsg, showProgress) ;
         loadQuads$(dest, input) ;
     }
     
 
     /** Load into a graph */
-    private static void loadTriples$(Destination<Triple> dest, List<String> urls)
+    private static void loadTriples$(BulkStreamRDF dest, List<String> urls)
     {
-        dest.start() ;
+        dest.startBulk() ;
         for ( String url : urls )
         {
             loadLogger.info("Load: "+url+" -- "+Utils.nowAsString()) ;
-            RiotReader.parseTriples(url, dest) ;
+            RiotReader.parse(url, dest) ;
         }            
-        dest.finish() ;
+        dest.finishBulk() ;
     }
 
     /** Load into a graph */
-    private static void loadTriples$(Destination<Triple> dest, InputStream input)
+    private static void loadTriples$(BulkStreamRDF dest, InputStream input)
     {
         loadLogger.info("Load: from input stream -- "+Utils.nowAsString()) ;
-        dest.start() ;
-        RiotReader.parseTriples(input, NTRIPLES, null, dest) ;
-        dest.finish() ;
+        dest.startBulk() ;
+        RiotReader.parse(input, RDFLanguages.NTRIPLES, null, dest) ;
+        dest.finishBulk() ;
     }
     
     /** Load quads into a dataset */
-    private static void loadQuads$(Destination<Quad> dest, List<String> urls)
+    private static void loadQuads$(BulkStreamRDF dest, List<String> urls)
     {
-        dest.start() ;
+        dest.startBulk() ;
         for ( String url : urls )
         {
             loadLogger.info("Load: "+url+" -- "+Utils.nowAsString()) ;
-            RiotReader.parseQuads(url, dest) ;
+            RiotReader.parse(url, dest) ;
         }
-        dest.finish() ;
+        dest.finishBulk() ;
     }
 
     /** Load quads into a dataset */
-    private static void loadQuads$(Destination<Quad> dest, InputStream input)
+    private static void loadQuads$(BulkStreamRDF dest, InputStream input)
     {
         loadLogger.info("Load: from input stream -- "+Utils.nowAsString()) ;
-        dest.start() ;
-        RiotReader.parseQuads(input, NQUADS, null, dest) ;
-        dest.finish() ;
+        dest.startBulk() ;
+        RiotReader.parse(input, RDFLanguages.NQUADS, null, dest) ;
+        dest.finishBulk() ;
     }
     
-    private static Destination<Triple> destinationNamedGraph(DatasetGraphTDB dsg, Node
graphName, boolean showProgress)
+    private static BulkStreamRDF destinationNamedGraph(DatasetGraphTDB dsg, Node graphName,
boolean showProgress)
     {
         if ( graphName == null )
             return destinationDefaultGraph(dsg,showProgress) ;
         
         NodeTupleTable ntt = dsg.getQuadTable().getNodeTupleTable() ;
         NodeTupleTable ntt2 = new NodeTupleTableView(ntt, graphName) ;
-        return destination(dsg, ntt2, showProgress) ;
+        return destinationGraph(dsg, ntt2, showProgress) ;
     }
 
     public static LoadMonitor createLoadMonitor(DatasetGraphTDB dsg, String itemName, boolean
showProgress)
@@ -188,141 +188,187 @@ public class BulkLoader
         else
             return new LoadMonitor(dsg, null, itemName, DataTickPoint, IndexTickPoint) ;

     }
+
+    private static BulkStreamRDF destinationDataset(DatasetGraphTDB dsg, boolean showProgress)
+    {
+        return new DestinationDSG(dsg, showProgress) ;
+    }
     
-    private static Destination<Triple> destination(final DatasetGraphTDB dsg, NodeTupleTable
nodeTupleTable, final boolean showProgress)
+    private static BulkStreamRDF destinationGraph(DatasetGraphTDB dsg, NodeTupleTable nodeTupleTable,
boolean showProgress)
+    {
+        return new DestinationGraph(dsg, nodeTupleTable, showProgress) ;
+    }
+
+    // Load triples and quads into a dataset.
+    private static final class DestinationDSG implements BulkStreamRDF
     {
-        LoadMonitor monitor = createLoadMonitor(dsg, "triples", showProgress) ;
-        final LoaderNodeTupleTable loaderTriples = new LoaderNodeTupleTable(nodeTupleTable,
"triples", monitor) ;
+        final private DatasetGraphTDB dsg ; 
+        final private boolean startedEmpty ;
+        final private LoadMonitor monitor1 ; 
+        final private LoadMonitor monitor2 ;
+        final private LoaderNodeTupleTable loaderTriples ;
+        final private LoaderNodeTupleTable loaderQuads ;
+        final private boolean showProgress ;
+        private long count = 0 ;
+        private StatsCollector stats ;
+    
+        DestinationDSG(final DatasetGraphTDB dsg, boolean showProgress)
+        {
+            this.dsg = dsg ;
+            startedEmpty = dsg.isEmpty() ;
+            monitor1 = createLoadMonitor(dsg, "triples", showProgress) ;
+            monitor2 = createLoadMonitor(dsg, "quads", showProgress) ;
+    
+            loaderTriples = new LoaderNodeTupleTable(dsg.getTripleTable().getNodeTupleTable(),
"triples", monitor1) ;
+            loaderQuads = new LoaderNodeTupleTable(dsg.getQuadTable().getNodeTupleTable(),
"quads", monitor2) ;
+            this.showProgress = showProgress ;
+        }
         
-        Destination<Triple> sink = new Destination<Triple>() {
-            long count = 0 ;
-            private StatsCollector stats ;
-            private boolean startedEmpty = dsg.isEmpty() ;
-            
-            @Override
-            final public void start()
-            {
-                loaderTriples.loadStart() ;
-                loaderTriples.loadDataStart() ;
-                
-                this.stats = new StatsCollector() ;
-            }
-            @Override
-            final public void send(Triple triple)
+        @Override
+        final public void startBulk()
+        {
+            loaderTriples.loadStart() ;
+            loaderQuads.loadStart() ;
+    
+            loaderTriples.loadDataStart() ;
+            loaderQuads.loadDataStart() ;
+            this.stats = new StatsCollector() ;
+        }
+    
+        @Override
+        public void triple(Triple triple)
+        {
+            Node s = triple.getSubject() ;
+            Node p = triple.getPredicate() ;
+            Node o = triple.getObject() ;
+            process(Quad.tripleInQuad, s, p, o ) ;
+        }
+    
+        @Override
+        public void quad(Quad quad)
+        {
+            Node s = quad.getSubject() ;
+            Node p = quad.getPredicate() ;
+            Node o = quad.getObject() ;
+            Node g = null ;
+            // Union graph?!
+            if ( ! quad.isTriple() && ! quad.isDefaultGraph() )
+                g = quad.getGraph() ;
+            process(g,s,p,o) ;
+        }
+    
+        private void process(Node g, Node s, Node p, Node o)
+        {
+            if ( g == null ) 
+                loaderTriples.load(s, p, o) ;
+            else
+                loaderQuads.load(g, s, p, o) ;
+            count++ ;
+            stats.record(g, s, p, o) ; 
+        }
+    
+        @Override
+        public void finishBulk()
+        {
+            loaderTriples.loadDataFinish() ;
+            loaderQuads.loadDataFinish() ;
+    
+            loaderTriples.loadIndexStart() ;
+            loaderQuads.loadIndexStart() ;
+    
+            loaderTriples.loadIndexFinish() ;
+            loaderQuads.loadIndexFinish() ;
+    
+            loaderTriples.loadFinish() ;
+            loaderQuads.loadFinish() ;
+            if ( ! dsg.getLocation().isMem() && startedEmpty )
             {
-                Node s = triple.getSubject() ;
-                Node p = triple.getPredicate() ;
-                Node o = triple.getObject() ;
-                
-                loaderTriples.load(s, p, o)  ;
-                stats.record(null, s, p, o) ; 
-                
-                count++ ;
+                String filename = dsg.getLocation().getPath(Names.optStats) ;
+                Stats.write(filename, stats) ;
             }
+            forceSync(dsg) ;
+        }
+    
+        @Override
+        public void start()                     {}
+        @Override
+        public void tuple(Tuple<Node> tuple)    { throw new TDBException("Tuple encountered
while loading a dataset") ; }
+        @Override
+        public void base(String base)           {}
+        @Override
+        public void prefix(String prefix, String iri)   {} // TODO
+        @Override
+        public void finish()                    {}
+    }
+
+    // Load triples into a specific NodeTupleTable
+    private static final class DestinationGraph implements BulkStreamRDF
+    {
+        final private DatasetGraphTDB dsg ;
+        final private LoadMonitor monitor ;
+        final private LoaderNodeTupleTable loaderTriples ;
+        final private boolean startedEmpty ;
+        private long count = 0 ;
+        private StatsCollector stats ;
 
-            @Override
-            final public void flush() { }
-            @Override
-            public void close() { }
+        DestinationGraph(final DatasetGraphTDB dsg, NodeTupleTable nodeTupleTable, boolean
showProgress)
+        {
+            this.dsg = dsg ;
+            startedEmpty = dsg.isEmpty() ;
+            monitor = createLoadMonitor(dsg, "triples", showProgress) ;
+            loaderTriples = new LoaderNodeTupleTable(nodeTupleTable, "triples", monitor)
;
+        }
 
-            @Override
-            final public void finish()
-            {
-                loaderTriples.loadDataFinish() ;
-                loaderTriples.loadIndexStart() ;
-                loaderTriples.loadIndexFinish() ;
-                loaderTriples.loadFinish() ;
-                
-                if ( ! dsg.getLocation().isMem() && startedEmpty )
-                {
-                    String filename = dsg.getLocation().getPath(Names.optStats) ;
-                    Stats.write(filename, stats) ;
-                }
-                
-                forceSync(dsg) ;
-            }
-        } ;
-        return sink ;
-    }
+        @Override
+        final public void startBulk()
+        {
+            loaderTriples.loadStart() ;
+            loaderTriples.loadDataStart() ;
 
-    private static Destination<Quad> destinationDataset(final DatasetGraphTDB dsg,
boolean showProgress)
-    {
-        LoadMonitor monitor1 = createLoadMonitor(dsg, "triples", showProgress) ;
-        LoadMonitor monitor2 = createLoadMonitor(dsg, "quads", showProgress) ;
-        
-        final LoaderNodeTupleTable loaderTriples = new LoaderNodeTupleTable(
-                                                                dsg.getTripleTable().getNodeTupleTable(),
-                                                                "triples",
-                                                                monitor1) ;
-        final LoaderNodeTupleTable loaderQuads = new LoaderNodeTupleTable( 
-                                                                 dsg.getQuadTable().getNodeTupleTable(),
-                                                                 "quads",
-                                                                 monitor2) ;
-        Destination<Quad> sink = new Destination<Quad>() {
-            long count = 0 ;
-            private StatsCollector stats ;
-            private boolean startedEmpty = dsg.isEmpty() ;
-            
-            @Override
-            final public void start()
-            {
-                loaderTriples.loadStart() ;
-                loaderQuads.loadStart() ;
+            this.stats = new StatsCollector() ;
+        }
+        @Override
+        final public void triple(Triple triple)
+        {
+            Node s = triple.getSubject() ;
+            Node p = triple.getPredicate() ;
+            Node o = triple.getObject() ;
+
+            loaderTriples.load(s, p, o)  ;
+            stats.record(null, s, p, o) ; 
+            count++ ;
+        }
 
-                loaderTriples.loadDataStart() ;
-                loaderQuads.loadDataStart() ;
-                this.stats = new StatsCollector() ;
-            }
-            
-            @Override
-            final public void send(Quad quad)
-            {
-                Node s = quad.getSubject() ;
-                Node p = quad.getPredicate() ;
-                Node o = quad.getObject() ;
-                Node g = null ;
-                // Union graph?!
-                if ( ! quad.isTriple() && ! quad.isDefaultGraph() )
-                    g = quad.getGraph() ;
-                
-                if ( g == null ) 
-                    loaderTriples.load(s, p, o) ;
-                else
-                    loaderQuads.load(g, s, p, o) ;
-                count++ ;
-                stats.record(g, s, p, o) ; 
-            }
+        @Override
+        final public void finishBulk()
+        {
+            loaderTriples.loadDataFinish() ;
+            loaderTriples.loadIndexStart() ;
+            loaderTriples.loadIndexFinish() ;
+            loaderTriples.loadFinish() ;
 
-            @Override
-            final public void finish()
+            if ( ! dsg.getLocation().isMem() && startedEmpty )
             {
-                loaderTriples.loadDataFinish() ;
-                loaderQuads.loadDataFinish() ;
-                
-                loaderTriples.loadIndexStart() ;
-                loaderQuads.loadIndexStart() ;
-
-                loaderTriples.loadIndexFinish() ;
-                loaderQuads.loadIndexFinish() ;
-
-                loaderTriples.loadFinish() ;
-                loaderQuads.loadFinish() ;
-                if ( ! dsg.getLocation().isMem() && startedEmpty )
-                {
-                    String filename = dsg.getLocation().getPath(Names.optStats) ;
-                    Stats.write(filename, stats) ;
-                }
-                forceSync(dsg) ;
+                String filename = dsg.getLocation().getPath(Names.optStats) ;
+                Stats.write(filename, stats) ;
             }
-            
-            @Override
-            final public void flush() { }
-            @Override
-            final public void close() { }
-        } ;
-        return sink ;
+            forceSync(dsg) ;
+        }
+
+        @Override
+        public void start()                     {}
+        @Override
+        public void quad(Quad quad)             { throw new TDBException("Quad encountered
while loading a single graph") ; }
+        @Override
+        public void tuple(Tuple<Node> tuple)    { throw new TDBException("Tuple encountered
while loading a single graph") ; }
+        @Override
+        public void base(String base)           { }
+        @Override
+        public void prefix(String prefix, String iri)  { } // TODO
+        @Override
+        public void finish()                    {}
     }
-    
+
     static void forceSync(DatasetGraphTDB dsg)
     {
         // Force sync - we have been bypassing DSG tables.
@@ -331,8 +377,7 @@ public class BulkLoader
         dsg.getQuadTable().getNodeTupleTable().getNodeTable().sync();
         dsg.getQuadTable().getNodeTupleTable().getNodeTable().sync();
         dsg.getPrefixes().getNodeTupleTable().getNodeTable().sync();                
-
-        // This is not enough -- modules whether sync needed.
+        // This is not enough -- modules check whether sync needed.
         dsg.sync() ;
         
     }

Modified: jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdNodeTableBuilder.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdNodeTableBuilder.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdNodeTableBuilder.java
(original)
+++ jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader2/CmdNodeTableBuilder.java
Tue Jan  8 19:07:23 2013
@@ -22,7 +22,6 @@ import static com.hp.hpl.jena.sparql.uti
 
 import java.io.FileNotFoundException ;
 import java.io.FileOutputStream ;
-import java.io.InputStream ;
 import java.io.OutputStream ;
 import java.util.Arrays ;
 import java.util.List ;
@@ -31,11 +30,11 @@ import org.apache.jena.atlas.AtlasExcept
 import org.apache.jena.atlas.io.IO ;
 import org.apache.jena.atlas.lib.FileOps ;
 import org.apache.jena.atlas.lib.Lib ;
-import org.apache.jena.atlas.lib.Sink ;
+import org.apache.jena.atlas.lib.Tuple ;
 import org.apache.jena.atlas.logging.Log ;
-import org.openjena.riot.Lang ;
-import org.openjena.riot.RiotLoader ;
-import org.openjena.riot.system.SinkExtendTriplesToQuads ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFLanguages ;
+import org.apache.jena.riot.RiotReader ;
 import org.slf4j.Logger ;
 import tdb.cmdline.CmdTDB ;
 import arq.cmd.CmdException ;
@@ -47,6 +46,7 @@ import com.hp.hpl.jena.graph.Triple ;
 import com.hp.hpl.jena.sparql.core.Quad ;
 import com.hp.hpl.jena.sparql.util.Utils ;
 import com.hp.hpl.jena.tdb.TDB ;
+import com.hp.hpl.jena.tdb.TDBException ;
 import com.hp.hpl.jena.tdb.base.file.Location ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
 import com.hp.hpl.jena.tdb.nodetable.NodeTupleTable ;
@@ -56,6 +56,7 @@ import com.hp.hpl.jena.tdb.solver.stats.
 import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
 import com.hp.hpl.jena.tdb.store.NodeId ;
 import com.hp.hpl.jena.tdb.store.bulkloader.BulkLoader ;
+import com.hp.hpl.jena.tdb.store.bulkloader.BulkStreamRDF ;
 
 /** Build node table - write triples/quads as text file */
 public class CmdNodeTableBuilder extends CmdGeneral
@@ -119,7 +120,7 @@ public class CmdNodeTableBuilder extends
 
         for( String filename : datafiles)
         {
-            Lang lang = Lang.guess(filename, Lang.NQUADS) ;
+            Lang lang = RDFLanguages.filenameToLang(filename, RDFLanguages.NQUADS) ;
             if ( lang == null )
                 // Does not happen due to default above.
                 cmdError("File suffix not recognized: " +filename) ;
@@ -152,22 +153,15 @@ public class CmdNodeTableBuilder extends
         catch (FileNotFoundException e) { throw new AtlasException(e) ; }
         
         NodeTableBuilder sink = new NodeTableBuilder(dsg, monitor, outputTriples, outputQuads)
; 
-        Sink<Triple> sink2 = new SinkExtendTriplesToQuads(sink) ;
-        
         monitor.start() ;
+        sink.startBulk() ;
         for( String filename : datafiles)
         {
             if ( datafiles.size() > 0 )
                 cmdLog.info("Load: "+filename+" -- "+Utils.nowAsString()) ;
-            
-            InputStream in = IO.openFile(filename) ;
-            Lang lang = Lang.guess(filename, Lang.NQUADS) ;
-            if ( lang.isTriples() )
-                RiotLoader.readTriples(in, lang, null, sink2) ;
-            else
-                RiotLoader.readQuads(in, lang, null, sink) ;
+            RiotReader.parse(filename, sink) ;
         }
-        sink.close() ;
+        sink.finishBulk() ;
         IO.close(outputTriples) ;
         IO.close(outputQuads) ;
         
@@ -187,7 +181,7 @@ public class CmdNodeTableBuilder extends
         cmdLog.info(str) ;
     }
 
-    static class NodeTableBuilder implements Sink<Quad>
+    static class NodeTableBuilder implements BulkStreamRDF
     {
         private DatasetGraphTDB dsg ;
         private NodeTable nodeTable ;
@@ -208,7 +202,36 @@ public class CmdNodeTableBuilder extends
         }
         
         @Override
-        public void send(Quad quad)
+        public void startBulk()
+        {}
+
+        @Override
+        public void start()
+        {}
+
+        @Override
+        public void finish()
+        {}
+
+        @Override
+        public void finishBulk()
+        {
+            writerTriples.flush() ;
+            writerQuads.flush() ;
+            nodeTable.sync() ;
+        }
+            
+        @Override
+        public void triple(Triple triple)
+        {
+            Node s = triple.getSubject() ;
+            Node p = triple.getPredicate() ;
+            Node o = triple.getObject() ;
+            process(Quad.tripleInQuad,s,p,o);
+        }
+
+        @Override
+        public void quad(Quad quad)
         {
             Node s = quad.getSubject() ;
             Node p = quad.getPredicate() ;
@@ -217,7 +240,12 @@ public class CmdNodeTableBuilder extends
             // Union graph?!
             if ( ! quad.isTriple() && ! quad.isDefaultGraph() )
                 g = quad.getGraph() ;
-            
+            process(g,s,p,o);
+        }
+
+       
+        private void process(Node g, Node s, Node p, Node o)
+        {
             NodeId sId = nodeTable.getAllocateNodeId(s) ; 
             NodeId pId = nodeTable.getAllocateNodeId(p) ;
             NodeId oId = nodeTable.getAllocateNodeId(o) ;
@@ -243,19 +271,19 @@ public class CmdNodeTableBuilder extends
             monitor.tick() ;
         }
 
+        public StatsCollectorNodeId getCollector() { return stats ; }
+
         @Override
-        public void flush()
-        {
-            writerTriples.flush() ;
-            writerQuads.flush() ;
-            nodeTable.sync() ;
-        }
+        public void tuple(Tuple<Node> tuple)
+        { throw new TDBException("Unexpected: tuple in bulk load (expected quads or triples)")
; }
 
         @Override
-        public void close()
-        { flush() ; }
-        
-        public StatsCollectorNodeId getCollector() { return stats ; }
+        public void base(String base)
+        {}
+
+        @Override
+        public void prefix(String prefix, String iri)
+        {}
     }
 
     @Override

Modified: jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
(original)
+++ jena/branches/streaming-update/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
Tue Jan  8 19:07:23 2013
@@ -63,6 +63,7 @@ public class TransactionManager
      *  deciding to flush the journal to the main database.  
      */
     // Temporarily public ....
+    // When improved, rename to chase down any systems directly setting it. 
     public static /*final*/ int QueueBatchSize = setQueueBatchSize() ; 
     
     private static int setQueueBatchSize() 

Modified: jena/branches/streaming-update/jena-tdb/src/main/java/tdb/tdbdump.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/main/java/tdb/tdbdump.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/main/java/tdb/tdbdump.java (original)
+++ jena/branches/streaming-update/jena-tdb/src/main/java/tdb/tdbdump.java Tue Jan  8 19:07:23
2013
@@ -18,7 +18,7 @@
 
 package tdb;
 
-import org.openjena.riot.RiotWriter ;
+import org.apache.jena.riot.RiotWriter ;
 import tdb.cmdline.CmdTDB ;
 
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;

Modified: jena/branches/streaming-update/jena-tdb/src/main/java/tdb/tdbloader.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/main/java/tdb/tdbloader.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/main/java/tdb/tdbloader.java (original)
+++ jena/branches/streaming-update/jena-tdb/src/main/java/tdb/tdbloader.java Tue Jan  8 19:07:23
2013
@@ -20,7 +20,8 @@ package tdb;
 
 import java.util.List ;
 
-import org.openjena.riot.Lang ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFLanguages ;
 import tdb.cmdline.CmdTDB ;
 import tdb.cmdline.CmdTDBGraph ;
 import tdb.cmdline.ModModel ;
@@ -103,8 +104,8 @@ public class tdbloader extends CmdTDBGra
         boolean allTriples = true ;
         for ( String url : urls )
         {
-            Lang lang = Lang.guess(url, Lang.NQUADS) ;
-            if ( lang != null && lang.isQuads() )
+            Lang lang = RDFLanguages.filenameToLang(url, RDFLanguages.NQUADS) ;
+            if ( lang != null && RDFLanguages.isQuads(lang) )
             {
                 allTriples = false ;
                 break ; 
@@ -128,11 +129,11 @@ public class tdbloader extends CmdTDBGra
         {
             for ( String url : urls )
             {
-                Lang lang = Lang.guess(url, Lang.NQUADS) ;
+                Lang lang = RDFLanguages.filenameToLang(url, RDFLanguages.NQUADS) ;
                 if ( lang == null )
                     // Does not happen due to default above.
                     cmdError("File suffix not recognized: " +url) ;
-                if ( lang != null && ! lang.isTriples() )
+                if ( lang != null && ! RDFLanguages.isTriples(lang) )
                     cmdError("Can only load triples into a named model: "+url) ;
             }
             cmdError("Internal error: deteched quad input but can't find it again") ;

Modified: jena/branches/streaming-update/jena-tdb/src/main/resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/main/resources/META-INF/NOTICE?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/main/resources/META-INF/NOTICE (original)
+++ jena/branches/streaming-update/jena-tdb/src/main/resources/META-INF/NOTICE Tue Jan  8
19:07:23 2013
@@ -1,5 +1,5 @@
 Apache Jena - module TDB
-Copyright 2011, 2012 The Apache Software Foundation
+Copyright 2011-2013 The Apache Software Foundation
 
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).

Modified: jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/junit/AbstractTestGraphTDB.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/junit/AbstractTestGraphTDB.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/junit/AbstractTestGraphTDB.java
(original)
+++ jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/junit/AbstractTestGraphTDB.java
Tue Jan  8 19:07:23 2013
@@ -20,15 +20,13 @@ package com.hp.hpl.jena.tdb.junit;
 
 import com.hp.hpl.jena.graph.test.AbstractTestGraph;
 
-public class AbstractTestGraphTDB extends AbstractTestGraph
+public abstract class AbstractTestGraphTDB extends AbstractTestGraph
 {
     public AbstractTestGraphTDB(String name)
     {
         super(name) ;
     }
     
-    @Override public void testBulkAddWithReification() {}
-    
     @Override public void testIsomorphismFile() {}
     
     // Meaning less - graphs (and hence models) are not indpenedent of their datasets. 

Modified: jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/nodetable/TestCodec.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/nodetable/TestCodec.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/nodetable/TestCodec.java
(original)
+++ jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/nodetable/TestCodec.java
Tue Jan  8 19:07:23 2013
@@ -55,7 +55,6 @@ public class TestCodec extends BaseTest 
                                         ) ;                                        
     }
 
-
     private Nodec nodec ;
     
     public TestCodec(Nodec nodec) { this.nodec = nodec ; }

Modified: jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestConcurrentAccess.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestConcurrentAccess.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestConcurrentAccess.java
(original)
+++ jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestConcurrentAccess.java
Tue Jan  8 19:07:23 2013
@@ -26,6 +26,7 @@ import org.apache.jena.atlas.lib.StrUtil
 import org.junit.Test ;
 
 import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.graph.GraphUtil ;
 import com.hp.hpl.jena.graph.Triple ;
 import com.hp.hpl.jena.query.Dataset ;
 import com.hp.hpl.jena.query.Query ;
@@ -76,7 +77,7 @@ public class TestConcurrentAccess extend
     {
         Graph g = buildGraph() ;
         Dataset ds = TDBFactory.createDataset() ;
-        ds.getDefaultModel().getGraph().getBulkUpdateHandler().add(g) ;
+        GraphUtil.addInto(ds.getDefaultModel().getGraph(), g) ;
         return ds ;
     }
     
@@ -146,7 +147,7 @@ public class TestConcurrentAccess extend
     {
         Dataset d = TDBFactory.createDataset() ;
         Model m = d.getNamedModel("http://example") ;
-        m.getGraph().getBulkUpdateHandler().add(buildGraph()) ;
+        GraphUtil.addInto(m.getGraph(), buildGraph()) ;
         Resource r = m.createResource("x") ;
         ExtendedIterator<Statement> iter1 = m.listStatements(r, null, (RDFNode)null)
;
         while(iter1.hasNext()) 
@@ -161,7 +162,7 @@ public class TestConcurrentAccess extend
     {
         Dataset d = TDBFactory.createDataset() ;
         Model m = d.getNamedModel("http://example") ;
-        m.getGraph().getBulkUpdateHandler().add(buildGraph()) ;
+        GraphUtil.addInto(m.getGraph(), buildGraph()) ;
         Resource r = m.createResource("x") ;
         ExtendedIterator<Statement> iter1 = m.listStatements(r, null, (RDFNode)null)
;
         assertNotNull(iter1.next()) ;

Modified: jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java
(original)
+++ jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestDatasetTDBPersist.java
Tue Jan  8 19:07:23 2013
@@ -100,7 +100,7 @@ public class TestDatasetTDBPersist exten
         // Sometimes, under windows, deleting the files by 
         // graphLocation.clearDirectory does not work.  
         // Needed for safe tests on windows.
-        g1.getBulkUpdateHandler().removeAll() ;
+        g1.clear() ;
         
         Graph g2 = ds.getNamedModel("http://example/").getGraph() ;
         g2.add(new Triple(n0,n1,n2) ) ;

Modified: jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestGraphTDB.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestGraphTDB.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestGraphTDB.java
(original)
+++ jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestGraphTDB.java
Tue Jan  8 19:07:23 2013
@@ -58,7 +58,7 @@ public class TestGraphTDB extends Abstra
     @Before public void before()
     { 
         try {
-            graph.getBulkUpdateHandler().removeAll() ;
+            graph.clear() ;
         } catch (Exception ex)
         {
             Log.warn(this, "before() : "+ex.getMessage(), ex) ;

Modified: jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java
(original)
+++ jena/branches/streaming-update/jena-tdb/src/test/java/com/hp/hpl/jena/tdb/store/TestNodeId.java
Tue Jan  8 19:07:23 2013
@@ -23,6 +23,7 @@ import org.junit.Test ;
 
 import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
 import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.sparql.expr.NodeValue ;
 import com.hp.hpl.jena.sparql.util.NodeFactory ;
 
 public class TestNodeId extends BaseTest
@@ -69,9 +70,33 @@ public class TestNodeId extends BaseTest
     // More than Long.MAX_VALUE
     { test("92233720368547758070",  (Node)null) ; }
 
+    // On the edge.
+    
+    static long X = 1L<<55 ;        // Just too large 
+    static long Y = -((1L<<55) +1) ;   // Just too small 
+    
     @Test public void nodeId_int_10()
+    { test("\""+Long.toString(X)+"\"^^xsd:integer",  (Node)null) ; }
+
+    @Test public void nodeId_int_11()
+    { 
+        Node n = NodeValue.makeInteger(X-1).asNode() ;
+        test("\""+Long.toString(X-1)+"\"^^xsd:integer",  n) ; 
+    }
+
+    @Test public void nodeId_int_12()
+    { test("\""+Long.toString(Y)+"\"^^xsd:integer",  (Node)null) ; }
+
+    @Test public void nodeId_int_13()
+    { 
+        Node n = NodeValue.makeInteger(Y+1).asNode() ;
+        test("\""+Long.toString(Y+1)+"\"^^xsd:integer",  n) ; 
+    }
+
+    @Test public void nodeId_int_20()
     { test("'300'^^xsd:byte",  (Node)null) ; }
     
+
     @Test public void nodeId_decimal_1()
     { test("3.14", NodeFactory.parseNode("3.14")) ; }
 

Modified: jena/branches/streaming-update/pom.xml
URL: http://svn.apache.org/viewvc/jena/branches/streaming-update/pom.xml?rev=1430447&r1=1430446&r2=1430447&view=diff
==============================================================================
--- jena/branches/streaming-update/pom.xml (original)
+++ jena/branches/streaming-update/pom.xml Tue Jan  8 19:07:23 2013
@@ -23,7 +23,7 @@
   <artifactId>jena</artifactId>
   <packaging>pom</packaging>
   <url>http://jena.apache.org/</url>
-  <version>2.7.5-SNAPSHOT</version>
+  <version>2.10.0-SNAPSHOT</version>
 
   <!-- Needed for -Papache-release -->
   <parent>



Mime
View raw message