jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1134730 - in /incubator/jena/Jena2/TDB/trunk: src-dev/reports/Report_MultipleModelLoads.java src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
Date Sat, 11 Jun 2011 19:28:51 GMT
Author: andy
Date: Sat Jun 11 19:28:51 2011
New Revision: 1134730

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

Added:
    incubator/jena/Jena2/TDB/trunk/src-dev/reports/Report_MultipleModelLoads.java   (with
props)
Modified:
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java

Added: incubator/jena/Jena2/TDB/trunk/src-dev/reports/Report_MultipleModelLoads.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src-dev/reports/Report_MultipleModelLoads.java?rev=1134730&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src-dev/reports/Report_MultipleModelLoads.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src-dev/reports/Report_MultipleModelLoads.java Sat Jun
11 19:28:51 2011
@@ -0,0 +1,74 @@
+/*
+ * (c) Copyright 2011 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package reports;
+
+import java.io.File ;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.rdf.model.Model ;
+import com.hp.hpl.jena.tdb.TDB ;
+import com.hp.hpl.jena.tdb.TDBFactory ;
+import com.hp.hpl.jena.util.FileManager ;
+
+public class Report_MultipleModelLoads
+{
+    static String $db = "DB" ;
+    static String input = "tmp/" ;
+    
+    public static void main(String[] args) {
+        // Create a new dataset 
+        Dataset ds = TDBFactory.createDataset() ; // ($db) ;
+        Model model = ds.getDefaultModel();
+        if ( !model.isEmpty() ) 
+            model.removeAll();
+        // Load content from input directory
+        File directory = new File(input);
+        String[] files = directory.list();
+        if ( files == null )
+            System.out.println("The directory doesn't exist!");
+        else if ( files.length == 0 ) 
+            System.out.println("The directory is empty.");
+        else {
+            for (int i = 0, j = files.length; i < j; i++ ) {
+                System.out.println( files[i] + " is being processed.");
+                // Bug is when a prefix is changed. 
+                FileManager.get().readModel( model, input + files[i]);
+                TDB.sync(ds) ;
+            }
+        }
+        // Close the different models
+        model.close();
+        ds.close();
+    }
+}
+
+/*
+ * (c) Copyright 2011 Epimorphics Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
\ No newline at end of file

Propchange: incubator/jena/Jena2/TDB/trunk/src-dev/reports/Report_MultipleModelLoads.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java?rev=1134730&r1=1134729&r2=1134730&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
(original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/DatasetPrefixesTDB.java
Sat Jun 11 19:28:51 2011
@@ -10,6 +10,7 @@ package com.hp.hpl.jena.tdb.store;
 import java.util.HashMap ;
 import java.util.HashSet ;
 import java.util.Iterator ;
+import java.util.List ;
 import java.util.Map ;
 import java.util.Set ;
 
@@ -184,9 +185,10 @@ public class DatasetPrefixesTDB implemen
         Node g = Node.createURI(graphName) ; 
         Node p = Node.createLiteral(prefix) ; 
         Iterator<Tuple<Node>> iter = nodeTupleTable.find(g, p, null) ;
-        while ( iter.hasNext() )
-            nodeTupleTable.deleteRow(g, p, iter.next().get(2)) ;
+        List<Tuple<Node>> list = Iter.toList(iter) ;    // Materialize.
         Iter.close(iter) ;
+        for ( Tuple<Node> tuple : list )
+            nodeTupleTable.deleteRow(g, p, tuple.get(2)) ;
     }
 
     public NodeTupleTable getNodeTupleTable()  { return nodeTupleTable ; }



Mime
View raw message