jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1142477 - in /incubator/jena: Experimental/TxTDB/trunk/src-dev/tx/TxMain.java Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/recordbuffer/RecordRangeIterator.java Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB7.java
Date Sun, 03 Jul 2011 18:46:51 GMT
Author: andy
Date: Sun Jul  3 18:46:50 2011
New Revision: 1142477

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

Added:
    incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB7.java   (with props)
Modified:
    incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java
    incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/recordbuffer/RecordRangeIterator.java

Modified: incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java?rev=1142477&r1=1142476&r2=1142477&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java (original)
+++ incubator/jena/Experimental/TxTDB/trunk/src-dev/tx/TxMain.java Sun Jul  3 18:46:50 2011
@@ -85,8 +85,8 @@ public class TxMain
         // next: write block id to Journal 
         // Next: API, transactions, and rollback.
         
-        if ( true ) 
-            SystemTDB.setFileMode(FileMode.direct) ;
+        SystemTDB.setFileMode(FileMode.direct) ;
+        //SystemTDB.setFileMode(FileMode.mapped) ;
         
         initFS() ;
         
@@ -106,7 +106,7 @@ public class TxMain
         DatasetGraphTDB dsg0 = build() ;
         dsg0.sync() ;
         query("SELECT (Count(*) AS ?c) { ?s ?p ?o }", dsg0) ;
-        exit(0) ;
+        //exit(0) ;
         
         TransactionManager txnMgr = new TransactionManager() ;
         

Modified: incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/recordbuffer/RecordRangeIterator.java
URL: http://svn.apache.org/viewvc/incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/recordbuffer/RecordRangeIterator.java?rev=1142477&r1=1142476&r2=1142477&view=diff
==============================================================================
--- incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/recordbuffer/RecordRangeIterator.java
(original)
+++ incubator/jena/Experimental/TxTDB/trunk/src/main/java/com/hp/hpl/jena/tdb/base/recordbuffer/RecordRangeIterator.java
Sun Jul  3 18:46:50 2011
@@ -12,10 +12,10 @@ import static org.openjena.atlas.lib.Alg
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
-import org.openjena.atlas.iterator.Iter ;
 import org.openjena.atlas.lib.Closeable ;
 
 import com.hp.hpl.jena.tdb.base.StorageException ;
+import com.hp.hpl.jena.tdb.base.block.BlockException ;
 import com.hp.hpl.jena.tdb.base.record.Record;
 
 final public
@@ -25,7 +25,7 @@ class RecordRangeIterator implements Ite
     public static Iterator<Record> iterator(int pageId, Record fromRec, Record toRec,
RecordBufferPageMgr pageMgr)
     {
         if ( ! pageMgr.valid(pageId) )
-            return Iter.nullIterator() ;
+            throw new BlockException("No such block") ;
         return new RecordRangeIterator(pageId, fromRec, toRec, pageMgr) ;
     }
 

Added: incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB7.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB7.java?rev=1142477&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB7.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB7.java Sun Jul  3 18:46:50
2011
@@ -0,0 +1,143 @@
+/**
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tdb.examples;
+
+import java.util.Iterator;
+
+import com.hp.hpl.jena.graph.Graph;
+import com.hp.hpl.jena.iri.IRIFactory;
+import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.query.QueryExecution;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.Statement;
+import com.hp.hpl.jena.tdb.TDBFactory;
+import com.hp.hpl.jena.tdb.sys.SetupTDB;
+
+import static java.lang.System.out;
+
+public class ExTDB7
+{
+    /// observe the non-http "protocol", because it is a bad precident
+    /// to only use http IRI when there is no http protocol involved
+    public static final String MY_NS =
+        "x-ns://example.org/ns1/";
+
+    public static void main(String[] args) throws Exception {
+        /// turn off the "No BGP optimizer warning"
+        SetupTDB.setOptimizerWarningFlag(false);
+
+        final IRIFactory iriFactory = IRIFactory.semanticWebImplementation();
+
+        final String DATASET_DIR_NAME = "data0";
+        final Dataset data0 = TDBFactory.createDataset( DATASET_DIR_NAME );
+
+        // show the currently registered names
+        for (Iterator<String> it = data0.listNames(); it.hasNext(); ) {
+            out.println("NAME="+it.next());
+        }
+
+        out.println("getting named model...");
+        /// this is the OWL portion
+        final Model model = data0.getNamedModel( MY_NS );
+        out.println("Model := "+model);
+
+        out.println("getting graph...");
+        /// this is the DATA in that MODEL
+        final Graph graph = model.getGraph();
+        out.println("Graph := "+graph);
+
+        if (graph.isEmpty()) {
+            final Resource product1 = model.createResource(
+                                                           iriFactory.construct( MY_NS +"product/1"
)
+                                                           .toString() );
+
+            final Property hasName = model.createProperty( MY_NS, "#hasName");
+            final Statement stmt = model.createStatement(
+                                                         product1, hasName, model.createLiteral("Beach
Ball","en") );
+            out.println("Statement = " + stmt);
+
+            model.add(stmt);
+
+            // just for fun
+            out.println("Triple := " + stmt.asTriple().toString());
+        } else {
+            out.println("Graph is not Empty; it has "+graph.size()+" Statements");
+            long t0, t1;
+            t0 = System.currentTimeMillis();
+            final Query q = QueryFactory.create(
+                                                "PREFIX exns: <"+MY_NS+"#>\n"+
+                                                "PREFIX exprod: <"+MY_NS+"product/>\n"+
+                                                " SELECT * "
+                                                // if you don't provide the Model to the
+                                                // QueryExecutionFactory below, then you'll
need
+                                                // to specify the FROM;
+                                                // you *can* always specify it, if you want
+                                                // +" FROM <"+MY_NS+">\n"
+                                                // +" WHERE { ?node <"+MY_NS+"#hasName>
?name }"
+                                                // +" WHERE { ?node exns:hasName ?name }"
+                                                // +" WHERE { exprod:1 exns:hasName ?name
}"
+                                                +" WHERE { ?res ?pred ?obj }"
+            );
+            out.println("Query := "+q);
+            t1 = System.currentTimeMillis();
+            out.println("QueryFactory.TIME="+(t1 - t0));
+
+            t0 = System.currentTimeMillis();
+            final QueryExecution qExec = QueryExecutionFactory
+            // if you query the whole DataSet,
+            // you have to provide a FROM in the SparQL
+            //.create(q, data0);
+            .create(q, model);
+            t1 = System.currentTimeMillis();
+            out.println("QueryExecutionFactory.TIME="+(t1 - t0));
+
+            try {
+                t0 = System.currentTimeMillis();
+                ResultSet rs = qExec.execSelect();
+                t1 = System.currentTimeMillis();
+                out.println("executeSelect.TIME="+(t1 - t0));
+                while (rs.hasNext()) {
+                    QuerySolution sol = rs.next();
+                    out.println("Solution := "+sol);
+                    for (Iterator<String> names = sol.varNames(); names.hasNext();
) {
+                        final String name = names.next();
+                        out.println("\t"+name+" := "+sol.get(name));
+                    }
+                }
+            } finally {
+                qExec.close();
+            }
+        }
+        out.println("closing graph");
+        graph.close();
+        out.println("closing model");
+        model.close();
+        //out.println("closing DataSetGraph");
+        //dsg.close();
+        out.println("closing DataSet");
+        data0.close();
+    }
+}

Propchange: incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB7.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message