directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1722426 [1/2] - in /directory/mavibot/branches/single-value/mavibot/src: main/java/org/apache/directory/mavibot/btree/ test/java/org/apache/directory/mavibot/btree/
Date Thu, 31 Dec 2015 08:49:04 GMT
Author: elecharny
Date: Thu Dec 31 08:49:03 2015
New Revision: 1722426

URL: http://svn.apache.org/viewvc?rev=1722426&view=rev
Log:
o Renamed the PersistedLeaf and Node to Leaf and Node
o Renamed the PersistedXXX to XXX
o Renamed the PersistedXXXHolder to XXXHolderImpl
o Renamed the PersistedXXX tests to XXX
o added a copy() method in the Page interface (we need to be able to copy a page)

Added:
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeBuilder.java
      - copied, changed from r1706445, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeBuilder.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeConfiguration.java
      - copied, changed from r1711861, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeConfiguration.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeImpl.java
      - copied, changed from r1722069, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTree.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/KeyHolderImpl.java
      - copied, changed from r1706445, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedKeyHolder.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Leaf.java
      - copied, changed from r1722069, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedLeaf.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Node.java
      - copied, changed from r1706445, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedNode.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageHolderImpl.java
      - copied, changed from r1706445, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedPageHolder.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/ValueHolderImpl.java
      - copied, changed from r1711861, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedValueHolder.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/BTreeBrowseTest.java
      - copied, changed from r1722069, directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/PersistedBTreeBrowseTest.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/BTreeBuilderTest.java
      - copied, changed from r1706445, directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/PersistedBTreeBuilderTest.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/BTreeTransactionTest.java
      - copied, changed from r1706445, directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/PersistedBTreeTransactionTest.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/ReadTest.java
      - copied, changed from r1706445, directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/PersistedReadTest.java
Removed:
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTree.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeBuilder.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeConfiguration.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedKeyHolder.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedLeaf.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedNode.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedPageHolder.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedValueHolder.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/PersistedBTreeBrowseTest.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/PersistedBTreeBuilderTest.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/PersistedBTreeTransactionTest.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/PersistedReadTest.java
Modified:
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeHeader.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/MavibotInspector.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageReclaimer.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
    directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/BulkLoaderTest.java
    directory/mavibot/branches/single-value/mavibot/src/test/java/org/apache/directory/mavibot/btree/PageReclaimerTest.java

