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/06/19 20:23:00 UTC

svn commit: r1137400 - in /incubator/jena/Scratch/AFS/trunk: .classpath src-dev/dev/SizeIndexes.java src-lib/structure/radix/RadixIndex.java src-lib/structure/radix/RadixTree.java

Author: andy
Date: Sun Jun 19 18:23:00 2011
New Revision: 1137400

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

Added:
    incubator/jena/Scratch/AFS/trunk/src-dev/dev/SizeIndexes.java   (with props)
Modified:
    incubator/jena/Scratch/AFS/trunk/.classpath
    incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixIndex.java
    incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixTree.java

Modified: incubator/jena/Scratch/AFS/trunk/.classpath
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/trunk/.classpath?rev=1137400&r1=1137399&r2=1137400&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/trunk/.classpath (original)
+++ incubator/jena/Scratch/AFS/trunk/.classpath Sun Jun 19 18:23:00 2011
@@ -20,6 +20,6 @@
 	<classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.7.1/xercesImpl-2.7.1.jar"/>
 	<classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4.jar" sourcepath="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4-sources.jar"/>
 	<classpathentry kind="lib" path="/ARQ/classes" sourcepath="/ARQ/src"/>
-	<classpathentry kind="lib" path="/TDB/classes"/>
+	<classpathentry kind="lib" path="/TxTDB/classes"/>
 	<classpathentry kind="output" path="classes"/>
 </classpath>

Added: incubator/jena/Scratch/AFS/trunk/src-dev/dev/SizeIndexes.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/trunk/src-dev/dev/SizeIndexes.java?rev=1137400&view=auto
==============================================================================
--- incubator/jena/Scratch/AFS/trunk/src-dev/dev/SizeIndexes.java (added)
+++ incubator/jena/Scratch/AFS/trunk/src-dev/dev/SizeIndexes.java Sun Jun 19 18:23:00 2011
@@ -0,0 +1,109 @@
+/*
+ * (c) Copyright 2011 Epimorphics Ltd.
+ * All rights reserved.
+ * [See end of file]
+ */
+
+package dev;
+
+import java.io.InputStream ;
+import java.util.Iterator ;
+
+import org.openjena.atlas.io.IO ;
+import org.openjena.atlas.lib.ColumnMap ;
+import org.openjena.atlas.logging.Log ;
+import structure.radix.RadixIndex ;
+import structure.radix.RadixTree ;
+
+import com.hp.hpl.jena.tdb.base.record.Record ;
+import com.hp.hpl.jena.tdb.base.record.RecordFactory ;
+import com.hp.hpl.jena.tdb.index.RangeIndex ;
+import com.hp.hpl.jena.tdb.index.bplustree.BPlusTree ;
+import com.hp.hpl.jena.tdb.store.bulkloader2.RecordsFromInput ;
+
+public class SizeIndexes
+{
+    public static void exit(int code)
+    {
+        System.out.println("DONE") ;
+        System.exit(code) ;
+    }
+
+    public static void main(String ... args) throws Exception
+    {
+        Log.setLog4j() ;
+        Log.enable(RadixTree.class) ;
+        
+        // create index
+        long count = 0 ;
+        InputStream input = IO.openFile("data") ;
+        RecordsFromInput stream = new RecordsFromInput(input, 3, new ColumnMap("SPO", "SPO"), 2000) ;
+        RecordFactory rf = new RecordFactory(24,0) ;
+        System.gc() ;
+        long startMem = mem() ;
+        
+        boolean useRadix = true ;
+        RangeIndex index ;
+        if ( ! useRadix )
+            index = BPlusTree.makeMem(200, 200, 24, 0) ;
+        else
+            index = new RadixIndex(rf) ;
+        
+        for ( ; stream.hasNext() ; )
+        {
+            count++ ;
+            Record r = stream.next() ;
+            if ( useRadix )
+                System.out.println("Add: "+r) ;
+            index.add(r) ;
+            if ( useRadix )
+            {
+                System.out.println();
+                ((RadixIndex)index).radix.print() ;
+                Iterator<Record> iter = index.iterator() ;
+                for ( ; iter.hasNext() ; )
+                    System.out.println(iter.next()) ;
+            }
+        }
+
+        // Release. reload. Recording memory.
+        
+        
+        System.gc() ;
+        long finishMem = mem() ;
+        System.out.printf("%d records : %,.2fK memory\n", count, (finishMem-startMem)/1000.0 ) ;
+    }
+
+    // Return the amount of memory in-use
+    private static long mem()
+    {
+        return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
+    }
+}
+
+/*
+ * (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/Scratch/AFS/trunk/src-dev/dev/SizeIndexes.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixIndex.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixIndex.java?rev=1137400&r1=1137399&r2=1137400&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixIndex.java (original)
+++ incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixIndex.java Sun Jun 19 18:23:00 2011
@@ -99,12 +99,6 @@ public class RadixIndex implements Range
     }
 
     @Override
-    public long sessionTripleCount()
-    {
-        return 0 ;
-    }
-
-    @Override
     public void sync()
     {}
 

Modified: incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixTree.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixTree.java?rev=1137400&r1=1137399&r2=1137400&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixTree.java (original)
+++ incubator/jena/Scratch/AFS/trunk/src-lib/structure/radix/RadixTree.java Sun Jun 19 18:23:00 2011
@@ -648,7 +648,7 @@ public final class RadixTree
             // Now move until leaf.
             while(!node.isLeaf())
             {
-                // Copy as we got.
+                // Copy as we go.
                 slot = appendBytes(node.prefix, 0, node.prefix.length, slot) ;
                 node = node.nodes.get(0) ;
             }
@@ -667,10 +667,19 @@ public final class RadixTree
             {
                 ByteBuffer bb2 = ByteBuffer.allocate(bb.capacity()*2 ) ;
                 System.arraycopy(bb.array(), 0, bb2.array(), 0, bb.position()) ;
+                return bb2 ;
             }
 //            System.arraycopy(bb.array(), bb.position(), array, 0, length) ;
 //            bb.position((bb.position()+length)) ;
+            try {
             bb.put(array, start, length) ;
+            } catch (java.nio.BufferOverflowException ex)
+            {
+                System.err.println() ;
+                System.err.println(bb) ;
+                System.err.printf("([%d], %d, %d)", array.length, start, length) ;
+                throw ex ;
+            }
             return bb ;
         }