activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r828268 - in /activemq/sandbox/activemq-apollo: activemq-util/src/main/java/org/apache/activemq/util/ activemq-util/src/main/java/org/apache/activemq/util/list/ activemq-util/src/main/java/org/apache/activemq/util/marshaller/ hawtdb/src/mai...
Date Thu, 22 Oct 2009 01:18:17 GMT
Author: chirino
Date: Thu Oct 22 01:18:16 2009
New Revision: 828268

URL: http://svn.apache.org/viewvc?rev=828268&view=rev
Log:
working on getting the deffered encoding working.

Modified:
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/Hasher.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/list/SequenceSet.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/BytesMarshaller.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/FixedBufferMarshaller.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/IntegerMarshaller.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/LongMarshaller.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/Marshaller.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/ObjectMarshaller.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/StringMarshaller.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/VariableBufferMarshaller.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Extent.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java
    activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtTransaction.java
    activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java
    activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java
    activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java
    activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java
    activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashBin.java
    activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashIndex.java

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/Hasher.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/Hasher.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/Hasher.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/Hasher.java Thu Oct 22 01:18:16 2009
@@ -361,6 +361,10 @@
         public Object readPayload(DataInput dataInput) throws IOException {
             throw new UnsupportedOperationException();
         }
+
+        public int estimatedSize(Object object) {
+            return object.toString().length();
+        }
     }
 
     /**

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/list/SequenceSet.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/list/SequenceSet.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/list/SequenceSet.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/list/SequenceSet.java Thu Oct 22 01:18:16 2009
@@ -86,6 +86,10 @@
         public boolean isDeepCopySupported() {
             return true;
         }
+
+        public int estimatedSize(SequenceSet object) {
+            return object.size()*16;
+        }
     }
     
     public void add(Sequence value) {

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/BytesMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/BytesMarshaller.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/BytesMarshaller.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/BytesMarshaller.java Thu Oct 22 01:18:16 2009
@@ -51,4 +51,8 @@
     public boolean isDeepCopySupported() {
         return true;
     }
+
+    public int estimatedSize(byte[] object) {
+        return object.length+4;
+    }
 }

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/FixedBufferMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/FixedBufferMarshaller.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/FixedBufferMarshaller.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/FixedBufferMarshaller.java Thu Oct 22 01:18:16 2009
@@ -33,16 +33,13 @@
 
     public FixedBufferMarshaller(int size) {
         this.size = size;
-        
     }
 
     public void writePayload(Buffer value, DataOutput dataOut) throws IOException {
-        dataOut.writeInt(value.length);
-        dataOut.write(value.data, value.offset, value.length);
+        dataOut.write(value.data, value.offset, size);
     }
 
     public Buffer readPayload(DataInput dataIn) throws IOException {
-        int size = dataIn.readInt();
         byte[] data = new byte[size];
         dataIn.readFully(data);
         return new Buffer(data);
@@ -59,5 +56,9 @@
     public boolean isDeepCopySupported() {
         return true;
     }
+
+    public int estimatedSize(Buffer object) {
+        return size;
+    }
     
 }

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/IntegerMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/IntegerMarshaller.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/IntegerMarshaller.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/IntegerMarshaller.java Thu Oct 22 01:18:16 2009
@@ -51,4 +51,8 @@
     public boolean isDeepCopySupported() {
         return true;
     }
+
+    public int estimatedSize(Integer object) {
+        return 4;
+    }
 }

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/LongMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/LongMarshaller.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/LongMarshaller.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/LongMarshaller.java Thu Oct 22 01:18:16 2009
@@ -47,4 +47,8 @@
     public boolean isDeepCopySupported() {
         return true;
     }
+
+    public int estimatedSize(Long object) {
+        return 8;
+    }
 }

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/Marshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/Marshaller.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/Marshaller.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/Marshaller.java Thu Oct 22 01:18:16 2009
@@ -49,6 +49,12 @@
     int getFixedSize();
     
     /**
+     * @param object
+     * @return the estimated marshaled size of the object.
+     */
+    int estimatedSize(T object);
+    
+    /**
      * 
      * @return true if the {@link #deepCopy(Object)} operations is supported.
      */

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/ObjectMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/ObjectMarshaller.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/ObjectMarshaller.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/ObjectMarshaller.java Thu Oct 22 01:18:16 2009
@@ -30,6 +30,16 @@
  */
 public class ObjectMarshaller extends VariableMarshaller<Object> {
 
+    private int estimatedSize;
+
+    public int getEstimatedSize() {
+        return estimatedSize;
+    }
+
+    public void setEstimatedSize(int estimatedSize) {
+        this.estimatedSize = estimatedSize;
+    }
+
     public void writePayload(Object object, DataOutput dataOut) throws IOException {
         ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
         ObjectOutputStream objectOut = new ObjectOutputStream(bytesOut);
@@ -52,5 +62,9 @@
             throw new IOException(e.getMessage());
         }
     }
