directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1551280 - in /directory/mavibot/trunk/mavibot/src: main/java/org/apache/directory/mavibot/btree/memory/ main/java/org/apache/directory/mavibot/btree/persisted/ test/java/org/apache/directory/mavibot/btree/memory/
Date Mon, 16 Dec 2013 17:40:44 GMT
Author: elecharny
Date: Mon Dec 16 17:40:44 2013
New Revision: 1551280

URL: http://svn.apache.org/r1551280
Log:
Renamed the Node classes to InMemoryNode and PersistedNode

Added:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryNode.java
      - copied, changed from r1551277, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Node.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedNode.java
      - copied, changed from r1551277, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/Node.java
Removed:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Node.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/Node.java
Modified:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTree.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeBuilder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryLeaf.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/BTreeFactory.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTree.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTreeBuilder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedLeaf.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/RecordManager.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/LeafTest.java

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeFactory.java
Mon Dec 16 17:40:44 2013
@@ -64,9 +64,9 @@ public class BTreeFactory
      * @param nbElems The number or elements in this node
      * @return A Node instance
      */
-    public static <K, V> Node<K, V> createNode( BTree<K, V> btree, long
revision, int nbElems )
+    public static <K, V> InMemoryNode<K, V> createNode( BTree<K, V> btree,
long revision, int nbElems )
     {
-        Node<K, V> node = new Node<K, V>( btree, revision, nbElems );
+        InMemoryNode<K, V> node = new InMemoryNode<K, V>( btree, revision, nbElems
);
 
         return node;
     }
@@ -216,7 +216,7 @@ public class BTreeFactory
      * @param pos The position in the values array
      * @param value the value to inject
      */
-    public static <K, V> void setValue( BTree<K, V> btree, Node<K, V> page,
int pos, Page<K, V> value )
+    public static <K, V> void setValue( BTree<K, V> btree, InMemoryNode<K,
V> page, int pos, Page<K, V> value )
     {
         page.setPageHolder( pos, new PageHolder<K, V>( btree, value ) );
     }
