You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2011/11/11 15:56:17 UTC

svn commit: r1200909 - in /incubator/jena/Jena2/TDB/trunk: ./ src-examples/ src-examples/tdb/ src-examples/tdb/examples/ src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/

Author: andy
Date: Fri Nov 11 14:56:16 2011
New Revision: 1200909

URL: http://svn.apache.org/viewvc?rev=1200909&view=rev
Log:
Tidy up.

Added:
    incubator/jena/Jena2/TDB/trunk/src-examples/
    incubator/jena/Jena2/TDB/trunk/src-examples/tdb/
    incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/
    incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExQuadFilter.java
    incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB1.java
    incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB2.java
    incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB3.java
    incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB4.java
    incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB5.java
Modified:
    incubator/jena/Jena2/TDB/trunk/.classpath
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesInterleaved.java
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesParallel.java
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesSequential.java
    incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BulkLoader.java

Modified: incubator/jena/Jena2/TDB/trunk/.classpath
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/.classpath?rev=1200909&r1=1200908&r2=1200909&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/.classpath (original)
+++ incubator/jena/Jena2/TDB/trunk/.classpath Fri Nov 11 14:56:16 2011
@@ -3,6 +3,7 @@
   <classpathentry excluding="**/.svn/" kind="src" path="src/main/java"/>
   <classpathentry excluding="**/.svn/" kind="src" path="src/test/java"/>
   <classpathentry excluding="**/.svn/" kind="src" path="src-dev"/>
+  <classpathentry excluding="**/.svn/" kind="src" path="src-examples"/>
   <classpathentry excluding="**/*.java" kind="src" path="resources"/>
   <classpathentry excluding="**/*.java" kind="src" path="resources2"/>
 