+
+    public int estimatedSize(Object object) {
+        return estimatedSize;
+    }
     
 }

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/StringMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/StringMarshaller.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/StringMarshaller.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/StringMarshaller.java Thu Oct 22 01:18:16 2009
@@ -62,4 +62,8 @@
     public boolean isDeepCopySupported() {
         return true;
     }
+
+    public int estimatedSize(String object) {
+        return object.length()+2;
+    }
 }

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/VariableBufferMarshaller.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/VariableBufferMarshaller.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/VariableBufferMarshaller.java (original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/marshaller/VariableBufferMarshaller.java Thu Oct 22 01:18:16 2009
@@ -48,5 +48,9 @@
     public boolean isDeepCopySupported() {
         return true;
     }
+
+    public int estimatedSize(Buffer object) {
+        return object.length+4;
+    }
     
 }

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/api/BTreeIndexFactory.java Thu Oct 22 01:18:16 2009
@@ -57,6 +57,11 @@
         return index;
     }
     
+    @Override
+    public String toString() {
+        return "{ deferredEncoding: "+deferredEncoding+" }";
+    }
+    
     public Index<Key, Value> open(Paged paged, int page) {
         return createInstance(paged, page);
     }

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIndex.java Thu Oct 22 01:18:16 2009
@@ -20,6 +20,7 @@
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.activemq.util.buffer.Buffer;
@@ -44,7 +45,7 @@
  */
 public class BTreeIndex<Key, Value> implements Index<Key, Value> {
 
-    private final BTreeNode.BTreeNodeEncoderDecoder<Key, Value> PAGE_ENCODER_DECODER = new BTreeNode.BTreeNodeEncoderDecoder<Key, Value>(this);
+    private final BTreeNode.DataEncoderDecoder<Key, Value> DATA_ENCODER_DECODER = new BTreeNode.DataEncoderDecoder<Key, Value>(this);
 
     private final Paged paged;
     private final int page;
@@ -64,7 +65,7 @@
     
     public void create() {
         // Store the root page..
-        BTreeNode<Key, Value> root = new BTreeNode<Key, Value>(page);
+        BTreeNode<Key, Value> root = new BTreeNode<Key, Value>(null, page);
         storeNode(root); 
     }
 
@@ -134,18 +135,18 @@
     // Internal implementation methods
     // /////////////////////////////////////////////////////////////////
     private BTreeNode<Key, Value> root() {
-        return loadNode(page);
+        return loadNode(null, page);
     }
 
     // /////////////////////////////////////////////////////////////////
     // Internal methods made accessible to BTreeNode
     // /////////////////////////////////////////////////////////////////
-    BTreeNode<Key, Value> createNode(Data<Key, Value> data) {
-        return new BTreeNode<Key, Value>(paged.allocator().alloc(1), data);
+    BTreeNode<Key, Value> createNode(BTreeNode<Key, Value> parent, Data<Key, Value> data) {
+        return new BTreeNode<Key, Value>(parent, paged.allocator().alloc(1), data);
     }
     
-    BTreeNode<Key, Value> createNode() {
-        return new BTreeNode<Key, Value>(paged.allocator().alloc(1));
+    BTreeNode<Key, Value> createNode(BTreeNode<Key, Value> parent) {
+        return new BTreeNode<Key, Value>(parent, paged.allocator().alloc(1));
     }
     
     @SuppressWarnings("serial")
@@ -158,17 +159,30 @@
      * @return false if page overflow occurred
      */
     boolean storeNode(BTreeNode<Key, Value> node) {
-        // Leaf nodes are the only one they might need to be stored in an
-        // extent.
         if (deferredEncoding) {
-            paged.put(PAGE_ENCODER_DECODER, node.getPage(), node);
+            int size = BTreeNode.estimatedSize(this, node.data);
+            size += 9; // The extent header.
+            
+            if( !node.allowPageOverflow() && size>paged.getPageSize()) {
+                return false;
+            }
+
+            paged.put(DATA_ENCODER_DECODER, node.getPage(), node.data);
+            node.storedInExtent=true;
         } else {
+            
+            if( node.storedInExtent ) {
+                DATA_ENCODER_DECODER.remove(paged, node.page);
+            }
+            
             if (node.isLeaf()) {
-                PAGE_ENCODER_DECODER.store(paged, node.getPage(), node);
-                if( !node.allowPageOverflow() && node.pageCount>1 ) {
-                    PAGE_ENCODER_DECODER.remove(paged, node.getPage());
+                List<Integer> pages = DATA_ENCODER_DECODER.store(paged, node.page, node.data);
+                if( !node.allowPageOverflow() && pages.size()>1 ) {
+                    DATA_ENCODER_DECODER.remove(paged, node.page);
+                    node.storedInExtent=false;
                     return false;
                 }
+                node.storedInExtent=true;
             } else {
                 DataByteArrayOutputStream os = new DataByteArrayOutputStream(paged.getPageSize()) {
                     protected void resize(int newcount) {
@@ -176,8 +190,9 @@
                     };
                 };
                 try {
-                    node.writeExternal(os, this);
-                    paged.write(node.getPage(), os.toBuffer());
+                    BTreeNode.write(os, this, node.data);
+                    paged.write(node.page, os.toBuffer());
+                    node.storedInExtent=false;
                 } catch (IOException e) {
                     throw new IndexException("Could not write btree node");
                 } catch (PageOverflowIOException e) {
@@ -188,42 +203,43 @@
         return true;
     }
     
-    BTreeNode<Key, Value> loadNode(int page) {
-        BTreeNode<Key, Value> node;
+
+
+    BTreeNode<Key, Value> loadNode(BTreeNode<Key, Value> parent, int page) {
+        BTreeNode<Key, Value> node = new BTreeNode<Key, Value>(parent, page);
         if( deferredEncoding ) {
-            node = paged.get(PAGE_ENCODER_DECODER, page);
+            node.data = paged.get(DATA_ENCODER_DECODER, page);
+            node.storedInExtent=true;
         } else {
             Buffer buffer = new Buffer(paged.getPageSize());
             paged.read(page, buffer);
             if ( buffer.startsWith(Extent.DEFAULT_MAGIC) ) {
                 // Page data was stored in an extent..
-                node = PAGE_ENCODER_DECODER.load(paged, page);
+                node.data = DATA_ENCODER_DECODER.load(paged, page);
+                node.storedInExtent=true;
             } else {
                 // It was just in a plain page..
                 DataByteArrayInputStream is = new DataByteArrayInputStream(buffer);
-                node = new BTreeNode<Key, Value>();
                 try {
-                    node.readExternal(is, this);
+                    node.data = BTreeNode.read(is, this);
+                    node.storedInExtent=false;
                 } catch (IOException e) {
                     throw new IndexException("Could not read btree node");
                 }
             }
         }
-        node.setPage(page);
         return node;
     }
     
-    void free( int page ) {
+    void free( BTreeNode<Key, Value> node ) {
         if( deferredEncoding ) {
-            paged.remove(PAGE_ENCODER_DECODER, page);
+            paged.remove(DATA_ENCODER_DECODER, node.page);
         } else {
-            Buffer buffer = new Buffer(paged.getPageSize());
-            paged.read(page, buffer);
-            if ( buffer.startsWith(Extent.DEFAULT_MAGIC) ) {
-                PAGE_ENCODER_DECODER.remove(paged, page);
+            if ( node.storedInExtent ) {
+                DATA_ENCODER_DECODER.remove(paged, node.page);
             }
         }
-        paged.allocator().free(page, 1);
+        paged.allocator().free(node.page, 1);
     }
 
     // /////////////////////////////////////////////////////////////////

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeIterator.java Thu Oct 22 01:18:16 2009
@@ -47,7 +47,7 @@
             if (nextIndex >= current.data.keys.length) {
                 // we need to roll to the next leaf..
                 if (current.data.next >= 0) {
-                    current = index.loadNode(current.data.next);
+                    current = index.loadNode(null, current.data.next);
                     nextIndex = 0;
                 } else {
                     break;

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/index/BTreeNode.java Thu Oct 22 01:18:16 2009
@@ -56,11 +56,17 @@
     public static final Buffer BRANCH_MAGIC = new Buffer(new byte[]{ 'b', 'b'});
     public static final Buffer LEAF_MAGIC = new Buffer(new byte[]{ 'b', 'l'});
     
+    /**
+     * This is the persistent data of each node.  Declared immutable so that 
+     * it can behave nicely in the page cache.  
+     * 
+     * TODO: Consider refactoring into branch/leaf sub classes.
+     * 
+     * @param <Key>
+     * @param <Value>
+     */
     static class Data<Key, Value> {
 
-        // The parent node or -1 if this is the root node of the BTree
-        final int parent;
-
         // Order list of keys in the node
         final Key[] keys;
 
@@ -76,11 +82,10 @@
         
         @SuppressWarnings("unchecked")
         public Data() {
-            this(-1, (Key[])EMPTY_ARRAY, null, (Value[])EMPTY_ARRAY, -1);
+            this((Key[])EMPTY_ARRAY, null, (Value[])EMPTY_ARRAY, -1);
         }
         
-        public Data(int parent, Key[] keys, int[] children, Value[] values, int next) {
-            this.parent = parent;
+        public Data(Key[] keys, int[] children, Value[] values, int next) {
             this.keys = keys;
             this.values = values;
             this.children = children;
@@ -89,154 +94,83 @@
         
         @Override
         public String toString() {
-            return "{ parent: "+parent+", next: "+next+", type: "+(isBranch()?"branch":"leaf")+", keys: "+Arrays.toString(keys)+" }";
+            return "{ next: "+next+", type: "+(isBranch()?"branch":"leaf")+", keys: "+Arrays.toString(keys)+" }";
         }
         
-        private boolean isBranch() {
+        public boolean isBranch() {
             return children != null;
         }
 
         public Data<Key, Value> values(Value[] values) {
-            return new Data<Key, Value>(parent, keys, children, values, next);
+            return new Data<Key, Value>(keys, children, values, next);
         }
 
         public Data<Key, Value> children(int[] children) {
-            return new Data<Key, Value>(parent, keys, children, values, next);
+            return new Data<Key, Value>(keys, children, values, next);
         }
 
         public Data<Key, Value> next(int next) {
-            return new Data<Key, Value>(parent, keys, children, values, next);
+            return new Data<Key, Value>(keys, children, values, next);
         }
         
         public Data<Key, Value> change(Key[] keys, int[] children, Value[] values) {
-            return new Data<Key, Value>(parent, keys, children, values, next);
+            return new Data<Key, Value>(keys, children, values, next);
         }
         
         public Data<Key, Value> branch(Key[] keys, int[] children) {
-            return new Data<Key, Value>(parent, keys, children, null, next);
-        }
-
-        public Data<Key, Value> branch(int parent, Key[] keys, int[] children) {
-            return new Data<Key, Value>(parent, keys, children, null, next);
+            return new Data<Key, Value>(keys, children, null, next);
         }
         
         public Data<Key, Value> leaf(Key[] keys, Value[] values) {
-            return new Data<Key, Value>(parent, keys, null, values, next);
-        }
-
-        public Data<Key, Value> leaf(int parent, Key[] keys, Value[] values) {
-            return new Data<Key, Value>(parent, keys, null, values, next);
+            return new Data<Key, Value>(keys, null, values, next);
         }
         
         public Data<Key, Value> leaf(Key[] keys, Value[] values, int next) {
-            return new Data<Key, Value>(parent, keys, null, values, next);
-        }
-
-        public Data<Key, Value> leaf(int parent, Key[] keys, Value[] values, int next) {
-            return new Data<Key, Value>(parent, keys, null, values, next);
-        }
-
-        public Data<Key, Value> parent(int parent) {
-            return new Data<Key, Value>(parent, keys, children, values, next);
+            return new Data<Key, Value>(keys, null, values, next);
         }
 
     }
-
-    static public class BTreeNodeEncoderDecoder<Key, Value> implements EncoderDecoder<BTreeNode<Key, Value>> {
-
-        private final BTreeIndex<Key, Value> index;
-
-        public BTreeNodeEncoderDecoder(BTreeIndex<Key, Value> index) {
-            this.index = index;
-        }
-
-        public List<Integer> store(Paged paged, int page, BTreeNode<Key, Value> node) {
-            short count = (short) node.data.keys.length; // cast may truncate
-                                                         // value...
-            if (count != node.data.keys.length) {
-                throw new IndexException("Too many keys");
-            }
-
-            // The node will be stored in an extent. This allows us to easily
-            // support huge nodes.
-            // The first extent is only 1 page long, extents linked off
-            // the first page will be up to 128 pages long.
-            ExtentOutputStream eos = new ExtentOutputStream(paged, page, (short) 1, (short) 128);
-            DataOutputStream os = new DataOutputStream(eos);
-            try {
-                node.writeExternal(os, index);
-                os.close();
-            } catch (IOException e) {
-                throw new IndexException(e);
-            }
-
-            Ranges pages = eos.getPages();
-            pages.remove(page);
-            if (pages.isEmpty()) {
-                node.pageCount = 1;
-                return Collections.emptyList();
+    
+    static <Key, Value> int estimatedSize(BTreeIndex<Key, Value> index, Data<Key, Value> data) {
+        int rc = 6; // magic + key count..
+        
+        // calculate the size of the keys.
+        int v = index.getKeyMarshaller().getFixedSize();
+        if( v >=0 ) {
+            rc += v*data.keys.length;
+        } else {
+            for (Key key : data.keys) {
+                rc += index.getKeyMarshaller().estimatedSize(key);
             }
-
-            List<Integer> rc = pages.values();
-            node.pageCount = rc.size() + 1;
-            return rc;
         }
-
-        public BTreeNode<Key, Value> load(Paged paged, int page) {
-            ExtentInputStream eis = new ExtentInputStream(paged, page);
-            DataInputStream is = new DataInputStream(eis);
-            try {
-                BTreeNode<Key, Value> node = new BTreeNode<Key, Value>();
-                node.readExternal(is, index);
-                is.close();
-                node.pageCount = eis.getPages().size();
-                return node;
-            } catch (IOException e) {
-                throw new IndexException(e);
+        
+        if( data.isBranch() ) {
+            // calculate the size of the children.
+            rc += 4*data.children.length;
+        } else {
+            // calculate the size of the values.
+            v = index.getValueMarshaller().getFixedSize();
+            if( v >=0 ) {
+                rc += v*data.values.length;
+            } else {
+                for (Value value : data.values) {
+                    rc += index.getValueMarshaller().estimatedSize(value);
+                }
             }
-
-        }
-
-        public void remove(Paged paged, int page) {
-            Extent.freeLinked(paged, page);
+            rc += 4; // for the next pointer.
         }
-
-    }
-
-    // The persistent data of the node.
-    Data<Key, Value> data;
-    // The page associated with this node
-    private int page;
-    // The number of pages that this node takes on disk if known. -1 if it is not yet known.
-    int pageCount = -1;
-    
-    public BTreeNode() {
-    }
-    
-    @SuppressWarnings("unchecked")
-    public BTreeNode(int page) {
-        this(page, EMPTY_DATA);
-    }
-
-    public BTreeNode(Data<Key, Value> data) {
-        this.data = data;
-    }
-
-    public BTreeNode(int page, Data<Key, Value> data) {
-        this.page = page;
-        this.data = data;
+        
+        return rc;
     }
     
-    
-    void writeExternal(DataOutput os, BTreeIndex<Key, Value> index) throws IOException {
-        int count = data.keys.length;
+    static <Key, Value> void write(DataOutput os, BTreeIndex<Key, Value> index, Data<Key, Value> data) throws IOException {
         if( data.isBranch() ) {
             os.write(BRANCH_MAGIC.data, BRANCH_MAGIC.offset, BRANCH_MAGIC.length);
         } else {
             os.write(LEAF_MAGIC.data, LEAF_MAGIC.offset, LEAF_MAGIC.length);
         }
         
-        os.writeInt(data.parent);
+        int count = data.keys.length;
         os.writeShort(count);
         for (int i = 0; i < data.keys.length; i++) {
             index.getKeyMarshaller().writePayload(data.keys[i], os);
@@ -254,7 +188,8 @@
         }
     }
     
-    @SuppressWarnings("unchecked") void readExternal(DataInput is, BTreeIndex<Key, Value> index) throws IOException {
+    @SuppressWarnings("unchecked") 
+    static <Key, Value> Data<Key, Value> read(DataInput is, BTreeIndex<Key, Value> index) throws IOException {
         Buffer magic = new Buffer(BRANCH_MAGIC.length);
         is.readFully(magic.data, magic.offset, magic.length);
         boolean branch;
@@ -266,7 +201,6 @@
             throw new IndexException("Page did not contain the expected btree headers");
         }
         
-        int parent = is.readInt();
         int count = is.readShort();
         Key[] keys = (Key[]) new Object[count];
         int[] children = null;
@@ -289,8 +223,85 @@
             }
             next = is.readInt();
         }
-        this.data = new Data<Key, Value>(parent, keys, children, values, next);
-    }    
+        return new Data<Key, Value>(keys, children, values, next);
+    }
+    
+    static public class DataEncoderDecoder<Key, Value> implements EncoderDecoder<Data<Key, Value>> {
+        private final BTreeIndex<Key, Value> index;
+
+        public DataEncoderDecoder(BTreeIndex<Key, Value> index) {
+            this.index = index;
+        }
+
+        public List<Integer> store(Paged paged, int page, Data<Key, Value> data) {
+            short count = (short) data.keys.length; // cast may truncate value...
+            if (count != data.keys.length) {
+                throw new IndexException("Too many keys");
+            }
+
+            // The node will be stored in an extent. This allows us to easily
+            // support huge nodes.
+            // The first extent is only 1 page long, extents linked off
+            // the first page will be up to 128 pages long.
+            ExtentOutputStream eos = new ExtentOutputStream(paged, page, (short) 1, (short) 128);
+            DataOutputStream os = new DataOutputStream(eos);
+            try {
+                write(os, index, data);
+                os.close();
+            } catch (IOException e) {
+                throw new IndexException(e);
+            }
+
+            Ranges pages = eos.getPages();
+            pages.remove(page);
+            if (pages.isEmpty()) {
+                return Collections.emptyList();
+            }
+
+            return pages.values();
+        }
+
+        public Data<Key, Value> load(Paged paged, int page) {
+            ExtentInputStream eis = new ExtentInputStream(paged, page);
+            DataInputStream is = new DataInputStream(eis);
+            try {
+                return read(is, index);
+            } catch (IOException e) {
+                throw new IndexException(e);
+            } finally {
+                try {
+                    is.close();
+                } catch (Throwable ignore) {
+                }
+            }
+
+        }
+
+        public void remove(Paged paged, int page) {
+            Extent.freeLinked(paged, page);
+        }
+
+    }
+
+    BTreeNode<Key, Value> parent;
+    // The persistent data of the node.
+    Data<Key, Value> data;
+    // The page associated with this node
+    int page;
+    boolean storedInExtent;
+    
+    @SuppressWarnings("unchecked")
+    public BTreeNode(BTreeNode<Key, Value> parent, int page) {
+        this(parent, page, EMPTY_DATA);
+    }
+
+    public BTreeNode(BTreeNode<Key, Value> parent, int page, Data<Key, Value> data) {
+        this.parent = parent;
+        this.page = page;
+        this.data = data;
+    }
+    
+    
     
     /**
      * Internal (to the BTreeNode) method. Because this method is called only by
@@ -300,7 +311,7 @@
      */
     private BTreeNode<Key, Value> getChild(BTreeIndex<Key, Value> index, int idx) {
         if (data.isBranch() && idx >= 0 && idx < data.children.length) {
-            BTreeNode<Key, Value> result = index.loadNode(data.children[idx]);
+            BTreeNode<Key, Value> result = index.loadNode(this, data.children[idx]);
             return result;
         } else {
             return null;
@@ -326,7 +337,6 @@
                     // This is cause branches are never really empty.. they just
                     // go down to 1 child..
                     data = data.children(arrayUpdate(data.children, idx, child.data.children[0]));
-                    linkChild(index, child.data.children[0]);
                 } else {
 
                     // The child was a leaf. Then we need to actually remove it
@@ -350,11 +360,11 @@
 
                     // If we are the root node, and only have 1 child left. Then
                     // make the root be the leaf node.
-                    if (data.children.length == 1 && data.parent == -1) {
+                    if (data.children.length == 1 && parent == null) {
                         child = getChild(index, 0);
                         data = data.change(child.data.keys, child.data.children, child.data.values);
                         // free up the page..
-                        index.free(child.getPage());
+                        index.free(child);
                     }
 
                 }
@@ -370,8 +380,8 @@
                 Value oldValue = data.values[idx];
                 data = data.leaf(arrayDelete(data.keys, idx), arrayDelete(data.values, idx));
 
-                if (data.keys.length == 0 && data.parent != -1) {
-                    index.free(getPage());
+                if (data.keys.length == 0 && parent != null) {
+                    index.free(this);
                 } else {
                     index.storeNode(this);
                 }
@@ -491,20 +501,18 @@
         }
 
         // Promote the pivot to the parent branch
-        if (data.parent == -1) {
+        if (parent == null) {
 
             // This can only happen if this is the root
-            BTreeNode<Key, Value> lNode = index.createNode();
-            BTreeNode<Key, Value> rNode = index.createNode();
+            BTreeNode<Key, Value> lNode = index.createNode(this);
+            BTreeNode<Key, Value> rNode = index.createNode(this);
 
             if (data.isBranch()) {
-                rNode.data = data.branch(page, rightKeys, rightChildren);
-                rNode.linkChildren(index);
-                lNode.data = data.branch(page, leftKeys, leftChildren);
-                lNode.linkChildren(index);
+                rNode.data = data.branch(rightKeys, rightChildren);
+                lNode.data = data.branch(leftKeys, leftChildren);
             } else {
-                rNode.data = data.leaf(page, rightKeys, rightValues);
-                lNode.data = data.leaf(page, leftKeys, leftValues, rNode.getPage());
+                rNode.data = data.leaf(rightKeys, rightValues);
+                lNode.data = data.leaf(leftKeys, leftValues, rNode.getPage());
             }
 
             Key[] v = createKeyArray(1);
@@ -519,38 +527,21 @@
             BTreeNode<Key, Value> rNode;
 
             if (data.isBranch()) {
-                rNode = index.createNode(data.branch(data.parent, rightKeys, rightChildren));
-                rNode.linkChildren(index);
+                rNode = index.createNode(parent, data.branch(rightKeys, rightChildren));
                 data = data.branch(leftKeys, leftChildren);
             } else {
-                rNode = index.createNode(data.leaf(data.parent, rightKeys, rightValues, data.next));
+                rNode = index.createNode(parent, data.leaf(rightKeys, rightValues, data.next));
                 data = data.leaf(leftKeys, leftValues, rNode.getPage());
             }
 
             index.storeNode(this);
             index.storeNode(rNode);
-            index.loadNode(data.parent).promoteValue(index, separator, rNode.getPage());
+            parent.promoteValue(index, separator, rNode.getPage());
         }
     }
 
-
-    private void linkChildren(BTreeIndex<Key, Value> index) {
-        if( data ==null || data.children ==null ) {
-            throw new NullPointerException();
-        }
-       for (int child : data.children) {
-           linkChild(index, child);
-       }
-    }
-
-    private void linkChild(BTreeIndex<Key, Value> index, int child) {
-        BTreeNode<Key, Value> node = index.loadNode(child);
-        node.data = node.data.parent(page);
-        index.storeNode(node);
-    }
-
     public void printStructure(BTreeIndex<Key, Value> index, PrintWriter out, String prefix) {
-        if (prefix.length() > 0 && data.parent == -1) {
+        if (prefix.length() > 0 && parent == null) {
             throw new IllegalStateException("Cycle back to root node detected.");
         }
 
@@ -592,7 +583,7 @@
         while (node!=null) {
             rc += node.data.values.length;
             if( node.data.next!= -1 ) {
-                node = index.loadNode(node.data.next);
+                node = index.loadNode(null, node.data.next);
             } else {
                 node = null;
             }
@@ -713,13 +704,13 @@
     public void clear(BTreeIndex<Key, Value> index) {
         if (data.isBranch()) {
             for (int i = 0; i < data.children.length; i++) {
-                BTreeNode<Key, Value> node = index.loadNode(data.children[i]);
+                BTreeNode<Key, Value> node = index.loadNode(this, data.children[i]);
                 node.clear(index);
-                index.free(node.getPage());
+                index.free(node);
             }
         }
         // Reset the root node to be a leaf.
-        if (data.parent == -1) {
+        if (parent == null) {
             data = data.leaf((Key[])EMPTY_ARRAY, (Value[])EMPTY_ARRAY, -1);
             index.storeNode(this);
         }
@@ -771,14 +762,14 @@
         return data.keys.length < 4;
     }
     
-    private boolean splitNeeded() {
-        if (pageCount > 1 && data.keys.length > 1) {
-            if (pageCount > 128 || !allowPageOverflow() ) {
-                return true;
-            }
-        }
-        return false;
-    }
+//    private boolean splitNeeded() {
+//        if (pageCount > 1 && data.keys.length > 1) {
+//            if (pageCount > 128 || !allowPageOverflow() ) {
+//                return true;
+//            }
+//        }
+//        return false;
+//    }
 
     @SuppressWarnings("unchecked")
     private Key[] createKeyArray(int size) {
@@ -854,8 +845,8 @@
         return newVals;
     }
 
-    public int getParent() {
-        return data.parent;
+    public BTreeNode<Key, Value> getParent() {
+        return parent;
     }
 
     public int getPage() {

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Extent.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Extent.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Extent.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/Extent.java Thu Oct 22 01:18:16 2009
@@ -69,7 +69,7 @@
             position = buffer.position();
             limit = buffer.limit();
         }
-        return "{ page: "+page+", position: "+position+", limit: "+limit+" }";
+        return "{ page: "+page+", position: "+position+", limit: "+limit+", length: "+length+", next: "+next+" }";
     }
     
     
@@ -208,7 +208,8 @@
             Extent extent = new Extent(paged, page, magic);
             extent.readHeader();
             try {
-                paged.allocator().free(page, paged.pages(extent.getLength()));
+                int pagesInExtent = paged.pages(extent.getLength());
+                paged.allocator().free(page, pagesInExtent);
                 page=extent.getNext();
             } finally {
                 extent.readClose();

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtPageFile.java Thu Oct 22 01:18:16 2009
@@ -581,7 +581,7 @@
                 // Note: every deferred update has an entry in the pageUpdates, so no need to 
                 // check to see if that map also conflicts.
                 rev = updatedSnapshot.commitCheck(pageUpdates);
-                
+                updatedSnapshot.close();
             } else {
                 rev = buildingRedo.head;
             }

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtTransaction.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtTransaction.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtTransaction.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/main/java/org/apache/hawtdb/internal/page/HawtTransaction.java Thu Oct 22 01:18:16 2009
@@ -246,15 +246,16 @@
         boolean failed = true;
         try {
             if (updates!=null) {
+                // If the commit is successful it will release our snapshot..
                 parent.commit(snapshot, updates, deferredUpdates);
             }
             failed = false;
         } finally {
             // Rollback if the commit fails.
             if (failed) {
-                freeAllocatedPages();
+                // rollback will release our snapshot..
+                rollback();
             }
-            parent.closeSnapshot(snapshot);
             updates = null;
             deferredUpdates = null;
             snapshot = null;
@@ -264,7 +265,18 @@
     public void rollback() throws IOPagingException {
         try {
             if (updates!=null) {
-                freeAllocatedPages();
+                for (Entry<Integer, Integer> entry : updates.entrySet()) {
+                    switch (entry.getValue()) {
+                    case HawtPageFile.PAGE_FREED:
+                        // Don't need to do anything..
+                        break;
+                    case HawtPageFile.PAGE_ALLOCATED:
+                    default:
+                        // We need to free the page that was allocated for the
+                        // update..
+                        parent.allocator.free(entry.getKey(), 1);
+                    }
+                }
             }
         } finally {
             parent.closeSnapshot(snapshot);
@@ -274,21 +286,6 @@
         }
     }
 
-    private void freeAllocatedPages() {
-        for (Entry<Integer, Integer> entry : updates.entrySet()) {
-            switch (entry.getValue()) {
-            case HawtPageFile.PAGE_FREED:
-                // Don't need to do anything..
-                break;
-            case HawtPageFile.PAGE_ALLOCATED:
-            default:
-                // We need to free the page that was allocated for the
-                // update..
-                parent.allocator.free(entry.getKey(), 1);
-            }
-        }
-    }
-
     public Snapshot snapshot() {
         if (snapshot == null) {
             snapshot = parent.openSnapshot();

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexBenchmark.java Thu Oct 22 01:18:16 2009
@@ -29,10 +29,15 @@
  */
 public class BTreeIndexBenchmark extends IndexBenchmark {
 
+    public BTreeIndexBenchmark() {
+        this.benchmark.setSamples(30);
+    }
+    
     protected Index<Long, Buffer> createIndex(Transaction tx) {
         BTreeIndexFactory<Long, Buffer> factory = new BTreeIndexFactory<Long, Buffer>();
         factory.setKeyMarshaller(LongMarshaller.INSTANCE);
         factory.setValueMarshaller(new FixedBufferMarshaller(DATA.length));
+        factory.setDeferredEncoding(false);
         return factory.create(tx, tx.allocator().alloc(1));
     }
 

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/BTreeIndexTest.java Thu Oct 22 01:18:16 2009
@@ -68,7 +68,7 @@
      * 
      * @throws Exception
      */
-    public void disabled_testTreeBalancing() throws Exception {
+    public void treeBalancing() throws Exception {
         createPageFileAndIndex((short) 100);
 
         BTreeIndex<String, Long> index = ((BTreeIndex<String, Long>)this.index);
@@ -95,7 +95,6 @@
     
     @Test
     public void testPruning() throws Exception {
-        deferredEncoding=false;
         createPageFileAndIndex((short)100);
 
         BTreeIndex<String,Long> index = ((BTreeIndex<String,Long>)this.index);
@@ -107,6 +106,9 @@
         
         doInsert(1000);
         
+        reloadAll();
+        
+        index = ((BTreeIndex<String,Long>)this.index);
         minLeafDepth = index.getMinLeafDepth();
         maxLeafDepth = index.getMaxLeafDepth();
         assertTrue("Depth of tree grew", minLeafDepth > 1);

Modified: activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java (original)
+++ activemq/sandbox/activemq-apollo/hawtdb/src/test/java/org/apache/hawtdb/internal/index/IndexBenchmark.java Thu Oct 22 01:18:16 2009
@@ -61,11 +61,13 @@
     
     @Test
     public void insert() throws Exception {
+        Thread.sleep(3000);
         benchmark.benchmark(1, new BenchmarkAction<IndexActor>("insert") {
             long counter=0;
             @Override
             protected void execute(IndexActor actor) {
                 actor.index.put(counter++, new Buffer(DATA));
+                actor.tx().commit();
             }
         });
     }

Modified: activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java (original)
+++ activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java Thu Oct 22 01:18:16 2009
@@ -203,6 +203,10 @@
             }
             return node;
         }
+
+        public int estimatedSize(BTreeNode<Key, Value> object) {
+            throw new UnsupportedOperationException();
+        }
     }
 
     public BTreeNode(BTreeIndex<Key, Value> index) {

Modified: activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashBin.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashBin.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashBin.java (original)
+++ activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashBin.java Thu Oct 22 01:18:16 2009
@@ -58,6 +58,10 @@
                 hashIndex.getValueMarshaller().writePayload(entry.getValue(), os);
             }
         }
+
+        public int estimatedSize(HashBin<Key, Value> object) {
+            throw new UnsupportedOperationException();
+        }
         
     }
     

Modified: activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashIndex.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashIndex.java?rev=828268&r1=828267&r2=828268&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashIndex.java (original)
+++ activemq/sandbox/activemq-apollo/kahadb/src/main/java/org/apache/kahadb/index/HashIndex.java Thu Oct 22 01:18:16 2009
@@ -114,6 +114,10 @@
             public void writePayload(Metadata object, DataOutput dataOut) throws IOException {
                 object.write(dataOut);
             }
+
+            public int estimatedSize(Metadata object) {
+                throw new UnsupportedOperationException();
+            }
         }
     }
     



Mime
View raw message