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 2012/06/07 17:20:24 UTC
svn commit: r1347670 - in /jena/Scratch/AFS/Jena-Dev/trunk: .classpath
src/dev/Jena250_Explore.java
Author: andy
Date: Thu Jun 7 15:20:23 2012
New Revision: 1347670
URL: http://svn.apache.org/viewvc?rev=1347670&view=rev
Log: (empty)
Added:
jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena250_Explore.java
Modified:
jena/Scratch/AFS/Jena-Dev/trunk/.classpath
Modified: jena/Scratch/AFS/Jena-Dev/trunk/.classpath
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Jena-Dev/trunk/.classpath?rev=1347670&r1=1347669&r2=1347670&view=diff
==============================================================================
--- jena/Scratch/AFS/Jena-Dev/trunk/.classpath (original)
+++ jena/Scratch/AFS/Jena-Dev/trunk/.classpath Thu Jun 7 15:20:23 2012
@@ -17,6 +17,6 @@
<classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.10.0/xercesImpl-2.10.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry combineaccessrules="false" kind="src" path="/jena-arq"/>
- <classpathentry kind="lib" path="/jena-tdb/classes"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jena-tdb"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Added: jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena250_Explore.java
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena250_Explore.java?rev=1347670&view=auto
==============================================================================
--- jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena250_Explore.java (added)
+++ jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena250_Explore.java Thu Jun 7 15:20:23 2012
@@ -0,0 +1,158 @@
+/* See JENA-250 */
+package dev ;
+
+import static com.hp.hpl.jena.query.ReadWrite.READ ;
+import static com.hp.hpl.jena.query.ReadWrite.WRITE ;
+
+import java.io.File ;
+import java.io.IOException ;
+import java.io.InputStream ;
+
+import org.openjena.atlas.io.IO ;
+import org.openjena.atlas.lib.FileOps ;
+
+import com.hp.hpl.jena.query.* ;
+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.tdb.StoreConnection ;
+import com.hp.hpl.jena.tdb.TDBFactory ;
+import com.hp.hpl.jena.tdb.base.file.Location ;
+import com.hp.hpl.jena.tdb.sys.SystemTDB ;
+
+public class Jena250_Explore {
+
+ /* 1 - Sync'ing the DSG does not help if block are written directly
+ * (the DSG has seen no change -> syncNeeded flags are false )
+ * 2 - direct mode is a stack of FreeChain and Chache BlockMgrs
+ * Need to ensure sync gets to the real file.
+ * See BlockMgrCache.syncFlush.
+ * 3 - Block writing in journal reply is done with blkMgr.overwrite which is write-through.
+ * But is the file sync'ed?
+ *
+ *
+ * Other:
+ * A - check NodeTableTrans -- seems to write to B+Trees early
+ */
+
+ final static String DIR = "DB" ;
+
+ public static void main(String[] args) {
+ System.out.println("Starting TestStoreRelease");
+
+ // Not seen in mapped mode.
+ ARQ.getContext().set(SystemTDB.symFileMode, "direct");
+ if (!SystemTDB.fileMode().toString().equals("direct")) {
+ throw new RuntimeException("file mode is not direct, but " + SystemTDB.fileMode()); //$NON-NLS-1$
+ }
+ System.out.println("File mode = "+SystemTDB.fileMode().toString()) ;
+
+ boolean clearout = true ;
+
+ if ( clearout )
+ {
+ // Clear it out.
+ if ( FileOps.exists(DIR) )
+ {
+ FileOps.clearDirectory(DIR) ;
+ new File(DIR).delete() ;
+ }
+ }
+
+ //String absoluteLocationStr = new File(locationStr).getAbsolutePath();
+ //System.out.println("Testing on store located at " + absoluteLocationStr);
+
+ Location location = new Location(DIR);
+
+ Jena250_Explore.oneCycle(location);
+ //System.exit(0) ;
+ StoreConnection.release(location);
+
+ Jena250_Explore.oneCycle(location);
+ //StoreConnection.release(location);
+
+ Jena250_Explore.oneCycle(location);
+ //StoreConnection.release(location);
+ }
+
+ public static void oneCycle(Location location) {
+ //listFiles(DIR) ;
+ Dataset ds = TDBFactory.createDataset(location);
+ //listFiles(DIR) ;
+ addTriple(ds) ;
+ countAndPrint(ds) ;
+ System.out.println("Release") ;
+ //listFiles(DIR) ;
+ System.out.println() ;
+ }
+
+ private static void addTriple(Dataset ds)
+ {
+ ds.begin(WRITE) ;
+ Model model = ds.getDefaultModel() ;
+
+ Resource subject = model.createResource("http://example/s");
+ Property predicate = model.createProperty("http://example/p");
+ model.add(subject, predicate, ""+System.currentTimeMillis());
+
+ countInnerPrint(ds) ;
+ ds.commit() ;
+ ds.end() ;
+ }
+
+ private static void listFiles(String pattern)
+ {
+ System.out.println("List files: "+pattern) ;
+ if ( pattern == null )
+ pattern = "" ;
+ try
+ {
+ Process proc = Runtime.getRuntime().exec("./dwim "+pattern) ;
+ InputStream in = proc.getInputStream() ;
+ String x = IO.readWholeFileAsUTF8(in) ;
+ System.out.print(x) ;
+ System.out.flush() ;
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private static void countAndPrint(Dataset ds)
+ {
+ long x = count(ds) ;
+ System.out.println("Count = "+x) ;
+ }
+
+ private static long count(Dataset ds)
+ {
+ ds.begin(READ) ;
+ try {
+ return countInner(ds) ;
+ }
+ finally {ds.commit(); ds.end() ; }
+ }
+
+
+ private static void countInnerPrint(Dataset ds)
+ {
+ long x = countInner(ds) ;
+ System.out.println("Inner count = "+x) ;
+ }
+
+ private static long countInner(Dataset ds)
+ {
+ String queryStr = "SELECT (COUNT(?s) as ?c) { ?s ?p ?o . }" ;
+
+ QueryExecution qe = QueryExecutionFactory.create(queryStr, ds) ;
+ ResultSet rs = qe.execSelect();
+ try {
+ if (rs.hasNext()) {
+ int x = rs.next().get("c").asLiteral().getInt();
+ ResultSetFormatter.consume(rs) ;
+ return x ;
+ }
+ } finally { qe.close() ; }
+ return -1 ;
+ }
+}