Added: incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExQuadFilter.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExQuadFilter.java?rev=1200909&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExQuadFilter.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExQuadFilter.java Fri Nov 11 14:56:16 2011
@@ -0,0 +1,157 @@
+/*
+ * (c) Copyright 2010 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package tdb.examples;
+
+import org.openjena.atlas.iterator.Filter ;
+import org.openjena.atlas.lib.Tuple ;
+
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.Query ;
+import com.hp.hpl.jena.query.QueryExecution ;
+import com.hp.hpl.jena.query.QueryExecutionFactory ;
+import com.hp.hpl.jena.query.QueryFactory ;
+import com.hp.hpl.jena.query.ResultSetFormatter ;
+import com.hp.hpl.jena.sparql.core.Quad ;
+import com.hp.hpl.jena.sparql.sse.SSE ;
+import com.hp.hpl.jena.tdb.TDB ;
+import com.hp.hpl.jena.tdb.TDBFactory ;
+import com.hp.hpl.jena.tdb.nodetable.NodeTable ;
+import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
+import com.hp.hpl.jena.tdb.store.NodeId ;
+import com.hp.hpl.jena.tdb.sys.SystemTDB ;
+
+/** Example of how to filter quads as they are accessed at the lowest level.
+ * Can be used to exclude daat from specific graphs.   
+ * This mechanism is not limited to graphs - it works for properties or anything
+ * where the visibility of otherwise is determined by the elements of the quad. 
+ * See <a href="http://openjena.org/wiki/TDB/QuadFilter">TDB/QuadFilter</a>
+ * for further details.
+ */
+
+public class ExQuadFilter
+{
+    private static String graphToHide = "http://example/g2" ;
+
+    public static void main(String ... args)
+    {
+        // This also works for default union graph ....
+        TDB.getContext().setTrue(TDB.symUnionDefaultGraph) ;
+        
+        Dataset ds = setup() ;
+        Filter<Tuple<NodeId>> filter = createFilter(ds) ;
+        example(ds, filter) ;
+    }
+    
+    /** Example setup - in-memory dataset with two graphs, one triple in each */
+    private static Dataset setup()
+    {
+        Dataset ds = TDBFactory.createDataset() ;
+        DatasetGraphTDB dsg = (DatasetGraphTDB)(ds.asDatasetGraph()) ;
+        Quad q1 = SSE.parseQuad("(<http://example/g1> <http://example/s> <http://example/p> <http://example/o1>)") ;
+        Quad q2 = SSE.parseQuad("(<http://example/g2> <http://example/s> <http://example/p> <http://example/o2>)") ;
+        dsg.add(q1) ;
+        dsg.add(q2) ;
+        return ds ;
+    }
+        
+    /** Create a filter to exclude the graph http://example/g2 */
+    private static Filter<Tuple<NodeId>> createFilter(Dataset ds)
+    {
+        DatasetGraphTDB dsg = (DatasetGraphTDB)(ds.asDatasetGraph()) ;
+        final NodeTable nodeTable = dsg.getQuadTable().getNodeTupleTable().getNodeTable() ;
+        // Filtering operates at a very low level: 
+        // need to know the internal identifier for the graph name. 
+        final NodeId target = nodeTable.getNodeIdForNode(Node.createURI(graphToHide)) ;
+
+        System.out.println("Hide graph: "+graphToHide+" --> "+target) ;
+        
+        // Filter for accept/reject as quad as being visible.
+        // Return true for "accept", false for "reject"
+        Filter<Tuple<NodeId>> filter = new Filter<Tuple<NodeId>>() {
+            @Override
+            public boolean accept(Tuple<NodeId> item)
+            {
+                // Reverse the lookup as a demo
+                //Node n = nodeTable.getNodeForNodeId(target) ;
+                //System.err.println(item) ;
+                if ( item.size() == 4 && item.get(0).equals(target) )
+                {
+                    //System.out.println("Reject: "+item) ;
+                    return false ;
+                }
+                //System.out.println("Accept: "+item) ;
+                return true ;
+            } } ;
+            
+        return filter ;
+    }            
+        
+    private static void example(Dataset ds, Filter<Tuple<NodeId>> filter)
+    {
+        String[] x = {
+            "SELECT * { GRAPH ?g { ?s ?p ?o } }",
+            "SELECT * { ?s ?p ?o }",
+            // THis filter does not hide the graph itself, just the quads associated with the graph.
+            "SELECT * { GRAPH ?g {} }"
+            } ;
+        
+        for ( String qs : x )
+        {
+            example(ds, qs, filter) ;
+            example(ds, qs, null) ;
+        }
+        
+    }
+
+    private static void example(Dataset ds, String qs, Filter<Tuple<NodeId>> filter)
+    {
+        System.out.println() ;
+        Query query = QueryFactory.create(qs) ;
+        System.out.println(qs) ;
+        QueryExecution qExec = QueryExecutionFactory.create(query, ds) ;
+        // Install filter for this query only.
+        if ( filter != null )
+        {
+            System.out.println("Install quad-level filter") ;
+            qExec.getContext().set(SystemTDB.symTupleFilter, filter) ;
+        }
+        else
+            System.out.println("No quad-level filter") ;
+        ResultSetFormatter.out(qExec.execSelect()) ;
+        qExec.close() ;
+
+    }
+        
+}
+
+/*
+ * (c) Copyright 2010 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

Added: incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB1.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB1.java?rev=1200909&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB1.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB1.java Fri Nov 11 14:56:16 2011
@@ -0,0 +1,68 @@
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package tdb.examples;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.rdf.model.Model;
+
+import com.hp.hpl.jena.tdb.TDBFactory;
+
+/** Example of creating a TDB-backed model.
+ *  The preferred way is to create a dataset then get the mode required from the dataset.
+ *  The dataset can be used for SPARQL query and update
+ *  but the Model (or Graph) can also be used.
+ *  
+ *  All the Jena APIs work on the model.
+ *   
+ *  Calling TDBFactory is the only place TDB-specific code is needed.
+ */
+
+public class ExTDB1
+{
+    public static void main(String... argv)
+    {
+        // Direct way: Make a TDB-back Jena model in the named directory.
+        String directory = "MyDatabases/DB1" ;
+        Dataset ds = TDBFactory.createDataset(directory) ;
+        Model model = ds.getDefaultModel() ;
+        
+        // ... do work ...
+        
+        // Close the dataset.
+        ds.close();
+        
+    }
+}
+
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 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

Added: incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB2.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB2.java?rev=1200909&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB2.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB2.java Fri Nov 11 14:56:16 2011
@@ -0,0 +1,60 @@
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package tdb.examples;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.tdb.TDBFactory ;
+
+/**
+ * Using an assembler description (see wiki for details of the assembler format for TDB)
+ * This way, you can change the model being used without changing the code.
+ * The assembler file is a configuration file.
+ * The same assembler description will work as part of a Joseki configuration file. 
+ */
+
+public class ExTDB2
+{
+    public static void main(String... argv)
+    {
+        String assemblerFile = "Store/tdb-assembler.ttl" ;
+
+        Dataset ds = TDBFactory.assembleDataset(assemblerFile) ;
+        
+        // ... do work ...
+        
+        ds.close() ;
+    }
+}
+
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 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