@@ -244,7 +244,7 @@ public class BTreeFactory
         }
         else
         {
-            Node<K, V> node = ( Node<K, V> ) btree.getRootPage();
+            InMemoryNode<K, V> node = ( InMemoryNode<K, V> ) btree.getRootPage();
 
             while ( true )
             {

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTree.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTree.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTree.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTree.java
Mon Dec 16 17:40:44 2013
@@ -499,7 +499,7 @@ public class InMemoryBTree<K, V> extends
             Page<K, V> newRootPage = null;
 
             // Create the new rootPage
-            newRootPage = new Node<K, V>( this, revision, pivot, leftPage, rightPage
);
+            newRootPage = new InMemoryNode<K, V>( this, revision, pivot, leftPage,
rightPage );
 
             rootPage = newRootPage;
         }

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeBuilder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeBuilder.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeBuilder.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeBuilder.java
Mon Dec 16 17:40:44 2013
@@ -150,7 +150,7 @@ public class InMemoryBTreeBuilder<K, V>
 
         int numChildren = numKeysInNode + 1;
 
-        Node<K, V> node = createNode( btree, 0, numKeysInNode );
+        InMemoryNode<K, V> node = createNode( btree, 0, numKeysInNode );
         lstNodes.add( node );
         int i = 0;
         int totalNodes = 0;

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryLeaf.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryLeaf.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryLeaf.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryLeaf.java
Mon Dec 16 17:40:44 2013
@@ -232,8 +232,8 @@ import org.apache.directory.mavibot.btre
                 // if it has more than N/2 elements, or to merge the two pages.
                 // 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( ( Node<K, V> ) parent, parentPos );
-                InMemoryLeaf<K, V> sibling = ( InMemoryLeaf<K, V> ) ( ( ( Node<K,
V> ) parent ).getPage( siblingPos ) );
+                int siblingPos = selectSibling( ( InMemoryNode<K, V> ) parent, parentPos
);
+                InMemoryLeaf<K, V> sibling = ( InMemoryLeaf<K, V> ) ( ( ( InMemoryNode<K,
V> ) parent ).getPage( siblingPos ) );
 
                 if ( sibling.getNbElems() == halfSize )
                 {

Copied: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryNode.java
(from r1551277, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Node.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryNode.java?p2=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryNode.java&p1=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Node.java&r1=1551277&r2=1551280&rev=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Node.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InMemoryNode.java
Mon Dec 16 17:40:44 2013
@@ -50,7 +50,7 @@ import org.apache.directory.mavibot.btre
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/* No qualifier */class Node<K, V> extends AbstractPage<K, V>
+/* No qualifier */class InMemoryNode<K, V> extends AbstractPage<K, V>
 {
     /**
      * Creates a new Node which will contain only one key, with references to
@@ -62,7 +62,7 @@ import org.apache.directory.mavibot.btre
      * @param nbElems The number of elements in this Node
      */
     @SuppressWarnings("unchecked")
-    /* No qualifier */Node( BTree<K, V> btree, long revision, int nbElems )
+    InMemoryNode( BTree<K, V> btree, long revision, int nbElems )
     {
         super( btree, revision, nbElems );
 
@@ -83,7 +83,7 @@ import org.apache.directory.mavibot.btre
      * @param rightPage The right page
      */
     @SuppressWarnings("unchecked")
-    /* No qualifier */Node( BTree<K, V> btree, long revision, K key, Page<K, V>
leftPage, Page<K, V> rightPage )
+    InMemoryNode( BTree<K, V> btree, long revision, K key, Page<K, V> leftPage,
Page<K, V> rightPage )
     {
         super( btree, revision, 1 );
 
@@ -175,7 +175,7 @@ import org.apache.directory.mavibot.btre
         // 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.
-        Node<K, V> newPage = copy( revision );
+        InMemoryNode<K, V> newPage = copy( revision );
 
         Page<K, V> modifiedPage = removeResult.getModifiedPage();
 
@@ -247,10 +247,10 @@ import org.apache.directory.mavibot.btre
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> borrowFromRight( long revision, MergedWithSiblingResult<K,
V> mergedResult,
-        Node<K, V> sibling, int pos ) throws IOException
+        InMemoryNode<K, V> sibling, int pos ) throws IOException
     {
         // Create the new sibling, with one less element at the beginning
-        Node<K, V> newSibling = new Node<K, V>( btree, revision, sibling.getNbElems()
- 1 );
+        InMemoryNode<K, V> newSibling = new InMemoryNode<K, V>( btree, revision,
sibling.getNbElems() - 1 );
 
         K siblingKey = sibling.children[0].getValue().getLeftMostKey();
 
@@ -260,7 +260,7 @@ import org.apache.directory.mavibot.btre
 
         // Create the new page and add the new element at the end
         // First copy the current node, with the same size
-        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems );
+        InMemoryNode<K, V> newNode = new InMemoryNode<K, V>( btree, revision,
nbElems );
 
         // Copy the keys and the values up to the insertion position
         int index = Math.abs( pos );
@@ -332,13 +332,13 @@ import org.apache.directory.mavibot.btre
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> borrowFromLeft( long revision, MergedWithSiblingResult<K,
V> mergedResult,
-        Node<K, V> sibling, int pos ) throws IOException
+        InMemoryNode<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
-        Node<K, V> newSibling = new Node<K, V>( btree, revision, sibling.getNbElems()
- 1 );
+        InMemoryNode<K, V> newSibling = new InMemoryNode<K, V>( btree, revision,
sibling.getNbElems() - 1 );
 
         // Copy the keys and children of the old sibling in the new sibling
         System.arraycopy( sibling.getKeys(), 0, newSibling.getKeys(), 0, newSibling.getNbElems()
);
@@ -346,7 +346,7 @@ import org.apache.directory.mavibot.btre
 
         // Create the new page and add the new element at the beginning
         // First copy the current node, with the same size
-        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems );
+        InMemoryNode<K, V> newNode = new InMemoryNode<K, V>( btree, revision,
nbElems );
 
         // Sets the first children
         newNode.children[0] = new PageHolder<K, V>( btree, siblingChild ); //1
@@ -418,11 +418,11 @@ import org.apache.directory.mavibot.btre
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> mergeWithSibling( long revision, MergedWithSiblingResult<K,
V> mergedResult,
-        Node<K, V> sibling, boolean isLeft, int pos ) throws IOException
+        InMemoryNode<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
-        Node<K, V> newNode = new Node<K, V>( btree, revision, btree.getPageSize()
);
+        InMemoryNode<K, V> newNode = new InMemoryNode<K, V>( btree, revision,
btree.getPageSize() );
         Tuple<K, V> removedElement = mergedResult.getRemovedElement();
         int half = btree.getPageSize() / 2;
         int index = Math.abs( pos );
@@ -620,9 +620,9 @@ import org.apache.directory.mavibot.btre
                 // We will remove one element from a page that will have less than N/2 elements,
                 // which will lead to some reorganization : either we can borrow an element
from
                 // a sibling, or we will have to merge two pages
-                int siblingPos = selectSibling( ( Node<K, V> ) parent, parentPos );
+                int siblingPos = selectSibling( ( InMemoryNode<K, V> ) parent, parentPos
);
 
-                Node<K, V> sibling = ( Node<K, V> ) ( ( ( Node<K, V> )
parent ).children[siblingPos].getValue() );
+                InMemoryNode<K, V> sibling = ( InMemoryNode<K, V> ) ( ( ( InMemoryNode<K,
V> ) parent ).children[siblingPos].getValue() );
 
                 if ( sibling.getNbElems() > halfSize )
                 {
@@ -672,7 +672,7 @@ import org.apache.directory.mavibot.btre
         Page<K, V> modifiedPage = borrowedResult.getModifiedPage();
         Page<K, V> modifiedSibling = borrowedResult.getModifiedSibling();
 
-        Node<K, V> newPage = copy( revision );
+        InMemoryNode<K, V> newPage = copy( revision );
 
         if ( pos < 0 )
         {
@@ -743,7 +743,7 @@ import org.apache.directory.mavibot.btre
         throws IOException
     {
         // First copy the current page, but remove one element in the copied page
-        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems - 1 );
+        InMemoryNode<K, V> newNode = new InMemoryNode<K, V>( btree, revision,
nbElems - 1 );
 
         int index = Math.abs( pos ) - 2;
 
@@ -825,7 +825,7 @@ import org.apache.directory.mavibot.btre
         // to point on the modified child
         Page<K, V> modifiedPage = result.getModifiedPage();
 
-        ( ( Node<K, V> ) newPage ).children[pos] = new PageHolder<K, V>( btree,
modifiedPage );
+        ( ( InMemoryNode<K, V> ) newPage ).children[pos] = new PageHolder<K, V>(
btree, modifiedPage );
 
         // We can return the result, where we update the modifiedPage,
         // to avoid the creation of a new object
@@ -855,7 +855,7 @@ import org.apache.directory.mavibot.btre
         throws IOException
     {
         // First copy the current page, but add one element in the copied page
-        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems + 1 );
+        InMemoryNode<K, V> newNode = new InMemoryNode<K, V>( btree, revision,
nbElems + 1 );
 
         // Copy the keys and the children up to the insertion position
         if ( nbElems > 0 )
@@ -911,8 +911,8 @@ import org.apache.directory.mavibot.btre
         int middle = btree.getPageSize() >> 1;
 
         // Create two new pages
-        Node<K, V> newLeftPage = new Node<K, V>( btree, revision, middle );
-        Node<K, V> newRightPage = new Node<K, V>( btree, revision, middle );
+        InMemoryNode<K, V> newLeftPage = new InMemoryNode<K, V>( btree, revision,
middle );
+        InMemoryNode<K, V> newRightPage = new InMemoryNode<K, V>( btree, revision,
middle );
 
         // Determinate where to store the new value
         // If it's before the middle, insert the value on the left,
@@ -996,9 +996,9 @@ import org.apache.directory.mavibot.btre
      * @param revision The new revision
      * @return The copied page
      */
-    protected Node<K, V> copy( long revision )
+    protected InMemoryNode<K, V> copy( long revision )
     {
-        Node<K, V> newPage = new Node<K, V>( btree, revision, nbElems );
+        InMemoryNode<K, V> newPage = new InMemoryNode<K, V>( btree, revision,
nbElems );
 
         // Copy the keys
         System.arraycopy( getKeys(), 0, newPage.getKeys(), 0, nbElems );

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/BTreeFactory.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/BTreeFactory.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/BTreeFactory.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/BTreeFactory.java
Mon Dec 16 17:40:44 2013
@@ -76,9 +76,9 @@ public class BTreeFactory
      * @param nbElems The number or elements in this node
      * @return A Node instance
      */
-    public static <K, V> Node<K, V> createNode( BTree<K, V> btree, long
revision, int nbElems )
+    public static <K, V> PersistedNode<K, V> createNode( BTree<K, V> btree,
long revision, int nbElems )
     {
-        Node<K, V> node = new Node<K, V>( btree, revision, nbElems );
+        PersistedNode<K, V> node = new PersistedNode<K, V>( btree, revision,
nbElems );
 
         return node;
     }
@@ -270,7 +270,7 @@ public class BTreeFactory
      * @param pos The position in the values array
      * @param value the value to inject
      */
-    public static <K, V> void setValue( Node<K, V> page, int pos, PersistedPageHolder<K,
V> value )
+    public static <K, V> void setValue( PersistedNode<K, V> page, int pos, PersistedPageHolder<K,
V> value )
     {
         page.setValue( pos, value );
     }
@@ -298,7 +298,7 @@ public class BTreeFactory
         }
         else
         {
-            Node<K, V> node = ( Node<K, V> ) btree.getRootPage();
+            PersistedNode<K, V> node = ( PersistedNode<K, V> ) btree.getRootPage();
 
             while ( true )
             {
@@ -343,7 +343,7 @@ public class BTreeFactory
         }
         else
         {
-            Node<K, V> node = ( Node<K, V> ) btree.getRootPage();
+            PersistedNode<K, V> node = ( PersistedNode<K, V> ) btree.getRootPage();
 
             while ( true )
             {

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTree.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTree.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTree.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTree.java
Mon Dec 16 17:40:44 2013
@@ -554,7 +554,7 @@ public class PersistedBTree<K, V> extend
                 rightPage, revision );
 
             // Create the new rootPage
-            newRootPage = new Node<K, V>( this, revision, pivot, holderLeft, holderRight
);
+            newRootPage = new PersistedNode<K, V>( this, revision, pivot, holderLeft,
holderRight );
 
             // If the BTree is managed, we now have to write the page on disk
             // and to add this page to the list of modified pages

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTreeBuilder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTreeBuilder.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTreeBuilder.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedBTreeBuilder.java
Mon Dec 16 17:40:44 2013
@@ -169,7 +169,7 @@ public class PersistedBTreeBuilder<K, V>
 
         int numChildren = numKeysInNode + 1;
 
-        Node<K, V> node = createNode( btree, 0, numKeysInNode );
+        PersistedNode<K, V> node = createNode( btree, 0, numKeysInNode );
         lstNodes.add( node );
         int i = 0;
         int totalNodes = 0;

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedLeaf.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedLeaf.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedLeaf.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedLeaf.java
Mon Dec 16 17:40:44 2013
@@ -222,8 +222,8 @@ import org.apache.directory.mavibot.btre
                 // if it has more than N/2 elements, or to merge the two pages.
                 // 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( ( Node<K, V> ) parent, parentPos );
-                PersistedLeaf<K, V> sibling = ( PersistedLeaf<K, V> ) ( ( ( Node<K,
V> ) parent ).getPage( siblingPos ) );
+                int siblingPos = selectSibling( ( PersistedNode<K, V> ) parent, parentPos
);
+                PersistedLeaf<K, V> sibling = ( PersistedLeaf<K, V> ) ( ( ( PersistedNode<K,
V> ) parent ).getPage( siblingPos ) );
 
                 if ( sibling.getNbElems() == halfSize )
                 {

Copied: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedNode.java
(from r1551277, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/Node.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedNode.java?p2=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedNode.java&p1=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/Node.java&r1=1551277&r2=1551280&rev=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/Node.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/PersistedNode.java
Mon Dec 16 17:40:44 2013
@@ -49,7 +49,7 @@ import org.apache.directory.mavibot.btre
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/* No qualifier */class Node<K, V> extends AbstractPage<K, V>
+/* No qualifier */class PersistedNode<K, V> extends AbstractPage<K, V>
 {
     /**
      * Creates a new Node which will contain only one key, with references to
@@ -61,7 +61,7 @@ import org.apache.directory.mavibot.btre
      * @param nbElems The number of elements in this Node
      */
     @SuppressWarnings("unchecked")
-    /* No qualifier */Node( BTree<K, V> btree, long revision, int nbElems )
+    PersistedNode( BTree<K, V> btree, long revision, int nbElems )
     {
         super( btree, revision, nbElems );
 
@@ -82,7 +82,7 @@ import org.apache.directory.mavibot.btre
      * @param rightPage The right page
      */
     @SuppressWarnings("unchecked")
-    /* No qualifier */Node( BTree<K, V> btree, long revision, K key, Page<K, V>
leftPage, Page<K, V> rightPage )
+    PersistedNode( BTree<K, V> btree, long revision, K key, Page<K, V> leftPage,
Page<K, V> rightPage )
     {
         super( btree, revision, 1 );
 
@@ -114,7 +114,7 @@ import org.apache.directory.mavibot.btre
      * @param rightPage The right page
      */
     @SuppressWarnings("unchecked")
-    /* No qualifier */Node( BTree<K, V> btree, long revision, K key, PersistedPageHolder<K,
V> leftPage,
+    PersistedNode( BTree<K, V> btree, long revision, K key, PersistedPageHolder<K,
V> leftPage,
         PersistedPageHolder<K, V> rightPage )
     {
         super( btree, revision, 1 );
@@ -206,7 +206,7 @@ import org.apache.directory.mavibot.btre
         // 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.
-        Node<K, V> newPage = copy( revision );
+        PersistedNode<K, V> newPage = copy( revision );
 
         Page<K, V> modifiedPage = removeResult.getModifiedPage();
 
@@ -278,10 +278,10 @@ import org.apache.directory.mavibot.btre
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> borrowFromRight( long revision, MergedWithSiblingResult<K,
V> mergedResult,
-        Node<K, V> sibling, int pos ) throws IOException
+        PersistedNode<K, V> sibling, int pos ) throws IOException
     {
         // Create the new sibling, with one less element at the beginning
-        Node<K, V> newSibling = new Node<K, V>( btree, revision, sibling.getNbElems()
- 1 );
+        PersistedNode<K, V> newSibling = new PersistedNode<K, V>( btree, revision,
sibling.getNbElems() - 1 );
 
         K siblingKey = sibling.children[0].getValue().getLeftMostKey();
 
@@ -291,7 +291,7 @@ import org.apache.directory.mavibot.btre
 
         // Create the new page and add the new element at the end
         // First copy the current node, with the same size
-        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems );
+        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision,
nbElems );
 
         // Copy the keys and the values up to the insertion position
         int index = Math.abs( pos );
@@ -364,13 +364,13 @@ import org.apache.directory.mavibot.btre
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> borrowFromLeft( long revision, MergedWithSiblingResult<K,
V> mergedResult,
-        Node<K, V> sibling, int pos ) throws IOException
+        PersistedNode<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
-        Node<K, V> newSibling = new Node<K, V>( btree, revision, sibling.getNbElems()
- 1 );
+        PersistedNode<K, V> newSibling = new PersistedNode<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() );
@@ -378,7 +378,7 @@ import org.apache.directory.mavibot.btre
 
         // Create the new page and add the new element at the beginning
         // First copy the current node, with the same size
-        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems );
+        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision,
nbElems );
 
         // Sets the first children
         newNode.children[0] = createHolder( siblingChild ); //1
@@ -453,11 +453,11 @@ import org.apache.directory.mavibot.btre
      * @throws IOException If we have an error while trying to access the page
      */
     private DeleteResult<K, V> mergeWithSibling( long revision, MergedWithSiblingResult<K,
V> mergedResult,
-        Node<K, V> sibling, boolean isLeft, int pos ) throws IOException
+        PersistedNode<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
-        Node<K, V> newNode = new Node<K, V>( btree, revision, btree.getPageSize()
);
+        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision,
btree.getPageSize() );
         Tuple<K, V> removedElement = mergedResult.getRemovedElement();
         int half = btree.getPageSize() / 2;
         int index = Math.abs( pos );
@@ -659,9 +659,9 @@ import org.apache.directory.mavibot.btre
                 // We will remove one element from a page that will have less than N/2 elements,
                 // which will lead to some reorganization : either we can borrow an element
from
                 // a sibling, or we will have to merge two pages
-                int siblingPos = selectSibling( ( Node<K, V> ) parent, parentPos );
+                int siblingPos = selectSibling( ( PersistedNode<K, V> ) parent, parentPos
);
 
-                Node<K, V> sibling = ( Node<K, V> ) ( ( ( Node<K, V> )
parent ).children[siblingPos].getValue() );
+                PersistedNode<K, V> sibling = ( PersistedNode<K, V> ) ( ( ( PersistedNode<K,
V> ) parent ).children[siblingPos].getValue() );
 
                 if ( sibling.getNbElems() > halfSize )
                 {
@@ -711,7 +711,7 @@ import org.apache.directory.mavibot.btre
         Page<K, V> modifiedPage = borrowedResult.getModifiedPage();
         Page<K, V> modifiedSibling = borrowedResult.getModifiedSibling();
 
-        Node<K, V> newPage = copy( revision );
+        PersistedNode<K, V> newPage = copy( revision );
 
         if ( pos < 0 )
         {
@@ -784,7 +784,7 @@ import org.apache.directory.mavibot.btre
         throws IOException
     {
         // First copy the current page, but remove one element in the copied page
-        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems - 1 );
+        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision,
nbElems - 1 );
 
         int index = Math.abs( pos ) - 2;
 
@@ -883,7 +883,7 @@ import org.apache.directory.mavibot.btre
         // to point on the modified child
         Page<K, V> modifiedPage = result.getModifiedPage();
 
-        ( ( Node<K, V> ) newPage ).children[pos] = createHolder( modifiedPage );
+        ( ( PersistedNode<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
@@ -930,7 +930,7 @@ import org.apache.directory.mavibot.btre
         throws IOException
     {
         // First copy the current page, but add one element in the copied page
-        Node<K, V> newNode = new Node<K, V>( btree, revision, nbElems + 1 );
+        PersistedNode<K, V> newNode = new PersistedNode<K, V>( btree, revision,
nbElems + 1 );
 
         // Copy the keys and the children up to the insertion position
         if ( nbElems > 0 )
@@ -986,8 +986,8 @@ import org.apache.directory.mavibot.btre
         int middle = btree.getPageSize() >> 1;
 
         // Create two new pages
-        Node<K, V> newLeftPage = new Node<K, V>( btree, revision, middle );
-        Node<K, V> newRightPage = new Node<K, V>( btree, revision, middle );
+        PersistedNode<K, V> newLeftPage = new PersistedNode<K, V>( btree, revision,
middle );
+        PersistedNode<K, V> newRightPage = new PersistedNode<K, V>( btree, revision,
middle );
 
         // Determinate where to store the new value
         // If it's before the middle, insert the value on the left,
@@ -1087,9 +1087,9 @@ import org.apache.directory.mavibot.btre
      * @param revision The new revision
      * @return The copied page
      */
-    protected Node<K, V> copy( long revision )
+    protected PersistedNode<K, V> copy( long revision )
     {
-        Node<K, V> newPage = new Node<K, V>( btree, revision, nbElems );
+        PersistedNode<K, V> newPage = new PersistedNode<K, V>( btree, revision,
nbElems );
 
         // Copy the keys
         System.arraycopy( keys, 0, newPage.keys, 0, nbElems );

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/RecordManager.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/RecordManager.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/RecordManager.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/RecordManager.java
Mon Dec 16 17:40:44 2013
@@ -680,10 +680,10 @@ public class RecordManager
     /**
      * Deserialize a Node from some PageIos
      */
-    private <K, V> Node<K, V> readNodeKeysAndValues( BTree<K, V> btree,
int nbElems, long revision, ByteBuffer byteBuffer,
+    private <K, V> PersistedNode<K, V> readNodeKeysAndValues( BTree<K, V>
btree, int nbElems, long revision, ByteBuffer byteBuffer,
         PageIO[] pageIos ) throws IOException
     {
-        Node<K, V> node = BTreeFactory.createNode( btree, revision, nbElems );
+        PersistedNode<K, V> node = BTreeFactory.createNode( btree, revision, nbElems
);
 
         // Read each value and key
         for ( int i = 0; i < nbElems; i++ )
@@ -1166,7 +1166,7 @@ public class RecordManager
             int dataSize = 0;
             int serializedSize = 0;
 
-            if ( page instanceof Node )
+            if ( page instanceof PersistedNode )
             {
                 // A Node has one more value to store
                 nbBuffers++;
@@ -1184,7 +1184,7 @@ public class RecordManager
             // Make it a negative value if it's a Node
             int pageNbElems = nbElems;
 
-            if ( page instanceof Node )
+            if ( page instanceof PersistedNode )
             {
                 pageNbElems = -nbElems;
             }
@@ -1199,10 +1199,10 @@ public class RecordManager
             for ( int pos = 0; pos < nbElems; pos++ )
             {
                 // Start with the value
-                if ( page instanceof Node )
+                if ( page instanceof PersistedNode )
                 {
-                    dataSize += serializeNodeValue( ( Node<K, V> ) page, pos, serializedData
);
-                    dataSize += serializeNodeKey( ( Node<K, V> ) page, pos, serializedData
);
+                    dataSize += serializeNodeValue( ( PersistedNode<K, V> ) page, pos,
serializedData );
+                    dataSize += serializeNodeKey( ( PersistedNode<K, V> ) page, pos,
serializedData );
                 }
                 else
                 {
@@ -1212,9 +1212,9 @@ public class RecordManager
             }
 
             // Nodes have one more value to serialize
-            if ( page instanceof Node )
+            if ( page instanceof PersistedNode )
             {
-                dataSize += serializeNodeValue( ( Node<K, V> ) page, nbElems, serializedData
);
+                dataSize += serializeNodeValue( ( PersistedNode<K, V> ) page, nbElems,
serializedData );
             }
 
             // Store the data size
@@ -1243,7 +1243,7 @@ public class RecordManager
     /**
      * Serialize a Node's key
      */
-    private <K, V> int serializeNodeKey( Node<K, V> node, int pos, List<byte[]>
serializedData )
+    private <K, V> int serializeNodeKey( PersistedNode<K, V> node, int pos, List<byte[]>
serializedData )
     {
         KeyHolder<K> holder = node.getKeyHolder( pos );
         byte[] buffer = ((PersistedKeyHolder<K>)holder).getRaw();
@@ -1262,7 +1262,7 @@ public class RecordManager
     /**
      * Serialize a Node's Value. We store the two offsets of the child page.
      */
-    private <K, V> int serializeNodeValue( Node<K, V> node, int pos, List<byte[]>
serializedData )
+    private <K, V> int serializeNodeValue( PersistedNode<K, V> node, int pos,
List<byte[]> serializedData )
         throws IOException
     {
         // For a node, we just store the children's offsets

Modified: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeTest.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeTest.java
(original)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/InMemoryBTreeTest.java
Mon Dec 16 17:40:44 2013
@@ -1064,7 +1064,7 @@ public class InMemoryBTreeTest
     }
 
 
-    private void addPage( BTree<Integer, String> btree, Node<Integer, String>
node, Page<Integer, String> page, int pos )
+    private void addPage( BTree<Integer, String> btree, InMemoryNode<Integer, String>
node, Page<Integer, String> page, int pos )
         throws EndOfFileExceededException, IOException
     {
         Tuple<Integer, String> leftmost = page.findLeftMost();
@@ -1139,13 +1139,13 @@ public class InMemoryBTreeTest
         BTree<Integer, String> btree = new InMemoryBTree<Integer, String>( "test",
new IntSerializer(), new StringSerializer(),
             pageSize );
 
-        Node<Integer, String> root = new Node<Integer, String>( btree, 1L, pageSize
);
+        InMemoryNode<Integer, String> root = new InMemoryNode<Integer, String>(
btree, 1L, pageSize );
 
         // Create the tree with 3 levels, all the leaves containing only N/2 elements
         int counter = 1;
         for ( int i = 0; i < pageSize + 1; i++ )
         {
-            Node<Integer, String> node = new Node<Integer, String>( btree, 1L,
pageSize );
+            InMemoryNode<Integer, String> node = new InMemoryNode<Integer, String>(
btree, 1L, pageSize );
 
             for ( int j = 0; j < pageSize + 1; j++ )
             {

Modified: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/LeafTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/LeafTest.java?rev=1551280&r1=1551279&r2=1551280&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/LeafTest.java
(original)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/LeafTest.java
Mon Dec 16 17:40:44 2013
@@ -227,7 +227,7 @@ public class LeafTest
     @Test
     public void testDeleteBorrowingFromLeftSibling() throws IOException
     {
-        Node<Long, String> parent = new Node<Long, String>( btree, 1L, 2 );
+        InMemoryNode<Long, String> parent = new InMemoryNode<Long, String>( btree,
1L, 2 );
         InMemoryLeaf<Long, String> left = new InMemoryLeaf<Long, String>( btree
);
         InMemoryLeaf<Long, String> target = new InMemoryLeaf<Long, String>( btree
);
         InMemoryLeaf<Long, String> right = new InMemoryLeaf<Long, String>( btree
);
@@ -297,7 +297,7 @@ public class LeafTest
     @Test
     public void testDeleteBorrowingFromRightSibling() throws IOException
     {
-        Node<Long, String> parent = new Node<Long, String>( btree, 1L, 2 );
+        InMemoryNode<Long, String> parent = new InMemoryNode<Long, String>( btree,
1L, 2 );
         InMemoryLeaf<Long, String> left = new InMemoryLeaf<Long, String>( btree
);
         InMemoryLeaf<Long, String> target = new InMemoryLeaf<Long, String>( btree
);
         InMemoryLeaf<Long, String> right = new InMemoryLeaf<Long, String>( btree
);
@@ -368,7 +368,7 @@ public class LeafTest
     @Test
     public void testDeleteMergeWithSibling() throws IOException
     {
-        Node<Long, String> parent = new Node<Long, String>( btree, 1L, 2 );
+        InMemoryNode<Long, String> parent = new InMemoryNode<Long, String>( btree,
1L, 2 );
         InMemoryLeaf<Long, String> left = new InMemoryLeaf<Long, String>( btree
);
         InMemoryLeaf<Long, String> target = new InMemoryLeaf<Long, String>( btree
);
         InMemoryLeaf<Long, String> right = new InMemoryLeaf<Long, String>( btree
);



Mime
View raw message