Copied: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeBuilder.java (from r1706445, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeBuilder.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeBuilder.java?p2=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeBuilder.java&p1=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeBuilder.java&r1=1706445&r2=1722426&rev=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeBuilder.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeBuilder.java Thu Dec 31 08:49:03 2015
@@ -36,7 +36,7 @@ import org.apache.directory.mavibot.btre
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PersistedBTreeBuilder<K, V>
+public class BTreeBuilder<K, V>
 {
     private String name;
 
@@ -49,7 +49,7 @@ public class PersistedBTreeBuilder<K, V>
     private RecordManager rm;
 
 
-    public PersistedBTreeBuilder( RecordManager rm, String name, int numKeysInNode, ElementSerializer<K> keySerializer,
+    public BTreeBuilder( RecordManager rm, String name, int numKeysInNode, ElementSerializer<K> keySerializer,
         ElementSerializer<V> valueSerializer )
     {
         this.rm = rm;
@@ -71,7 +71,7 @@ public class PersistedBTreeBuilder<K, V>
 
         int totalTupleCount = 0;
 
-        PersistedLeaf<K, V> leaf1 = ( PersistedLeaf<K, V> ) BTreeFactory.createLeaf( btree, 0, numKeysInNode );
+        Leaf<K, V> leaf1 = ( Leaf<K, V> ) BTreeFactory.createLeaf( btree, 0, numKeysInNode );
         lstLeaves.add( leaf1 );
 
         int leafIndex = 0;
@@ -82,7 +82,7 @@ public class PersistedBTreeBuilder<K, V>
 
             BTreeFactory.setKey( btree, leaf1, leafIndex, tuple.getKey() );
 
-            PersistedValueHolder<V> eh = new PersistedValueHolder<V>( btree, tuple.getValue() );
+            ValueHolderImpl<V> eh = new ValueHolderImpl<V>( btree, tuple.getValue() );
 
             BTreeFactory.setValue( btree, leaf1, leafIndex, eh );
 
@@ -94,7 +94,7 @@ public class PersistedBTreeBuilder<K, V>
 
                 PageHolder<K, V> pageHolder = rm.writePage( btree, leaf1, 1 );
 
-                leaf1 = ( PersistedLeaf<K, V> ) BTreeFactory.createLeaf( btree, 0, numKeysInNode );
+                leaf1 = ( Leaf<K, V> ) BTreeFactory.createLeaf( btree, 0, numKeysInNode );
                 lstLeaves.add( leaf1 );
             }
 
@@ -107,7 +107,7 @@ public class PersistedBTreeBuilder<K, V>
         }
 
         // remove null keys and values from the last leaf and resize
-        PersistedLeaf<K, V> lastLeaf = ( PersistedLeaf<K, V> ) lstLeaves.get( lstLeaves.size() - 1 );
+        Leaf<K, V> lastLeaf = ( Leaf<K, V> ) lstLeaves.get( lstLeaves.size() - 1 );
         for ( int i = 0; i < lastLeaf.getNbElems(); i++ )
         {
             if ( lastLeaf.getKey( i ) == null )
@@ -116,11 +116,11 @@ public class PersistedBTreeBuilder<K, V>
                 lastLeaf.setNbElems( n );
                 KeyHolder<K>[] keys = lastLeaf.getKeys();
 
-                lastLeaf.setKeys( ( KeyHolder[] ) Array.newInstance( PersistedKeyHolder.class, n ) );
+                lastLeaf.setKeys( ( KeyHolder[] ) Array.newInstance( KeyHolderImpl.class, n ) );
                 System.arraycopy( keys, 0, lastLeaf.getKeys(), 0, n );
 
                 ValueHolder<V>[] values = lastLeaf.values;
-                lastLeaf.values = ( PersistedValueHolder<V>[] ) Array.newInstance( PersistedValueHolder.class, n );
+                lastLeaf.values = ( ValueHolderImpl<V>[] ) Array.newInstance( ValueHolderImpl.class, n );
                 System.arraycopy( values, 0, lastLeaf.values, 0, n );
 
                 PageHolder<K, V> pageHolder = rm.writePage( btree, lastLeaf, 1 );
@@ -134,7 +134,7 @@ public class PersistedBTreeBuilder<K, V>
         Page<K, V> rootPage = attachNodes( lstLeaves, btree );
 
         //System.out.println("built rootpage : " + rootPage);
-        ( ( PersistedBTree<K, V> ) btree ).setNbElems( totalTupleCount );
+        ( ( BTreeImpl<K, V> ) btree ).setNbElems( totalTupleCount );
 
         rm.updateBtreeHeader( btree, ( ( AbstractPage<K, V> ) rootPage ).getOffset() );
 
@@ -158,7 +158,7 @@ public class PersistedBTreeBuilder<K, V>
 
         int numChildren = numKeysInNode + 1;
 
-        PersistedNode<K, V> node = ( PersistedNode<K, V> ) BTreeFactory.createNode( btree, 0, numKeysInNode );
+        Node<K, V> node = ( Node<K, V> ) BTreeFactory.createNode( btree, 0, numKeysInNode );
         lstNodes.add( node );
         int i = 0;
         int totalNodes = 0;
@@ -181,7 +181,7 @@ public class PersistedBTreeBuilder<K, V>
 
                 rm.writePage( btree, node, 1 );
 
-                node = ( PersistedNode<K, V> ) BTreeFactory.createNode( btree, 0, numKeysInNode );
+                node = ( Node<K, V> ) BTreeFactory.createNode( btree, 0, numKeysInNode );
                 lstNodes.add( node );
             }
         }

Copied: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeConfiguration.java (from r1711861, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeConfiguration.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeConfiguration.java?p2=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeConfiguration.java&p1=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeConfiguration.java&r1=1711861&r2=1722426&rev=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTreeConfiguration.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeConfiguration.java Thu Dec 31 08:49:03 2015
@@ -32,7 +32,7 @@ import org.apache.directory.mavibot.btre
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PersistedBTreeConfiguration<K, V>
+public class BTreeConfiguration<K, V>
 {
     /** Number of entries in each Page. */
     private int pageSize = BTree.DEFAULT_PAGE_SIZE;
@@ -61,7 +61,7 @@ public class PersistedBTreeConfiguration
      * The default value is 10000 (10 seconds). If the value is 0 or below,
      * the delay is considered as infinite
      */
-    private long readTimeOut = PersistedBTree.DEFAULT_READ_TIMEOUT;
+    private long readTimeOut = BTreeImpl.DEFAULT_READ_TIMEOUT;
 
     /** The B-tree type */
     private BTreeTypeEnum btreeType = BTreeTypeEnum.PERSISTED;

Modified: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java?rev=1722426&r1=1722425&r2=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java Thu Dec 31 08:49:03 2015
@@ -48,7 +48,7 @@ public class BTreeFactory<K, V>
      */
     public static <K, V> BTree<K, V> createPersistedBTree()
     {
-        BTree<K, V> btree = new PersistedBTree<K, V>();
+        BTree<K, V> btree = new BTreeImpl<K, V>();
 
         return btree;
     }
@@ -61,7 +61,7 @@ public class BTreeFactory<K, V>
      */
     public static <K, V> BTree<K, V> createPersistedBTree( BTreeTypeEnum type )
     {
-        BTree<K, V> btree = new PersistedBTree<K, V>();
+        BTree<K, V> btree = new BTreeImpl<K, V>();
         ( ( AbstractBTree<K, V> ) btree ).setType( type );
 
         return btree;
@@ -74,7 +74,7 @@ public class BTreeFactory<K, V>
      * @param btree The btree to update
      * @param btreeHeaderOffset The offset
      */
-    public static <K, V> void setBtreeHeaderOffset( PersistedBTree<K, V> btree, long btreeHeaderOffset )
+    public static <K, V> void setBtreeHeaderOffset( BTreeImpl<K, V> btree, long btreeHeaderOffset )
     {
         btree.setBtreeHeaderOffset( btreeHeaderOffset );
     }
@@ -87,9 +87,9 @@ public class BTreeFactory<K, V>
      * @param configuration The configuration to use
      * @return a new B-tree instance
      */
-    public static <K, V> BTree<K, V> createPersistedBTree( PersistedBTreeConfiguration<K, V> configuration )
+    public static <K, V> BTree<K, V> createPersistedBTree( BTreeConfiguration<K, V> configuration )
     {
-        BTree<K, V> btree = new PersistedBTree<K, V>( configuration );
+        BTree<K, V> btree = new BTreeImpl<K, V>( configuration );
 
         return btree;
     }
@@ -107,16 +107,16 @@ public class BTreeFactory<K, V>
     public static <K, V> BTree<K, V> createPersistedBTree( String name, ElementSerializer<K> keySerializer,
         ElementSerializer<V> valueSerializer )
     {
-        PersistedBTreeConfiguration<K, V> configuration = new PersistedBTreeConfiguration<K, V>();
+        BTreeConfiguration<K, V> configuration = new BTreeConfiguration<K, V>();
 
         configuration.setName( name );
         configuration.setKeySerializer( keySerializer );
         configuration.setValueSerializer( valueSerializer );
         configuration.setPageSize( BTree.DEFAULT_PAGE_SIZE );
-        configuration.setCacheSize( PersistedBTree.DEFAULT_CACHE_SIZE );
+        configuration.setCacheSize( BTreeImpl.DEFAULT_CACHE_SIZE );
         configuration.setWriteBufferSize( BTree.DEFAULT_WRITE_BUFFER_SIZE );
 
-        BTree<K, V> btree = new PersistedBTree<K, V>( configuration );
+        BTree<K, V> btree = new BTreeImpl<K, V>( configuration );
 
         return btree;
     }
@@ -135,16 +135,16 @@ public class BTreeFactory<K, V>
     public static <K, V> BTree<K, V> createPersistedBTree( String name, ElementSerializer<K> keySerializer,
         ElementSerializer<V> valueSerializer, boolean allowDuplicates )
     {
-        PersistedBTreeConfiguration<K, V> configuration = new PersistedBTreeConfiguration<K, V>();
+        BTreeConfiguration<K, V> configuration = new BTreeConfiguration<K, V>();
 
         configuration.setName( name );
         configuration.setKeySerializer( keySerializer );
         configuration.setValueSerializer( valueSerializer );
         configuration.setPageSize( BTree.DEFAULT_PAGE_SIZE );
-        configuration.setCacheSize( PersistedBTree.DEFAULT_CACHE_SIZE );
+        configuration.setCacheSize( BTreeImpl.DEFAULT_CACHE_SIZE );
         configuration.setWriteBufferSize( BTree.DEFAULT_WRITE_BUFFER_SIZE );
 
-        BTree<K, V> btree = new PersistedBTree<K, V>( configuration );
+        BTree<K, V> btree = new BTreeImpl<K, V>( configuration );
 
         return btree;
     }
@@ -164,7 +164,7 @@ public class BTreeFactory<K, V>
     public static <K, V> BTree<K, V> createPersistedBTree( String name, ElementSerializer<K> keySerializer,
         ElementSerializer<V> valueSerializer, boolean allowDuplicates, int cacheSize )
     {
-        PersistedBTreeConfiguration<K, V> configuration = new PersistedBTreeConfiguration<K, V>();
+        BTreeConfiguration<K, V> configuration = new BTreeConfiguration<K, V>();
 
         configuration.setName( name );
         configuration.setKeySerializer( keySerializer );
@@ -173,7 +173,7 @@ public class BTreeFactory<K, V>
         configuration.setCacheSize( cacheSize );
         configuration.setWriteBufferSize( BTree.DEFAULT_WRITE_BUFFER_SIZE );
 
-        BTree<K, V> btree = new PersistedBTree<K, V>( configuration );
+        BTree<K, V> btree = new BTreeImpl<K, V>( configuration );
 
         return btree;
     }
@@ -192,16 +192,16 @@ public class BTreeFactory<K, V>
     public static <K, V> BTree<K, V> createPersistedBTree( String name, ElementSerializer<K> keySerializer,
         ElementSerializer<V> valueSerializer, int pageSize )
     {
-        PersistedBTreeConfiguration<K, V> configuration = new PersistedBTreeConfiguration<K, V>();
+        BTreeConfiguration<K, V> configuration = new BTreeConfiguration<K, V>();
 
         configuration.setName( name );
         configuration.setKeySerializer( keySerializer );
         configuration.setValueSerializer( valueSerializer );
         configuration.setPageSize( pageSize );
-        configuration.setCacheSize( PersistedBTree.DEFAULT_CACHE_SIZE );
+        configuration.setCacheSize( BTreeImpl.DEFAULT_CACHE_SIZE );
         configuration.setWriteBufferSize( BTree.DEFAULT_WRITE_BUFFER_SIZE );
 
-        BTree<K, V> btree = new PersistedBTree<K, V>( configuration );
+        BTree<K, V> btree = new BTreeImpl<K, V>( configuration );
 
         return btree;
     }
@@ -221,16 +221,16 @@ public class BTreeFactory<K, V>
     public static <K, V> BTree<K, V> createPersistedBTree( String name, ElementSerializer<K> keySerializer,
         ElementSerializer<V> valueSerializer, int pageSize, boolean allowDuplicates )
     {
-        PersistedBTreeConfiguration<K, V> configuration = new PersistedBTreeConfiguration<K, V>();
+        BTreeConfiguration<K, V> configuration = new BTreeConfiguration<K, V>();
 
         configuration.setName( name );
         configuration.setKeySerializer( keySerializer );
         configuration.setValueSerializer( valueSerializer );
         configuration.setPageSize( pageSize );
-        configuration.setCacheSize( PersistedBTree.DEFAULT_CACHE_SIZE );
+        configuration.setCacheSize( BTreeImpl.DEFAULT_CACHE_SIZE );
         configuration.setWriteBufferSize( BTree.DEFAULT_WRITE_BUFFER_SIZE );
 
-        BTree<K, V> btree = new PersistedBTree<K, V>( configuration );
+        BTree<K, V> btree = new BTreeImpl<K, V>( configuration );
 
         return btree;
     }
@@ -251,7 +251,7 @@ public class BTreeFactory<K, V>
     public static <K, V> BTree<K, V> createPersistedBTree( String name, ElementSerializer<K> keySerializer,
         ElementSerializer<V> valueSerializer, int pageSize, boolean allowDuplicates, int cacheSize )
     {
-        PersistedBTreeConfiguration<K, V> configuration = new PersistedBTreeConfiguration<K, V>();
+        BTreeConfiguration<K, V> configuration = new BTreeConfiguration<K, V>();
 
         configuration.setName( name );
         configuration.setKeySerializer( keySerializer );
@@ -260,7 +260,7 @@ public class BTreeFactory<K, V>
         configuration.setCacheSize( cacheSize );
         configuration.setWriteBufferSize( BTree.DEFAULT_WRITE_BUFFER_SIZE );
 
-        BTree<K, V> btree = new PersistedBTree<K, V>( configuration );
+        BTree<K, V> btree = new BTreeImpl<K, V>( configuration );
 
         return btree;
     }
@@ -280,7 +280,7 @@ public class BTreeFactory<K, V>
      */
     /* no qualifier*/static <K, V> Page<K, V> createLeaf( BTree<K, V> btree, long revision, int nbElems )
     {
-        return new PersistedLeaf<K, V>( btree, revision, nbElems );
+        return new Leaf<K, V>( btree, revision, nbElems );
     }
 
 
@@ -295,7 +295,7 @@ public class BTreeFactory<K, V>
     /* no qualifier*/static <K, V> Page<K, V> createNode( BTree<K, V> btree, long revision, int nbElems )
     {
         //System.out.println( "Creating a node with nbElems : " + nbElems );
-        return new PersistedNode<K, V>( btree, revision, nbElems );
+        return new Node<K, V>( btree, revision, nbElems );
     }
 
 
@@ -312,7 +312,7 @@ public class BTreeFactory<K, V>
      */
     /* no qualifier*/static <K, V> void setKey( BTree<K, V> btree, Page<K, V> page, int pos, K key )
     {
-        KeyHolder<K> keyHolder = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+        KeyHolder<K> keyHolder = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
 
         ( ( AbstractPage<K, V> ) page ).setKey( pos, keyHolder );
     }
@@ -328,7 +328,7 @@ public class BTreeFactory<K, V>
      */
     /* no qualifier*/static <K, V> void setValue( BTree<K, V> btree, Page<K, V> page, int pos, ValueHolder<V> value )
     {
-        ( ( PersistedLeaf<K, V> ) page ).setValue( pos, value );
+        ( ( Leaf<K, V> ) page ).setValue( pos, value );
     }
 
 
@@ -342,7 +342,7 @@ public class BTreeFactory<K, V>
      */
     /* no qualifier*/static <K, V> void setPage( BTree<K, V> btree, Page<K, V> page, int pos, Page<K, V> child )
     {
-        ( ( PersistedNode<K, V> ) page ).setValue( pos, new PersistedPageHolder<K, V>( btree, child ) );
+        ( ( Node<K, V> ) page ).setValue( pos, new PageHolderImpl<K, V>( btree, child ) );
     }
 
 
@@ -552,9 +552,9 @@ public class BTreeFactory<K, V>
      */
     /* no qualifier*/static <K, V> void setRootPageOffset( BTree<K, V> btree, long rootPageOffset )
     {
-        if ( btree instanceof PersistedBTree )
+        if ( btree instanceof BTreeImpl )
         {
-            ( ( PersistedBTree<K, V> ) btree ).getBtreeHeader().setRootPageOffset( rootPageOffset );
+            ( ( BTreeImpl<K, V> ) btree ).getBtreeHeader().setRootPageOffset( rootPageOffset );
         }
         else
         {
@@ -571,9 +571,9 @@ public class BTreeFactory<K, V>
      */
     /* no qualifier*/static <K, V> void setRecordManager( BTree<K, V> btree, RecordManager recordManager )
     {
-        if ( btree instanceof PersistedBTree )
+        if ( btree instanceof BTreeImpl )
         {
-            ( ( PersistedBTree<K, V> ) btree ).setRecordManager( recordManager );
+            ( ( BTreeImpl<K, V> ) btree ).setRecordManager( recordManager );
         }
         else
         {
@@ -592,9 +592,9 @@ public class BTreeFactory<K, V>
      */
     /* no qualifier*/static <K, V> void setKey( BTree<K, V> btree, Page<K, V> page, int pos, byte[] buffer )
     {
-        if ( btree instanceof PersistedBTree )
+        if ( btree instanceof BTreeImpl )
         {
-            KeyHolder<K> keyHolder = new PersistedKeyHolder<K>( btree.getKeySerializer(), buffer );
+            KeyHolder<K> keyHolder = new KeyHolderImpl<K>( btree.getKeySerializer(), buffer );
             ( ( AbstractPage<K, V> ) page ).setKey( pos, keyHolder );
         }
         else
@@ -612,7 +612,7 @@ public class BTreeFactory<K, V>
      */
     /* no qualifier*/static <K, V> LinkedList<ParentPos<K, V>> getPathToLeftMostLeaf( BTree<K, V> btree )
     {
-        if ( btree instanceof PersistedBTree )
+        if ( btree instanceof BTreeImpl )
         {
             LinkedList<ParentPos<K, V>> stack = new LinkedList<ParentPos<K, V>>();
 

Modified: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeHeader.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeHeader.java?rev=1722426&r1=1722425&r2=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeHeader.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeHeader.java Thu Dec 31 08:49:03 2015
@@ -86,7 +86,7 @@ import java.util.concurrent.atomic.Atomi
      */
     public long getBTreeInfoOffset()
     {
-        return ( ( PersistedBTree<K, V> ) btree ).getBtreeInfoOffset();
+        return ( ( BTreeImpl<K, V> ) btree ).getBtreeInfoOffset();
     }
 
 
@@ -306,7 +306,7 @@ import java.util.concurrent.atomic.Atomi
         sb.append( ", name[" ).append( btree.getName() ).append( "]" );
         sb.append( ", revision[" ).append( revision ).append( "]" );
         sb.append( ", btreeInfoOffset[0x" )
-            .append( Long.toHexString( ( ( PersistedBTree<K, V> ) btree ).getBtreeInfoOffset() ) ).append( "]" );
+            .append( Long.toHexString( ( ( BTreeImpl<K, V> ) btree ).getBtreeInfoOffset() ) ).append( "]" );
         sb.append( ", rootPageOffset[0x" ).append( Long.toHexString( rootPageOffset ) ).append( "]" );
         sb.append( ", nbElems[" ).append( nbElems ).append( "]" );
         sb.append( ", nbUsers[" ).append( nbUsers.get() ).append( "]" );
@@ -366,7 +366,7 @@ import java.util.concurrent.atomic.Atomi
         position = recordManager.store( position, getRootPageOffset(), btreeHeaderPageIos );
 
         // The B-tree info page offset
-        position = recordManager.store( position, ( ( PersistedBTree<K, V> ) btree ).getBtreeInfoOffset(), btreeHeaderPageIos );
+        position = recordManager.store( position, ( ( BTreeImpl<K, V> ) btree ).getBtreeInfoOffset(), btreeHeaderPageIos );
 
         // And flush the pages to disk now
         /*

Copied: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeImpl.java (from r1722069, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTree.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeImpl.java?p2=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeImpl.java&p1=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTree.java&r1=1722069&r2=1722426&rev=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedBTree.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeImpl.java Thu Dec 31 08:49:03 2015
@@ -40,10 +40,10 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PersistedBTree<K, V> extends AbstractBTree<K, V> implements Closeable
+public class BTreeImpl<K, V> extends AbstractBTree<K, V> implements Closeable
 {
     /** The LoggerFactory used by this class */
-    protected static final Logger LOG = LoggerFactory.getLogger( PersistedBTree.class );
+    protected static final Logger LOG = LoggerFactory.getLogger( BTreeImpl.class );
 
     protected static final Logger LOG_PAGES = LoggerFactory.getLogger( "org.apache.directory.mavibot.LOG_PAGES" );
 
@@ -63,7 +63,7 @@ public class PersistedBTree<K, V> extend
     /**
      * Creates a new BTree, with no initialization.
      */
-    /* no qualifier */PersistedBTree()
+    BTreeImpl()
     {
         setType( BTreeTypeEnum.PERSISTED );
     }
@@ -75,7 +75,7 @@ public class PersistedBTree<K, V> extend
      *
      * @param configuration The configuration to use
      */
-    /* no qualifier */PersistedBTree( PersistedBTreeConfiguration<K, V> configuration )
+    BTreeImpl( BTreeConfiguration<K, V> configuration )
     {
         super();
         String name = configuration.getName();
@@ -153,8 +153,8 @@ public class PersistedBTree<K, V> extend
         }
         else
         {
-            this.cache = ( ( PersistedBTree<K, V> ) parentBTree ).getCache();
-            this.readTransactions = ( ( PersistedBTree<K, V> ) parentBTree ).getReadTransactions();
+            this.cache = ( ( BTreeImpl<K, V> ) parentBTree ).getCache();
+            this.readTransactions = ( ( BTreeImpl<K, V> ) parentBTree ).getReadTransactions();
         }
 
         // Initialize the txnManager thread
@@ -471,9 +471,10 @@ public class PersistedBTree<K, V> extend
         // Get the current B-tree header, and insert the value into it
         // Check if it's in the context
         BTreeHeader<K, V> btreeHeader = currentBtreeHeader;
+        long btreeHeaderOffset = currentBtreeHeader.getBTreeHeaderOffset();
         
         // If the current btree header has been modified, it will be in the WalObject map. 
-        WALObject walObject = ( BTreeHeader<K, V> ) recordManager.getContext().getPage( currentBtreeHeader.getBTreeHeaderOffset() );
+        WALObject walObject = ( BTreeHeader<K, V> ) recordManager.getContext().getPage( btreeHeaderOffset );
         
         if ( walObject != null )
         {
@@ -483,20 +484,22 @@ public class PersistedBTree<K, V> extend
         {
             // Create a new BTreeHeader
             BTreeHeader<K, V> newBtreeHeader = btreeHeader.copy();
+            
+            // Get an offset for this newly created page
+            newBtreeHeader.serialize();
 
             // Store the btreeHeader into the context
-            recordManager.getContext().addPage( newBtreeHeader.getBTreeHeaderOffset(),  newBtreeHeader );
+            recordManager.getContext().addPage( newBtreeHeader.getBTreeHeaderOffset(), newBtreeHeader );
     
             // Store the old BtreeHeader in the copied page map in the context
-            recordManager.getContext().addCopiedPage( btreeHeader.getBTreeHeaderOffset(),  btreeHeader );
-    
-            btreeHeader = newBtreeHeader;
+            recordManager.getContext().addCopiedPage( btreeHeaderOffset,  btreeHeader );
         }
         
         // Get the rootPage
         Page<K, V> rootPage = null;
+        long rootPageOffset = btreeHeader.getRootPageOffset();
         
-        walObject = recordManager.getContext().getPage( btreeHeader.getRootPageOffset() );
+        walObject = recordManager.getContext().getPage( rootPageOffset );
         
         if ( walObject != null )
         {
@@ -504,7 +507,8 @@ public class PersistedBTree<K, V> extend
         }
         else
         {
-        	rootPage = btreeHeader.getRootPage();
+            // We need to copy the page
+            rootPage = btreeHeader.getRootPage();
         }
         
         InsertResult<K, V> result = rootPage.insert( key, value, revision );
@@ -545,7 +549,7 @@ public class PersistedBTree<K, V> extend
             PageHolder<K, V> holderRight = writePage( rightPage, revision );
 
             // Create the new rootPage
-            newRootPage = new PersistedNode<K, V>( this, revision, pivot, holderLeft, holderRight );
+            newRootPage = new Node<K, V>( this, revision, pivot, holderLeft, holderRight );
 
             // Always increment the counter : we have added a new value
             btreeHeader.incrementNbElems();

Modified: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java?rev=1722426&r1=1722425&r2=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/BulkLoader.java Thu Dec 31 08:49:03 2015
@@ -464,9 +464,9 @@ public class BulkLoader<K, V>
      */
     private static <K, V> void injectInLeaf( BTree<K, V> btree, Tuple<K, V> tuple, LevelInfo<K, V> leafLevel )
     {
-        PersistedLeaf<K, V> leaf = ( PersistedLeaf<K, V> ) leafLevel.getCurrentPage();
+        Leaf<K, V> leaf = ( Leaf<K, V> ) leafLevel.getCurrentPage();
 
-        KeyHolder<K> keyHolder = new PersistedKeyHolder<K>( btree.getKeySerializer(), tuple.getKey() );
+        KeyHolder<K> keyHolder = new KeyHolderImpl<K>( btree.getKeySerializer(), tuple.getKey() );
         leaf.setKey( leafLevel.getCurrentPos(), keyHolder );
 
         leafLevel.incCurrentPos();
@@ -530,7 +530,7 @@ public class BulkLoader<K, V>
     private static <K, V> void injectInRoot( BTree<K, V> btree, Page<K, V> page, PageHolder<K, V> pageHolder,
         LevelInfo<K, V> level ) throws IOException
     {
-        PersistedNode<K, V> node = ( PersistedNode<K, V> ) level.getCurrentPage();
+        Node<K, V> node = ( Node<K, V> ) level.getCurrentPage();
 
         if ( ( level.getCurrentPos() == 0 ) && ( node.getPage( 0 ) == null ) )
         {
@@ -541,7 +541,7 @@ public class BulkLoader<K, V>
         {
             // Inject the pageHolder and the page leftmost key
             node.setPageHolder( level.getCurrentPos() + 1, pageHolder );
-            KeyHolder<K> keyHolder = new PersistedKeyHolder<K>( btree.getKeySerializer(), page.getLeftMostKey() );
+            KeyHolder<K> keyHolder = new KeyHolderImpl<K>( btree.getKeySerializer(), page.getLeftMostKey() );
             node.setKey( level.getCurrentPos(), keyHolder );
             level.incCurrentPos();
             level.incNbAddedElems();
@@ -550,9 +550,9 @@ public class BulkLoader<K, V>
             // we have to write the page on disk and update the btree
             if ( level.getNbAddedElems() == level.getNbElems() )
             {
-                PageHolder<K, V> rootHolder = ( ( PersistedBTree<K, V> ) btree ).getRecordManager().writePage(
+                PageHolder<K, V> rootHolder = ( ( BTreeImpl<K, V> ) btree ).getRecordManager().writePage(
                     btree, node, 0L );
-                ( ( PersistedBTree<K, V> ) btree ).setRootPage( rootHolder.getValue() );
+                ( ( BTreeImpl<K, V> ) btree ).setRootPage( rootHolder.getValue() );
             }
         }
 
@@ -569,10 +569,10 @@ public class BulkLoader<K, V>
     {
         int pageSize = btree.getPageSize();
         LevelInfo<K, V> level = levels.get( levelIndex );
-        PersistedNode<K, V> node = ( PersistedNode<K, V> ) level.getCurrentPage();
+        Node<K, V> node = ( Node<K, V> ) level.getCurrentPage();
 
         // We first have to write the page on disk
-        PageHolder<K, V> pageHolder = ( ( PersistedBTree<K, V> ) btree ).getRecordManager().writePage( btree, page, 0L );
+        PageHolder<K, V> pageHolder = ( ( BTreeImpl<K, V> ) btree ).getRecordManager().writePage( btree, page, 0L );
 
         // First deal with a node that has less than PageSize elements at this level.
         // It will become the root node.
@@ -601,7 +601,7 @@ public class BulkLoader<K, V>
             {
                 // Inject the pageHolder and the page leftmost key
                 node.setPageHolder( level.getCurrentPos(), pageHolder );
-                KeyHolder<K> keyHolder = new PersistedKeyHolder<K>( btree.getKeySerializer(), page.getLeftMostKey() );
+                KeyHolder<K> keyHolder = new KeyHolderImpl<K>( btree.getKeySerializer(), page.getLeftMostKey() );
                 node.setKey( level.getCurrentPos() - 1, keyHolder );
             }
 
@@ -673,7 +673,7 @@ public class BulkLoader<K, V>
                     {
                         // Inject the pageHolder and the page leftmost key
                         node.setPageHolder( level.getCurrentPos(), pageHolder );
-                        KeyHolder<K> keyHolder = new PersistedKeyHolder<K>( btree.getKeySerializer(),
+                        KeyHolder<K> keyHolder = new KeyHolderImpl<K>( btree.getKeySerializer(),
                             page.getLeftMostKey() );
                         node.setKey( level.getCurrentPos() - 1, keyHolder );
                     }
@@ -702,7 +702,7 @@ public class BulkLoader<K, V>
                         // Any other following elements
                         // Inject the pageHolder and the page leftmost key
                         node.setPageHolder( level.getCurrentPos(), pageHolder );
-                        KeyHolder<K> keyHolder = new PersistedKeyHolder<K>( btree.getKeySerializer(),
+                        KeyHolder<K> keyHolder = new KeyHolderImpl<K>( btree.getKeySerializer(),
                             page.getLeftMostKey() );
                         node.setKey( level.getCurrentPos() - 1, keyHolder );
                     }
@@ -745,7 +745,7 @@ public class BulkLoader<K, V>
                         // Any other following elements
                         // Inject the pageHolder and the page leftmost key
                         node.setPageHolder( level.getCurrentPos(), pageHolder );
-                        KeyHolder<K> keyHolder = new PersistedKeyHolder<K>( btree.getKeySerializer(),
+                        KeyHolder<K> keyHolder = new KeyHolderImpl<K>( btree.getKeySerializer(),
                             page.getLeftMostKey() );
                         node.setKey( level.getCurrentPos() - 1, keyHolder );
                     }
@@ -786,7 +786,7 @@ public class BulkLoader<K, V>
         switch ( btree.getType() )
         {
             default:
-                ( ( PersistedLeaf<K, V> ) rootPage ).values = values;
+                ( ( Leaf<K, V> ) rootPage ).values = values;
         }
 
         // We first have to inject data into the page
@@ -797,11 +797,11 @@ public class BulkLoader<K, V>
             Tuple<K, V> tuple = dataIterator.next();
 
             // Store the current element in the rootPage
-            KeyHolder<K> keyHolder = new PersistedKeyHolder<K>( btree.getKeySerializer(), tuple.getKey() );
+            KeyHolder<K> keyHolder = new KeyHolderImpl<K>( btree.getKeySerializer(), tuple.getKey() );
             keys[pos] = keyHolder;
 
-            ValueHolder<V>valueHolder = new PersistedValueHolder<V>( btree, ( V )tuple.getValue() );
-            ( ( PersistedLeaf<K, V> ) rootPage ).values[pos] = valueHolder;
+            ValueHolder<V>valueHolder = new ValueHolderImpl<V>( btree, ( V )tuple.getValue() );
+            ( ( Leaf<K, V> ) rootPage ).values[pos] = valueHolder;
 
             pos++;
         }

Copied: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/KeyHolderImpl.java (from r1706445, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedKeyHolder.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/KeyHolderImpl.java?p2=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/KeyHolderImpl.java&p1=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedKeyHolder.java&r1=1706445&r2=1722426&rev=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedKeyHolder.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/KeyHolderImpl.java Thu Dec 31 08:49:03 2015
@@ -32,7 +32,7 @@ import org.apache.directory.mavibot.btre
  * 
  * <K> The key type
  */
-/* No qualifier */class PersistedKeyHolder<K> extends KeyHolder<K>
+/* No qualifier */class KeyHolderImpl<K> extends KeyHolder<K>
 {
     /** The ByteBuffer storing the key */
     private byte[] raw;
@@ -46,7 +46,7 @@ import org.apache.directory.mavibot.btre
      * @param keySerializer The KeySerializer instance
      * @param key The key to store
      */
-    /* no qualifier */PersistedKeyHolder( ElementSerializer<K> keySerializer, K key )
+    KeyHolderImpl( ElementSerializer<K> keySerializer, K key )
     {
         super( key );
         this.keySerializer = keySerializer;
@@ -59,7 +59,7 @@ import org.apache.directory.mavibot.btre
      * @param keySerializer The KeySerializer instance
      * @param raw the bytes representing the serialized key
      */
-    /* no qualifier */PersistedKeyHolder( ElementSerializer<K> keySerializer, byte[] raw )
+    KeyHolderImpl( ElementSerializer<K> keySerializer, byte[] raw )
     {
         super( null );
         this.keySerializer = keySerializer;

Copied: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Leaf.java (from r1722069, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedLeaf.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Leaf.java?p2=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Leaf.java&p1=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedLeaf.java&r1=1722069&r2=1722426&rev=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedLeaf.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Leaf.java Thu Dec 31 08:49:03 2015
@@ -36,7 +36,7 @@ import org.apache.directory.mavibot.btre
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/* No qualifier */class PersistedLeaf<K, V> extends AbstractPage<K, V>
+/* No qualifier */class Leaf<K, V> extends AbstractPage<K, V>
 {
     /** Values associated with keys */
     protected ValueHolder<V>[] values;
@@ -47,7 +47,7 @@ import org.apache.directory.mavibot.btre
      *
      * @param btree The BTree this page belongs to.
      */
-    PersistedLeaf( BTree<K, V> btree )
+    Leaf( BTree<K, V> btree )
     {
         super( btree );
     }
@@ -61,10 +61,10 @@ import org.apache.directory.mavibot.btre
      * @param nbElems The number of elements this page will contain
      */
     @SuppressWarnings("unchecked")
-    PersistedLeaf( BTree<K, V> btree, long revision, int nbElems )
+    Leaf( BTree<K, V> btree, long revision, int nbElems )
     {
         super( btree, revision, nbElems );
-        values = ( ValueHolder<V>[] ) Array.newInstance( PersistedValueHolder.class, btree.getPageSize() );
+        values = ( ValueHolder<V>[] ) Array.newInstance( ValueHolderImpl.class, btree.getPageSize() );
     }
 
 
@@ -165,10 +165,10 @@ import org.apache.directory.mavibot.btre
             }
         }
 
-        PersistedLeaf<K, V> newLeaf = null;
+        Leaf<K, V> newLeaf = null;
 
         // No value, we can remove the key
-        newLeaf = new PersistedLeaf<K, V>( btree, revision, nbElems - 1 );
+        newLeaf = new Leaf<K, V>( btree, revision, nbElems - 1 );
 
         // Create the result
         DeleteResult<K, V> defaultResult = new RemoveResult<K, V>( newLeaf, removedElement );
@@ -197,7 +197,7 @@ import org.apache.directory.mavibot.btre
                 // Check in both next and previous page, if they have the same parent
                 // and select the biggest page with the same parent to borrow an element.
                 int siblingPos = selectSibling( parent, parentPos );
-                PersistedLeaf<K, V> sibling = ( PersistedLeaf<K, V> ) ( ( ( PersistedNode<K, V> ) parent )
+                Leaf<K, V> sibling = ( Leaf<K, V> ) ( ( ( Node<K, V> ) parent )
                     .getPage( siblingPos ) );
 
                 if ( sibling.getNbElems() == halfSize )
@@ -254,13 +254,13 @@ import org.apache.directory.mavibot.btre
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> mergeWithSibling( Tuple<K, V> removedElement, long revision,
-        PersistedLeaf<K, V> sibling,
+        Leaf<K, V> sibling,
         boolean isLeft, int pos )
         throws EndOfFileExceededException, IOException
     {
         // Create the new page. It will contain N - 1 elements (the maximum number)
         // as we merge two pages that contain N/2 elements minus the one we remove
-        PersistedLeaf<K, V> newLeaf = new PersistedLeaf<K, V>( btree, revision, btree.getPageSize() - 1 );
+        Leaf<K, V> newLeaf = new Leaf<K, V>( btree, revision, btree.getPageSize() - 1 );
 
         if ( isLeft )
         {
@@ -314,7 +314,7 @@ import org.apache.directory.mavibot.btre
      * @return The resulting pages
      * @throws IOException If we have an error while trying to access the page
      */
-    private DeleteResult<K, V> borrowFromLeft( Tuple<K, V> removedElement, long revision, PersistedLeaf<K, V> sibling,
+    private DeleteResult<K, V> borrowFromLeft( Tuple<K, V> removedElement, long revision, Leaf<K, V> sibling,
         int pos )
         throws IOException
     {
@@ -324,14 +324,14 @@ import org.apache.directory.mavibot.btre
         siblingValue = sibling.values[sibling.getNbElems() - 1];
 
         // Create the new sibling, with one less element at the end
-        PersistedLeaf<K, V> newSibling = ( PersistedLeaf<K, V> ) sibling.copy( revision, sibling.getNbElems() - 1 );
+        Leaf<K, V> newSibling = ( Leaf<K, V> ) sibling.copy( revision, sibling.getNbElems() - 1 );
 
         // Create the new page and add the new element at the beginning
         // First copy the current page, with the same size
-        PersistedLeaf<K, V> newLeaf = new PersistedLeaf<K, V>( btree, revision, nbElems );
+        Leaf<K, V> newLeaf = new Leaf<K, V>( btree, revision, nbElems );
 
         // Insert the borrowed element
-        newLeaf.keys[0] = new PersistedKeyHolder<K>( btree.getKeySerializer(), siblingKey );
+        newLeaf.keys[0] = new KeyHolderImpl<K>( btree.getKeySerializer(), siblingKey );
         newLeaf.values[0] = siblingValue;
 
         // Copy the keys and the values up to the insertion position,
@@ -363,7 +363,7 @@ import org.apache.directory.mavibot.btre
      * @return The resulting pages
      * @throws IOException If we have an error while trying to access the page
      */
-    private DeleteResult<K, V> borrowFromRight( Tuple<K, V> removedElement, long revision, PersistedLeaf<K, V> sibling,
+    private DeleteResult<K, V> borrowFromRight( Tuple<K, V> removedElement, long revision, Leaf<K, V> sibling,
         int pos )
         throws IOException
     {
@@ -373,7 +373,7 @@ import org.apache.directory.mavibot.btre
         siblingHolder = sibling.values[0];
 
         // Create the new sibling
-        PersistedLeaf<K, V> newSibling = new PersistedLeaf<K, V>( btree, revision, sibling.getNbElems() - 1 );
+        Leaf<K, V> newSibling = new Leaf<K, V>( btree, revision, sibling.getNbElems() - 1 );
 
         // Copy the keys and the values from 1 to N in the new sibling
         System.arraycopy( sibling.keys, 1, newSibling.keys, 0, sibling.nbElems - 1 );
@@ -381,10 +381,10 @@ import org.apache.directory.mavibot.btre
 
         // Create the new page and add the new element at the end
         // First copy the current page, with the same size
-        PersistedLeaf<K, V> newLeaf = new PersistedLeaf<K, V>( btree, revision, nbElems );
+        Leaf<K, V> newLeaf = new Leaf<K, V>( btree, revision, nbElems );
 
         // Insert the borrowed element at the end
-        newLeaf.keys[nbElems - 1] = new PersistedKeyHolder<K>( btree.getKeySerializer(), siblingKey );
+        newLeaf.keys[nbElems - 1] = new KeyHolderImpl<K>( btree.getKeySerializer(), siblingKey );
         newLeaf.values[nbElems - 1] = siblingHolder;
 
         // Copy the keys and the values up to the deletion position,
@@ -413,7 +413,7 @@ import org.apache.directory.mavibot.btre
      * @param pos The position into the page of the element to remove
      * @throws IOException If we have an error while trying to access the page
      */
-    private void copyAfterRemovingElement( V removedValue, PersistedLeaf<K, V> newLeaf, int pos )
+    private void copyAfterRemovingElement( V removedValue, Leaf<K, V> newLeaf, int pos )
         throws IOException
     {
         // Deal with the special case of a page with only one element by skipping
@@ -677,9 +677,53 @@ import org.apache.directory.mavibot.btre
      * @param nbElems The number of elements to copy
      * @return The copied page
      */
-    private Page<K, V> copy( long revision, int nbElems )
+    public Page<K, V> copy( long revision, int nbElems )
     {
-        PersistedLeaf<K, V> newLeaf = new PersistedLeaf<K, V>( btree, revision, nbElems );
+        Leaf<K, V> newLeaf = new Leaf<K, V>( btree, revision, nbElems );
+
+        // Copy the keys and the values
+        System.arraycopy( keys, 0, newLeaf.keys, 0, nbElems );
+
+        if ( values != null )
+        {
+            // It' not enough to copy the ValueHolder, we have to clone them
+            // as ValueHolders are mutable
+            int pos = 0;
+
+            for ( ValueHolder<V> valueHolder : values )
+            {
+                try
+                {
+                    newLeaf.values[pos++] = valueHolder.clone();
+                }
+                catch ( CloneNotSupportedException e )
+                {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+
+                // Stop when we have copied nbElems values
+                if ( pos == nbElems )
+                {
+                    break;
+                }
+            }
+        }
+
+        return newLeaf;
+    }
+
+
+    /**
+     * Copy the current page and all of the keys, values and children, if it's not a leaf.
+     *
+     * @param revision The new revision
+     * @param nbElems The number of elements to copy
+     * @return The copied page
+     */
+    public Page<K, V> copy( long revision )
+    {
+        Leaf<K, V> newLeaf = new Leaf<K, V>( btree, revision, nbElems );
 
         // Copy the keys and the values
         System.arraycopy( keys, 0, newLeaf.keys, 0, nbElems );
@@ -727,7 +771,7 @@ import org.apache.directory.mavibot.btre
     private InsertResult<K, V> replaceElement( long revision, K key, V value, int pos )
         throws IOException
     {
-        PersistedLeaf<K, V> newLeaf = this;
+        Leaf<K, V> newLeaf = this;
 
         // Get the previous value from the leaf (it's a copy)
         ValueHolder<V> valueHolder = values[pos];
@@ -737,7 +781,7 @@ import org.apache.directory.mavibot.btre
         if ( this.revision != revision )
         {
             // The page hasn't been modified yet, we need to copy it first
-            newLeaf = ( PersistedLeaf<K, V> ) copy( revision, nbElems );
+            newLeaf = ( Leaf<K, V> ) copy( revision, nbElems );
         }
 
         // Get the previous value from the leaf (it's a copy)
@@ -779,12 +823,12 @@ import org.apache.directory.mavibot.btre
     private Page<K, V> addElement( long revision, K key, V value, int pos )
     {
         // Create the value holder
-        ValueHolder<V> valueHolder = new PersistedValueHolder<V>( btree, value );
+        ValueHolder<V> valueHolder = new ValueHolderImpl<V>( btree, value );
 
         // Deal with the special case of an empty page
         if ( nbElems == 0 )
         {
-            keys[0] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+            keys[0] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
             values[0] = valueHolder;
         }
         else
@@ -795,7 +839,7 @@ import org.apache.directory.mavibot.btre
             System.arraycopy( values, pos, values, pos + 1, nbElementToMove );
 
             // Add the new element
-            keys[pos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+            keys[pos] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
             values[pos] = valueHolder;
         }
 
@@ -823,22 +867,22 @@ import org.apache.directory.mavibot.btre
     private InsertResult<K, V> addAndSplit( long revision, K key, V value, int pos )
     {
         int middle = btree.getPageSize() >> 1;
-        PersistedLeaf<K, V> leftLeaf = null;
-        PersistedLeaf<K, V> rightLeaf = null;
-        ValueHolder<V> valueHolder = new PersistedValueHolder<V>( btree, value );
+        Leaf<K, V> leftLeaf = null;
+        Leaf<K, V> rightLeaf = null;
+        ValueHolder<V> valueHolder = new ValueHolderImpl<V>( btree, value );
 
         // Determinate where to store the new value
         if ( pos <= middle )
         {
             // The left page will contain the new value
-            leftLeaf = new PersistedLeaf<K, V>( btree, revision, middle + 1 );
+            leftLeaf = new Leaf<K, V>( btree, revision, middle + 1 );
 
             // Copy the keys and the values up to the insertion position
             System.arraycopy( keys, 0, leftLeaf.keys, 0, pos );
             System.arraycopy( values, 0, leftLeaf.values, 0, pos );
 
             // Add the new element
-            leftLeaf.keys[pos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+            leftLeaf.keys[pos] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
             leftLeaf.values[pos] = valueHolder;
 
             // And copy the remaining elements
@@ -846,7 +890,7 @@ import org.apache.directory.mavibot.btre
             System.arraycopy( values, pos, leftLeaf.values, pos + 1, middle - pos );
 
             // Now, create the right page
-            rightLeaf = new PersistedLeaf<K, V>( btree, revision, middle );
+            rightLeaf = new Leaf<K, V>( btree, revision, middle );
 
             // Copy the keys and the values in the right page
             System.arraycopy( keys, middle, rightLeaf.keys, 0, middle );
@@ -855,14 +899,14 @@ import org.apache.directory.mavibot.btre
         else
         {
             // Create the left page
-            leftLeaf = new PersistedLeaf<K, V>( btree, revision, middle );
+            leftLeaf = new Leaf<K, V>( btree, revision, middle );
 
             // Copy all the element into the left page
             System.arraycopy( keys, 0, leftLeaf.keys, 0, middle );
             System.arraycopy( values, 0, leftLeaf.values, 0, middle );
 
             // Now, create the right page
-            rightLeaf = new PersistedLeaf<K, V>( btree, revision, middle + 1 );
+            rightLeaf = new Leaf<K, V>( btree, revision, middle + 1 );
 
             int rightPos = pos - middle;
 
@@ -871,7 +915,7 @@ import org.apache.directory.mavibot.btre
             System.arraycopy( values, middle, rightLeaf.values, 0, rightPos );
 
             // Add the new element
-            rightLeaf.keys[rightPos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+            rightLeaf.keys[rightPos] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
             rightLeaf.values[rightPos] = valueHolder;
 
             // And copy the remaining elements
@@ -1004,12 +1048,12 @@ import org.apache.directory.mavibot.btre
     private Page<K, V> addSubTreeElement( long revision, K key, int pos )
     {
         // First copy the current page, but add one element in the copied page
-        PersistedLeaf<K, V> newLeaf = new PersistedLeaf<K, V>( btree, revision, nbElems + 1 );
+        Leaf<K, V> newLeaf = new Leaf<K, V>( btree, revision, nbElems + 1 );
 
         // Deal with the special case of an empty page
         if ( nbElems == 0 )
         {
-            newLeaf.keys[0] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+            newLeaf.keys[0] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
         }
         else
         {
@@ -1017,7 +1061,7 @@ import org.apache.directory.mavibot.btre
             System.arraycopy( keys, 0, newLeaf.keys, 0, pos );
 
             // Add the new element
-            newLeaf.keys[pos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+            newLeaf.keys[pos] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
 
             // And copy the remaining elements
             System.arraycopy( keys, pos, newLeaf.keys, pos + 1, keys.length - pos );
@@ -1034,26 +1078,26 @@ import org.apache.directory.mavibot.btre
     private InsertResult<K, V> addAndSplitSubTree( long revision, K key, int pos )
     {
         int middle = btree.getPageSize() >> 1;
-        PersistedLeaf<K, V> leftLeaf = null;
-        PersistedLeaf<K, V> rightLeaf = null;
+        Leaf<K, V> leftLeaf = null;
+        Leaf<K, V> rightLeaf = null;
 
         // Determinate where to store the new value
         if ( pos <= middle )
         {
             // The left page will contain the new value
-            leftLeaf = new PersistedLeaf<K, V>( btree, revision, middle + 1 );
+            leftLeaf = new Leaf<K, V>( btree, revision, middle + 1 );
 
             // Copy the keys and the values up to the insertion position
             System.arraycopy( keys, 0, leftLeaf.keys, 0, pos );
 
             // Add the new element
-            leftLeaf.keys[pos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+            leftLeaf.keys[pos] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
 
             // And copy the remaining elements
             System.arraycopy( keys, pos, leftLeaf.keys, pos + 1, middle - pos );
 
             // Now, create the right page
-            rightLeaf = new PersistedLeaf<K, V>( btree, revision, middle );
+            rightLeaf = new Leaf<K, V>( btree, revision, middle );
 
             // Copy the keys and the values in the right page
             System.arraycopy( keys, middle, rightLeaf.keys, 0, middle );
@@ -1061,13 +1105,13 @@ import org.apache.directory.mavibot.btre
         else
         {
             // Create the left page
-            leftLeaf = new PersistedLeaf<K, V>( btree, revision, middle );
+            leftLeaf = new Leaf<K, V>( btree, revision, middle );
 
             // Copy all the element into the left page
             System.arraycopy( keys, 0, leftLeaf.keys, 0, middle );
 
             // Now, create the right page
-            rightLeaf = new PersistedLeaf<K, V>( btree, revision, middle + 1 );
+            rightLeaf = new Leaf<K, V>( btree, revision, middle + 1 );
 
             int rightPos = pos - middle;
 
@@ -1075,7 +1119,7 @@ import org.apache.directory.mavibot.btre
             System.arraycopy( keys, middle, rightLeaf.keys, 0, rightPos );
 
             // Add the new element
-            rightLeaf.keys[rightPos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+            rightLeaf.keys[rightPos] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
 
             // And copy the remaining elements
             System.arraycopy( keys, pos, rightLeaf.keys, rightPos + 1, nbElems - pos );

Modified: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/MavibotInspector.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/MavibotInspector.java?rev=1722426&r1=1722425&r2=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/MavibotInspector.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/MavibotInspector.java Thu Dec 31 08:49:03 2015
@@ -203,7 +203,7 @@ public class MavibotInspector
         System.out.print( "BTree Name: " );
         String name = readLine();
 
-        PersistedBTree<?, ?> pb = ( PersistedBTree<?, ?> ) rm.getManagedTree( name );
+        BTreeImpl<?, ?> pb = ( BTreeImpl<?, ?> ) rm.getManagedTree( name );
 
         if ( pb == null )
         {

Copied: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Node.java (from r1706445, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedNode.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Node.java?p2=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Node.java&p1=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedNode.java&r1=1706445&r2=1722426&rev=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedNode.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Node.java Thu Dec 31 08:49:03 2015
@@ -34,7 +34,7 @@ import java.util.List;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/* No qualifier */class PersistedNode<K, V> extends AbstractPage<K, V>
+/* No qualifier */class Node<K, V> extends AbstractPage<K, V>
 {
     /**
      * Creates a new Node which will contain only one key, with references to
@@ -46,12 +46,12 @@ import java.util.List;
      * @param nbElems The number of elements in this Node
      */
     @SuppressWarnings("unchecked")
-    PersistedNode( BTree<K, V> btree, long revision, int nbElems )
+    Node( BTree<K, V> btree, long revision, int nbElems )
     {
         super( btree, revision, nbElems );
 
         // Create the children array
-        children = ( PersistedPageHolder<K, V>[] ) Array.newInstance( PersistedPageHolder.class, nbElems + 1 );
+        children = ( PageHolderImpl<K, V>[] ) Array.newInstance( PageHolderImpl.class, nbElems + 1 );
     }
 
 
@@ -67,23 +67,23 @@ import java.util.List;
      * @param rightPage The right page
      */
     @SuppressWarnings("unchecked")
-    PersistedNode( BTree<K, V> btree, long revision, K key, Page<K, V> leftPage, Page<K, V> rightPage )
+    Node( BTree<K, V> btree, long revision, K key, Page<K, V> leftPage, Page<K, V> rightPage )
     {
         super( btree, revision, 1 );
 
         // Create the children array, and store the left and right children
-        children = ( PersistedPageHolder<K, V>[] ) Array.newInstance( PersistedPageHolder.class,
+        children = ( PageHolderImpl<K, V>[] ) Array.newInstance( PageHolderImpl.class,
             btree.getPageSize() + 1 );
 
-        children[0] = new PersistedPageHolder<K, V>( btree, leftPage );
-        children[1] = new PersistedPageHolder<K, V>( btree, rightPage );
+        children[0] = new PageHolderImpl<K, V>( btree, leftPage );
+        children[1] = new PageHolderImpl<K, V>( btree, rightPage );
 
         // Create the keys array and store the pivot into it
         // We get the type of array to create from the btree
         // Yes, this is an hack...
-        keys = ( KeyHolder<K>[] ) Array.newInstance( PersistedKeyHolder.class, btree.getPageSize() );
+        keys = ( KeyHolder<K>[] ) Array.newInstance( KeyHolderImpl.class, btree.getPageSize() );
 
-        keys[0] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+        keys[0] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
     }
 
 
@@ -99,7 +99,7 @@ import java.util.List;
      * @param rightPage The right page
      */
     @SuppressWarnings("unchecked")
-    PersistedNode( BTree<K, V> btree, long revision, K key, PageHolder<K, V> leftPage, PageHolder<K, V> rightPage )
+    Node( BTree<K, V> btree, long revision, K key, PageHolder<K, V> leftPage, PageHolder<K, V> rightPage )
     {
         super( btree, revision, 1 );
 
@@ -113,7 +113,7 @@ import java.util.List;
         // Create the keys array and store the pivot into it
         keys = ( KeyHolder[] ) Array.newInstance( KeyHolder.class, btree.getPageSize() );
 
-        keys[0] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+        keys[0] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
     }
 
 
@@ -194,7 +194,7 @@ import java.util.List;
         // Simplest case : the element has been removed from the underlying page,
         // we just have to copy the current page an modify the reference to link to
         // the modified page.
-        PersistedNode<K, V> newPage = copy( revision );
+        Node<K, V> newPage = copy( revision );
 
         Page<K, V> modifiedPage = removeResult.getModifiedPage();
 
@@ -266,10 +266,10 @@ import java.util.List;
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> borrowFromRight( long revision, MergedWithSiblingResult<K, V> mergedResult,
-        PersistedNode<K, V> sibling, int pos ) throws IOException
+        Node<K, V> sibling, int pos ) throws IOException
     {
         // Create the new sibling, with one less element at the beginning
-        PersistedNode<K, V> newSibling = new PersistedNode<K, V>( btree, revision, sibling.getNbElems() - 1 );
+        Node<K, V> newSibling = new Node<K, V>( btree, revision, sibling.getNbElems() - 1 );
 
         K siblingKey = sibling.children[0].getValue().getLeftMostKey();
 
@@ -279,13 +279,13 @@ import java.util.List;
 
         // Create the new page and add the new element at the end
         // First copy the current node, with the same size
-        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision, nbElems );
+        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems );
 
         // Copy the keys and the values up to the insertion position
         int index = Math.abs( pos );
 
         // Copy the key and children from sibling
-        newNode.keys[nbElems - 1] = new PersistedKeyHolder<K>( btree.getKeySerializer(), siblingKey ); // 1
+        newNode.keys[nbElems - 1] = new KeyHolderImpl<K>( btree.getKeySerializer(), siblingKey ); // 1
         newNode.children[nbElems] = sibling.children[0]; // 8
 
         if ( index < 2 )
@@ -309,7 +309,7 @@ import java.util.List;
             }
 
             // Inject the new modified page key
-            newNode.keys[index - 2] = new PersistedKeyHolder<K>( btree.getKeySerializer(), mergedResult
+            newNode.keys[index - 2] = new KeyHolderImpl<K>( btree.getKeySerializer(), mergedResult
                 .getModifiedPage()
                 .getLeftMostKey() ); // 2
 
@@ -353,13 +353,13 @@ import java.util.List;
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> borrowFromLeft( long revision, MergedWithSiblingResult<K, V> mergedResult,
-        PersistedNode<K, V> sibling, int pos ) throws IOException
+        Node<K, V> sibling, int pos ) throws IOException
     {
         // The sibling is on the left, borrow the rightmost element
         Page<K, V> siblingChild = sibling.children[sibling.nbElems].getValue();
 
         // Create the new sibling, with one less element at the end
-        PersistedNode<K, V> newSibling = new PersistedNode<K, V>( btree, revision, sibling.getNbElems() - 1 );
+        Node<K, V> newSibling = new Node<K, V>( btree, revision, sibling.getNbElems() - 1 );
 
         // Copy the keys and children of the old sibling in the new sibling
         System.arraycopy( sibling.keys, 0, newSibling.keys, 0, newSibling.getNbElems() );
@@ -367,7 +367,7 @@ import java.util.List;
 
         // Create the new page and add the new element at the beginning
         // First copy the current node, with the same size
-        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision, nbElems );
+        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems );
 
         // Sets the first children
         newNode.children[0] = createHolder( siblingChild ); //1
@@ -376,7 +376,7 @@ import java.util.List;
 
         if ( index < 2 )
         {
-            newNode.keys[0] = new PersistedKeyHolder<K>( btree.getKeySerializer(), mergedResult.getModifiedPage()
+            newNode.keys[0] = new KeyHolderImpl<K>( btree.getKeySerializer(), mergedResult.getModifiedPage()
                 .getLeftMostKey() );
             System.arraycopy( keys, 1, newNode.keys, 1, nbElems - 1 );
 
@@ -387,7 +387,7 @@ import java.util.List;
         else
         {
             // Set the first key
-            newNode.keys[0] = new PersistedKeyHolder<K>( btree.getKeySerializer(), children[0].getValue()
+            newNode.keys[0] = new KeyHolderImpl<K>( btree.getKeySerializer(), children[0].getValue()
                 .getLeftMostKey() ); //2
 
             if ( index > 2 )
@@ -397,7 +397,7 @@ import java.util.List;
             }
 
             // Inject the modified key
-            newNode.keys[index - 1] = new PersistedKeyHolder<K>( btree.getKeySerializer(), mergedResult
+            newNode.keys[index - 1] = new KeyHolderImpl<K>( btree.getKeySerializer(), mergedResult
                 .getModifiedPage()
                 .getLeftMostKey() ); // 3
 
@@ -443,11 +443,11 @@ import java.util.List;
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> mergeWithSibling( long revision, MergedWithSiblingResult<K, V> mergedResult,
-        PersistedNode<K, V> sibling, boolean isLeft, int pos ) throws IOException
+        Node<K, V> sibling, boolean isLeft, int pos ) throws IOException
     {
         // Create the new node. It will contain N - 1 elements (the maximum number)
         // as we merge two nodes that contain N/2 elements minus the one we remove
-        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision, btree.getPageSize() );
+        Node<K, V> newNode = new Node<K, V>( btree, revision, btree.getPageSize() );
         Tuple<K, V> removedElement = mergedResult.getRemovedElement();
         int half = btree.getPageSize() / 2;
         int index = Math.abs( pos );
@@ -461,7 +461,7 @@ import java.util.List;
             // Then copy all the elements up to the deletion point
             if ( index < 2 )
             {
-                newNode.keys[half] = new PersistedKeyHolder<K>( btree.getKeySerializer(), mergedResult
+                newNode.keys[half] = new KeyHolderImpl<K>( btree.getKeySerializer(), mergedResult
                     .getModifiedPage()
                     .getLeftMostKey() );
                 System.arraycopy( keys, 1, newNode.keys, half + 1, half - 1 );
@@ -474,7 +474,7 @@ import java.util.List;
             {
                 // Copy the left part of the node keys up to the deletion point
                 // Insert the new key
-                newNode.keys[half] = new PersistedKeyHolder<K>( btree.getKeySerializer(), children[0].getValue()
+                newNode.keys[half] = new KeyHolderImpl<K>( btree.getKeySerializer(), children[0].getValue()
                     .getLeftMostKey() ); // 3
 
                 if ( index > 2 )
@@ -483,7 +483,7 @@ import java.util.List;
                 }
 
                 // Inject the new merged key
-                newNode.keys[half + index - 1] = new PersistedKeyHolder<K>( btree.getKeySerializer(), mergedResult
+                newNode.keys[half + index - 1] = new KeyHolderImpl<K>( btree.getKeySerializer(), mergedResult
                     .getModifiedPage().getLeftMostKey() ); //5
 
                 if ( index < half )
@@ -528,7 +528,7 @@ import java.util.List;
                 System.arraycopy( children, 0, newNode.children, 0, index - 1 ); //6
 
                 // Inject the modified key
-                newNode.keys[index - 2] = new PersistedKeyHolder<K>( btree.getKeySerializer(), mergedResult
+                newNode.keys[index - 2] = new KeyHolderImpl<K>( btree.getKeySerializer(), mergedResult
                     .getModifiedPage()
                     .getLeftMostKey() ); //2
 
@@ -547,7 +547,7 @@ import java.util.List;
             }
 
             // Inject the new key from sibling
-            newNode.keys[half - 1] = new PersistedKeyHolder<K>( btree.getKeySerializer(), sibling.findLeftMost()
+            newNode.keys[half - 1] = new KeyHolderImpl<K>( btree.getKeySerializer(), sibling.findLeftMost()
                 .getKey() ); //3
 
             // Copy the sibling keys
@@ -654,7 +654,7 @@ import java.util.List;
                 // a sibling, or we will have to merge two pages
                 int siblingPos = selectSibling( parent, parentPos );
 
-                PersistedNode<K, V> sibling = ( PersistedNode<K, V> ) ( ( ( PersistedNode<K, V> ) parent ).children[siblingPos]
+                Node<K, V> sibling = ( Node<K, V> ) ( ( ( Node<K, V> ) parent ).children[siblingPos]
                     .getValue() );
 
                 if ( sibling.getNbElems() > halfSize )
@@ -705,7 +705,7 @@ import java.util.List;
         Page<K, V> modifiedPage = borrowedResult.getModifiedPage();
         Page<K, V> modifiedSibling = borrowedResult.getModifiedSibling();
 
-        PersistedNode<K, V> newPage = copy( revision );
+        Node<K, V> newPage = copy( revision );
 
         if ( pos < 0 )
         {
@@ -714,9 +714,9 @@ import java.util.List;
             if ( borrowedResult.isFromRight() )
             {
                 // Update the keys
-                newPage.keys[pos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), modifiedPage.findLeftMost()
+                newPage.keys[pos] = new KeyHolderImpl<K>( btree.getKeySerializer(), modifiedPage.findLeftMost()
                     .getKey() );
-                newPage.keys[pos + 1] = new PersistedKeyHolder<K>( btree.getKeySerializer(), modifiedSibling
+                newPage.keys[pos + 1] = new KeyHolderImpl<K>( btree.getKeySerializer(), modifiedSibling
                     .findLeftMost()
                     .getKey() );
 
@@ -727,7 +727,7 @@ import java.util.List;
             else
             {
                 // Update the keys
-                newPage.keys[pos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), modifiedPage.findLeftMost()
+                newPage.keys[pos] = new KeyHolderImpl<K>( btree.getKeySerializer(), modifiedPage.findLeftMost()
                     .getKey() );
 
                 // Update the children
@@ -740,7 +740,7 @@ import java.util.List;
             if ( borrowedResult.isFromRight() )
             {
                 // Update the keys
-                newPage.keys[pos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), modifiedSibling.findLeftMost()
+                newPage.keys[pos] = new KeyHolderImpl<K>( btree.getKeySerializer(), modifiedSibling.findLeftMost()
                     .getKey() );
 
                 // Update the children
@@ -750,7 +750,7 @@ import java.util.List;
             else
             {
                 // Update the keys
-                newPage.keys[pos - 1] = new PersistedKeyHolder<K>( btree.getKeySerializer(), modifiedPage
+                newPage.keys[pos - 1] = new KeyHolderImpl<K>( btree.getKeySerializer(), modifiedPage
                     .findLeftMost()
                     .getKey() );
 
@@ -783,7 +783,7 @@ import java.util.List;
         throws IOException
     {
         // First copy the current page, but remove one element in the copied page
-        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision, nbElems - 1 );
+        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems - 1 );
 
         int index = Math.abs( pos ) - 2;
 
@@ -804,7 +804,7 @@ import java.util.List;
                 System.arraycopy( keys, 0, newNode.keys, 0, index );
             }
 
-            newNode.keys[index] = new PersistedKeyHolder<K>( btree.getKeySerializer(), mergedResult.getModifiedPage()
+            newNode.keys[index] = new KeyHolderImpl<K>( btree.getKeySerializer(), mergedResult.getModifiedPage()
                 .findLeftMost().getKey() );
 
             if ( index < nbElems - 2 )
@@ -856,7 +856,7 @@ import java.util.List;
      * @param pos The position in the values array
      * @param value the value to inject
      */
-    /* no qualifier */void setValue( int pos, PersistedPageHolder<K, V> value )
+    /* no qualifier */void setValue( int pos, PageHolderImpl<K, V> value )
     {
         children[pos] = value;
     }
@@ -882,7 +882,7 @@ import java.util.List;
         // to point on the modified child
         Page<K, V> modifiedPage = result.getModifiedPage();
 
-        ( ( PersistedNode<K, V> ) newPage ).children[pos] = createHolder( modifiedPage );
+        ( ( Node<K, V> ) newPage ).children[pos] = createHolder( modifiedPage );
 
         // We can return the result, where we update the modifiedPage,
         // to avoid the creation of a new object
@@ -903,7 +903,7 @@ import java.util.List;
      */
     private PageHolder<K, V> createHolder( Page<K, V> page ) throws IOException
     {
-        PageHolder<K, V> holder = ( ( PersistedBTree<K, V> ) btree ).getRecordManager().writePage( btree,
+        PageHolder<K, V> holder = ( ( BTreeImpl<K, V> ) btree ).getRecordManager().writePage( btree,
             page,
             revision );
 
@@ -929,7 +929,7 @@ import java.util.List;
         throws IOException
     {
         // First copy the current page, but add one element in the copied page
-        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision, nbElems + 1 );
+        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems + 1 );
 
         // Copy the keys and the children up to the insertion position
         if ( nbElems > 0 )
@@ -939,7 +939,7 @@ import java.util.List;
         }
 
         // Add the new key and children
-        newNode.keys[pos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), key );
+        newNode.keys[pos] = new KeyHolderImpl<K>( btree.getKeySerializer(), key );
 
         // If the BTree is managed, we now have to write the modified page on disk
         // and to add this page to the list of modified pages
@@ -985,8 +985,8 @@ import java.util.List;
         int middle = btree.getPageSize() >> 1;
 
         // Create two new pages
-        PersistedNode<K, V> newLeftPage = new PersistedNode<K, V>( btree, revision, middle );
-        PersistedNode<K, V> newRightPage = new PersistedNode<K, V>( btree, revision, middle );
+        Node<K, V> newLeftPage = new Node<K, V>( btree, revision, middle );
+        Node<K, V> newRightPage = new Node<K, V>( btree, revision, middle );
 
         // Determinate where to store the new value
         // If it's before the middle, insert the value on the left,
@@ -998,7 +998,7 @@ import java.util.List;
             System.arraycopy( children, 0, newLeftPage.children, 0, pos );
 
             // Add the new element
-            newLeftPage.keys[pos] = new PersistedKeyHolder<K>( btree.getKeySerializer(), pivot );
+            newLeftPage.keys[pos] = new KeyHolderImpl<K>( btree.getKeySerializer(), pivot );
             newLeftPage.children[pos] = createHolder( leftPage );
             newLeftPage.children[pos + 1] = createHolder( rightPage );
 
@@ -1055,7 +1055,7 @@ import java.util.List;
             System.arraycopy( children, middle + 1, newRightPage.children, 0, pos - middle - 1 );
 
             // Add the new element
-            newRightPage.keys[pos - middle - 1] = new PersistedKeyHolder<K>( btree.getKeySerializer(), pivot );
+            newRightPage.keys[pos - middle - 1] = new KeyHolderImpl<K>( btree.getKeySerializer(), pivot );
             newRightPage.children[pos - middle - 1] = createHolder( leftPage );
             newRightPage.children[pos - middle] = createHolder( rightPage );
 
@@ -1086,9 +1086,9 @@ import java.util.List;
      * @param revision The new revision
      * @return The copied page
      */
-    protected PersistedNode<K, V> copy( long revision )
+    public Node<K, V> copy( long revision )
     {
-        PersistedNode<K, V> newPage = new PersistedNode<K, V>( btree, revision, nbElems );
+        Node<K, V> newPage = new Node<K, V>( btree, revision, nbElems );
 
         // Copy the keys
         System.arraycopy( keys, 0, newPage.keys, 0, nbElems );

Modified: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java?rev=1722426&r1=1722425&r2=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java Thu Dec 31 08:49:03 2015
@@ -121,6 +121,15 @@ import org.apache.directory.mavibot.btre
      */
     boolean contains( K key, V value ) throws IOException;
 
+    
+    /**
+     * Copies the current page and all its keys, with a new revision.
+     *
+     * @param revision The new revision
+     * @return The copied page
+     */
+    Page<K, V> copy( long revision );
+
 
     /**
      * Browses the tree, looking for the given key, and creates a Cursor on top

Copied: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageHolderImpl.java (from r1706445, directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedPageHolder.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageHolderImpl.java?p2=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageHolderImpl.java&p1=directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedPageHolder.java&r1=1706445&r2=1722426&rev=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedPageHolder.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageHolderImpl.java Thu Dec 31 08:49:03 2015
@@ -38,7 +38,7 @@ import org.apache.directory.mavibot.btre
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/* No qualifier */class PersistedPageHolder<K, V> extends PageHolder<K, V>
+/* No qualifier */class PageHolderImpl<K, V> extends PageHolder<K, V>
 {
     /** The RecordManager */
     private RecordManager recordManager;
@@ -58,12 +58,12 @@ import org.apache.directory.mavibot.btre
      *
      * @param page The element to store into a SoftReference
      */
-    public PersistedPageHolder( BTree<K, V> btree, Page<K, V> page )
+    public PageHolderImpl( BTree<K, V> btree, Page<K, V> page )
     {
         // DO NOT keep the reference to Page, it will be fetched from cache when needed 
         super( btree, null );
-        cache = ( ( PersistedBTree<K, V> ) btree ).getCache();
-        recordManager = ( ( PersistedBTree<K, V> ) btree ).getRecordManager();
+        cache = ( ( BTreeImpl<K, V> ) btree ).getCache();
+        recordManager = ( ( BTreeImpl<K, V> ) btree ).getRecordManager();
         offset = ( ( AbstractPage<K, V> ) page ).getOffset();
         lastOffset = ( ( AbstractPage<K, V> ) page ).getLastOffset();
 
@@ -79,12 +79,12 @@ import org.apache.directory.mavibot.btre
      *
      * @param page The element to store into a SoftReference
      */
-    public PersistedPageHolder( BTree<K, V> btree, Page<K, V> page, long offset, long lastOffset )
+    public PageHolderImpl( BTree<K, V> btree, Page<K, V> page, long offset, long lastOffset )
     {
         // DO NOT keep the reference to Page, it will be fetched from cache when needed
         super( btree, null );
-        cache = ( ( PersistedBTree<K, V> ) btree ).getCache();
-        recordManager = ( ( PersistedBTree<K, V> ) btree ).getRecordManager();
+        cache = ( ( BTreeImpl<K, V> ) btree ).getCache();
+        recordManager = ( ( BTreeImpl<K, V> ) btree ).getRecordManager();
         this.offset = offset;
         this.lastOffset = lastOffset;
 

Modified: directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageReclaimer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageReclaimer.java?rev=1722426&r1=1722425&r2=1722426&view=diff
==============================================================================
--- directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageReclaimer.java (original)
+++ directory/mavibot/branches/single-value/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageReclaimer.java Thu Dec 31 08:49:03 2015
@@ -77,7 +77,7 @@ public class PageReclaimer
 
             for ( String name : managed )
             {
-                PersistedBTree tree = ( PersistedBTree ) rm.getManagedTree( name );
+                BTreeImpl tree = ( BTreeImpl ) rm.getManagedTree( name );
 
                 long latestRev = tree.getRevision();
                 



Mime
View raw message