Added: incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB3.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB3.java?rev=1200909&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB3.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB3.java Fri Nov 11 14:56:16 2011
@@ -0,0 +1,86 @@
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package tdb.examples;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Resource;
+
+import com.hp.hpl.jena.util.FileManager;
+
+import com.hp.hpl.jena.assembler.Assembler;
+import com.hp.hpl.jena.shared.JenaException;
+
+import com.hp.hpl.jena.sparql.core.assembler.DatasetAssemblerVocab;
+import com.hp.hpl.jena.sparql.util.TypeNotUniqueException;
+import com.hp.hpl.jena.sparql.util.graph.GraphUtils;
+
+import com.hp.hpl.jena.tdb.assembler.VocabTDB;
+
+/** 
+ * Examples of finding an assembler for a TDB model in a larger collection
+ * of descriptions in a single file.
+ */
+public class ExTDB3
+{
+    public static void main(String... argv)
+    {
+        String assemblerFile = "Store/tdb-assembler.ttl" ;
+        
+        // Find a particular description in the file where there are several: 
+        Model spec = FileManager.get().loadModel(assemblerFile) ;
+
+        // Find the right starting point for the description in some way.
+        Resource root = null ;
+
+        if ( false )
+            // If you know the Resource URI:
+            root = spec.createResource("http://example/myChoiceOfURI" );
+        else
+        {
+            // Alternatively, look for the a single resource of the right type. 
+            try {
+                // Find the required description - the file can contain descriptions of many different types.
+                root = GraphUtils.findRootByType(spec, VocabTDB.tDatasetTDB) ;
+                if ( root == null )
+                    throw new JenaException("Failed to find a suitable root") ;
+            } catch (TypeNotUniqueException ex)
+            { throw new JenaException("Multiple types for: "+DatasetAssemblerVocab.tDataset) ; }
+        }
+
+        Dataset ds = (Dataset)Assembler.general.open(root) ;
+    }
+}
+
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 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

Added: incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB4.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB4.java?rev=1200909&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB4.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB4.java Fri Nov 11 14:56:16 2011
@@ -0,0 +1,77 @@
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package tdb.examples;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.Query ;
+import com.hp.hpl.jena.query.QueryExecution ;
+import com.hp.hpl.jena.query.QueryExecutionFactory ;
+import com.hp.hpl.jena.query.QueryFactory ;
+import com.hp.hpl.jena.query.ResultSet ;
+import com.hp.hpl.jena.query.ResultSetFormatter ;
+import com.hp.hpl.jena.tdb.TDBFactory ;
+
+/** Example of creating a TDB-backed model.
+ *  The preferred way is to create a dataset then get the mode required from the dataset.
+ *  The dataset can be used for SPARQL query and update
+ *  but the Model (or Graph) can also be used.
+ *  
+ *  All the Jena APIs work on the model.
+ *   
+ *  Calling TDBFactory is the only place TDB-specific code is needed.
+ */
+
+public class ExTDB4
+{
+    public static void main(String... argv)
+    {
+        // Direct way: Make a TDB-back Jena model in the named directory.
+        String directory = "MyDatabases/DB1" ;
+        Dataset dataset = TDBFactory.createDataset(directory) ;
+        
+        // Potentially expensive query.
+        String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
+        // See http://www.openjena.org/ARQ/app_api.html
+        
+        Query query = QueryFactory.create(sparqlQueryString) ;
+        QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
+        ResultSet results = qexec.execSelect() ;
+        ResultSetFormatter.out(results) ;
+        qexec.close() ;
+
+        dataset.close();
+    }
+}
+
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 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

Added: incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB5.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB5.java?rev=1200909&view=auto
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB5.java (added)
+++ incubator/jena/Jena2/TDB/trunk/src-examples/tdb/examples/ExTDB5.java Fri Nov 11 14:56:16 2011
@@ -0,0 +1,85 @@
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package tdb.examples;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.Query ;
+import com.hp.hpl.jena.query.QueryExecution ;
+import com.hp.hpl.jena.query.QueryExecutionFactory ;
+import com.hp.hpl.jena.query.QueryFactory ;
+import com.hp.hpl.jena.query.QuerySolution ;
+import com.hp.hpl.jena.query.ResultSet ;
+import com.hp.hpl.jena.tdb.TDBFactory ;
+
+/** Example of creating a TDB-backed model.
+ *  The preferred way is to create a dataset then get the mode required from the dataset.
+ *  The dataset can be used for SPARQL query and update
+ *  but the Model (or Graph) can also be used.
+ *  
+ *  All the Jena APIs work on the model.
+ *   
+ *  Calling TDBFactory is the only place TDB-specific code is needed.
+ */
+
+public class ExTDB5
+{
+    public static void main(String... argv)
+    {
+        // Direct way: Make a TDB-back Jena model in the named directory.
+        String directory = "MyDatabases/DB1" ;
+        Dataset dataset = TDBFactory.createDataset(directory) ;
+        
+        // Potentially expensive query.
+        String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
+        // See http://www.openjena.org/ARQ/app_api.html
+        
+        Query query = QueryFactory.create(sparqlQueryString) ;
+        QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
+        try {
+          ResultSet results = qexec.execSelect() ;
+          for ( ; results.hasNext() ; )
+          {
+              QuerySolution soln = results.nextSolution() ;
+              int count = soln.getLiteral("count").getInt() ;
+              System.out.println("count = "+count) ;
+          }
+        } finally { qexec.close() ; }
+
+        // Close the dataset.
+        dataset.close();
+        
+    }
+}
+
+/*
+ * (c) Copyright 2008, 2009 Hewlett-Packard Development Company, LP
+ * (c) Copyright 2010 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

Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesInterleaved.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesInterleaved.java?rev=1200909&r1=1200908&r2=1200909&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesInterleaved.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesInterleaved.java Fri Nov 11 14:56:16 2011
@@ -21,11 +21,11 @@ package com.hp.hpl.jena.tdb.store.bulklo
 import com.hp.hpl.jena.sparql.util.Timer ;
 import com.hp.hpl.jena.tdb.index.TupleIndex ;
 
-class BuilderSecondaryIndexesInterleaved implements BuilderSecondaryIndexes
+public class BuilderSecondaryIndexesInterleaved implements BuilderSecondaryIndexes
 {
     private LoadMonitor monitor ;
 
-    BuilderSecondaryIndexesInterleaved(LoadMonitor monitor) { this.monitor = monitor ; } 
+    public BuilderSecondaryIndexesInterleaved(LoadMonitor monitor) { this.monitor = monitor ; } 
     
     // Do as one pass over the SPO index, creating both other indexes at the same time.
     // Can be hugely costly in system resources.

Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesParallel.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesParallel.java?rev=1200909&r1=1200908&r2=1200909&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesParallel.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesParallel.java Fri Nov 11 14:56:16 2011
@@ -23,11 +23,11 @@ import java.util.concurrent.Semaphore ;
 import com.hp.hpl.jena.sparql.util.Timer ;
 import com.hp.hpl.jena.tdb.index.TupleIndex ;
 
-class BuilderSecondaryIndexesParallel implements BuilderSecondaryIndexes
+public class BuilderSecondaryIndexesParallel implements BuilderSecondaryIndexes
 {
     private LoadMonitor monitor ;
 
-    BuilderSecondaryIndexesParallel(LoadMonitor monitor) { this.monitor = monitor ; } 
+    public BuilderSecondaryIndexesParallel(LoadMonitor monitor) { this.monitor = monitor ; } 
     
     @Override
     public void createSecondaryIndexes(TupleIndex   primaryIndex ,

Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesSequential.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesSequential.java?rev=1200909&r1=1200908&r2=1200909&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesSequential.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BuilderSecondaryIndexesSequential.java Fri Nov 11 14:56:16 2011
@@ -21,11 +21,11 @@ package com.hp.hpl.jena.tdb.store.bulklo
 import com.hp.hpl.jena.sparql.util.Timer ;
 import com.hp.hpl.jena.tdb.index.TupleIndex ;
 
-class BuilderSecondaryIndexesSequential implements BuilderSecondaryIndexes
+public class BuilderSecondaryIndexesSequential implements BuilderSecondaryIndexes
 {
     private LoadMonitor monitor ;
 
-    BuilderSecondaryIndexesSequential(LoadMonitor monitor) { this.monitor = monitor ; } 
+    public BuilderSecondaryIndexesSequential(LoadMonitor monitor) { this.monitor = monitor ; } 
     
     // Create each secondary indexes, doing one at a time.
     @Override

Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BulkLoader.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BulkLoader.java?rev=1200909&r1=1200908&r2=1200909&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BulkLoader.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/store/bulkloader/BulkLoader.java Fri Nov 11 14:56:16 2011
@@ -181,7 +181,7 @@ public class BulkLoader
         return destination(dsg, ntt2, showProgress) ;
     }
 
-    private static LoadMonitor createLoadMonitor(DatasetGraphTDB dsg, String itemName, boolean showProgress)
+    public static LoadMonitor createLoadMonitor(DatasetGraphTDB dsg, String itemName, boolean showProgress)
     {
         if ( showProgress ) 
             return new LoadMonitor(dsg, loadLogger, itemName, DataTickPoint, IndexTickPoint) ;