directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1547422 - in /directory/mavibot/trunk/mavibot/src: main/java/org/apache/directory/mavibot/btree/ main/java/org/apache/directory/mavibot/btree/memory/ test/java/org/apache/directory/mavibot/btree/memory/
Date Tue, 03 Dec 2013 15:11:45 GMT
Author: elecharny
Date: Tue Dec  3 15:11:44 2013
New Revision: 1547422

URL: http://svn.apache.org/r1547422
Log:
o The ElementHolder.getValue() does not need a BTre argument anymore
o Renamed the ParentPos.dupsContainer to valueCursor (an attempt to close the gap with the
managerBTree ParentPos class)
o Using the TupleCursor interface instead of the TupleCursorImpl class
o Some minor cleanup

Modified:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractPage.java
    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/ElementHolder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InternalUtil.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Leaf.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MemoryHolder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MultipleMemoryHolder.java
    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/memory/Page.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ParentPos.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/TupleCursorImpl.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/BTreeDuplicateKeyTest.java

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java
Tue Dec  3 15:11:44 2013
@@ -152,7 +152,7 @@ public interface TupleCursor<K, V> exten
     
     
     /**
-     * Change the position in the current cursor tbefore the first key
+     * Change the position in the current cursor before the first key
      */
     void beforeFirst() throws IOException;
     

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractPage.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractPage.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractPage.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractPage.java
Tue Dec  3 15:11:44 2013
@@ -114,8 +114,8 @@ import org.apache.directory.mavibot.btre
             return parentPos - 1;
         }
 
-        Page<K, V> prevPage = parent.children[parentPos - 1].getValue( btree );
-        Page<K, V> nextPage = parent.children[parentPos + 1].getValue( btree );
+        Page<K, V> prevPage = parent.children[parentPos - 1].getValue();
+        Page<K, V> nextPage = parent.children[parentPos + 1].getValue();
 
         int prevPageSize = prevPage.getNbElems();
         int nextPageSize = nextPage.getNbElems();

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=1547422&r1=1547421&r2=1547422&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
Tue Dec  3 15:11:44 2013
@@ -256,7 +256,7 @@ public class BTreeFactory
 
             while ( true )
             {
-                Page<K, V> p = node.children[node.getNbElems()].getValue( btree );
+                Page<K, V> p = node.children[node.getNbElems()].getValue();
 
                 last = new ParentPos<K, V>( p, p.getNbElems() );
                 stack.push( last );

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ElementHolder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ElementHolder.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ElementHolder.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ElementHolder.java
Tue Dec  3 15:11:44 2013
@@ -41,9 +41,7 @@ public interface ElementHolder<E, K, V>
     /**
      * Get back the element
      * 
-     * @param btree The Btree storing the element
-     * 
      * @return The stored element
      */
-    E getValue( BTree<K, V> btree ) throws EndOfFileExceededException, IOException;
+    E getValue() throws EndOfFileExceededException, IOException;
 }

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InternalUtil.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InternalUtil.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InternalUtil.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/InternalUtil.java
Tue Dec  3 15:11:44 2013
@@ -36,7 +36,7 @@ import org.apache.directory.mavibot.btre
 {
 
     /**
-     * Sets the multi-value container(a.k.a dupsContainer) of the key at the given position.
+     * Sets the multi-value container(a.k.a valueCursor) of the key at the given position.
      * 
      * This method will not update the existing value of 'dupsPos'. To change this value
      * use {@link #changeNextDupsContainer(ParentPos, BTree)} or {@link #changePrevDupsContainer(ParentPos,
BTree)}
@@ -51,7 +51,7 @@ import org.apache.directory.mavibot.btre
             return;
         }
 
-        if ( parentPos.dupsContainer == null )
+        if ( parentPos.valueCursor == null )
         {
             Leaf leaf = ( Leaf ) ( parentPos.page );
             
@@ -67,8 +67,8 @@ import org.apache.directory.mavibot.btre
                 
                 if ( !mvHolder.isSingleValue() )
                 {
-                    BTree dupsContainer = ( BTree ) mvHolder.getValue( btree );
-                    parentPos.dupsContainer = dupsContainer;
+                    BTree valueCursor = ( BTree ) mvHolder.getValue();
+                    parentPos.valueCursor = valueCursor;
                 }
             }
         }
@@ -76,7 +76,7 @@ import org.apache.directory.mavibot.btre
 
 
     /**
-     * Sets the multi-value container(a.k.a dupsContainer) of the key at the given position
+     * Sets the multi-value container(a.k.a valueCursor) of the key at the given position
      * and resets the 'dupsPos' to zero. This is mostly used by Cursor while navigating using
      * next() 
      *
@@ -96,8 +96,8 @@ import org.apache.directory.mavibot.btre
             MultipleMemoryHolder mvHolder = ( MultipleMemoryHolder ) leaf.values[parentPos.pos];
             if( !mvHolder.isSingleValue() )
             {
-                BTree dupsContainer = ( BTree ) mvHolder.getValue( btree );
-                parentPos.dupsContainer = dupsContainer;
+                BTree valueCursor = ( BTree ) mvHolder.getValue();
+                parentPos.valueCursor = valueCursor;
                 parentPos.dupPos = 0;
             }
         }
@@ -105,7 +105,7 @@ import org.apache.directory.mavibot.btre
 
 
     /**
-     * Sets the multi-value container(a.k.a dupsContainer) of the key at the index below
the given position( i.e pos - 1)
+     * Sets the multi-value container(a.k.a valueCursor) of the key at the index below the
given position( i.e pos - 1)
      * and resets the 'dupsPos' to the number of elements present in the multi-value container.
      * This is used by Cursor while navigating using prev() 
      *
@@ -126,13 +126,12 @@ import org.apache.directory.mavibot.btre
             MultipleMemoryHolder mvHolder = ( MultipleMemoryHolder ) leaf.values[index];
             if( !mvHolder.isSingleValue() )
             {
-                BTree dupsContainer = ( BTree ) mvHolder.getValue( btree );
-                parentPos.dupsContainer = dupsContainer;
-                parentPos.dupPos = ( int ) parentPos.dupsContainer.getNbElems();
+                parentPos.valueCursor = ( BTree ) mvHolder.getValue();
+                parentPos.dupPos = ( int ) parentPos.valueCursor.getNbElems();
             }
             else
             {
-                parentPos.dupsContainer = null;
+                parentPos.valueCursor = null;
                 parentPos.dupPos = -1;
             }
         }

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Leaf.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Leaf.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Leaf.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Leaf.java
Tue Dec  3 15:11:44 2013
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.lang.reflect.Array;
 
 import org.apache.directory.mavibot.btree.Tuple;
+import org.apache.directory.mavibot.btree.TupleCursor;
 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 
@@ -161,7 +162,7 @@ import org.apache.directory.mavibot.btre
 
             //FIXME should the internal sub-tree should be deleted from RM?
 
-            V existingVal = mvHolder.getValue( btree );
+            V existingVal = mvHolder.getValue();
 
             if ( value == null ) // this is a case to delete entire <K,sub-BTree> or
<K,single-V>
             {
@@ -216,7 +217,7 @@ import org.apache.directory.mavibot.btre
         }
         else
         {
-            V existing = values[index].getValue( btree );
+            V existing = values[index].getValue();
 
             if ( ( ( existing == null ) && ( value == null ) ) || ( value == null
) )
             {
@@ -272,7 +273,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( ( Node<K, V> ) parent, parentPos );
-                Leaf<K, V> sibling = ( Leaf<K, V> ) ( ( ( Node<K, V> )
parent ).children[siblingPos].getValue( btree ) );
+                Leaf<K, V> sibling = ( Leaf<K, V> ) ( ( ( Node<K, V> )
parent ).children[siblingPos].getValue() );
 
                 if ( sibling.getNbElems() == halfSize )
                 {
@@ -537,17 +538,17 @@ import org.apache.directory.mavibot.btre
                 MultipleMemoryHolder<K, V> mvHolder = ( MultipleMemoryHolder<K,
V> ) values[-( pos + 1 )];
                 if ( mvHolder.isSingleValue() )
                 {
-                    return mvHolder.getValue( btree );
+                    return mvHolder.getValue();
                 }
                 else
                 {
                     // always return the first value for get(key) when duplicates are allowed
-                    BTree<V, V> dupTree = ( BTree<V, V> ) mvHolder.getValue(
btree );
+                    BTree<V, V> dupTree = ( BTree<V, V> ) mvHolder.getValue();
                     return dupTree.rootPage.getLeftMostKey();
                 }
             }
 
-            V v = values[-( pos + 1 )].getValue( btree );
+            V v = values[-( pos + 1 )].getValue();
 
             return v;
         }
@@ -577,10 +578,10 @@ import org.apache.directory.mavibot.btre
 
             if ( mvHolder.isSingleValue() )
             {
-                return new DuplicateKeyVal<V>( mvHolder.getValue( btree ) );
+                return new DuplicateKeyVal<V>( mvHolder.getValue() );
             }
 
-            return new DuplicateKeyVal<V>( ( BTree<V, V> ) mvHolder.getValue(
btree ) );
+            return new DuplicateKeyVal<V>( ( BTree<V, V> ) mvHolder.getValue()
);
         }
         else
         {
@@ -617,18 +618,18 @@ import org.apache.directory.mavibot.btre
                 MultipleMemoryHolder<K, V> mvHolder = ( MultipleMemoryHolder<K,
V> ) values[-( pos + 1 )];
                 if ( mvHolder.isSingleValue() )
                 {
-                    return ( btree.getValueSerializer().compare( value, mvHolder.getValue(
btree ) ) == 0 );
+                    return ( btree.getValueSerializer().compare( value, mvHolder.getValue()
) == 0 );
                 }
                 else
                 {
                     // always return the first value for get(key) when duplicates are allowed
-                    BTree<V, V> dupTree = ( ( BTree<V, V> ) mvHolder.getValue(
btree ) );
+                    BTree<V, V> dupTree = ( ( BTree<V, V> ) mvHolder.getValue()
);
                     return dupTree.hasKey( value );
                 }
             }
             else
             {
-                V v = values[-( pos + 1 )].getValue( btree );
+                V v = values[-( pos + 1 )].getValue();
                 return ( btree.getValueSerializer().compare( value, v ) == 0 );
             }
         }
@@ -669,10 +670,10 @@ import org.apache.directory.mavibot.btre
     /**
      * {@inheritDoc}
      */
-    public TupleCursorImpl<K, V> browse( K key, Transaction<K, V> transaction,
ParentPos<K, V>[] stack, int depth )
+    public TupleCursor<K, V> browse( K key, Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
     {
         int pos = findPos( key );
-        TupleCursorImpl<K, V> cursor = null;
+        TupleCursor<K, V> cursor = null;
 
         if ( pos < 0 )
         {
@@ -713,10 +714,10 @@ import org.apache.directory.mavibot.btre
     /**
      * {@inheritDoc}
      */
-    public TupleCursorImpl<K, V> browse( Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
+    public TupleCursor<K, V> browse( Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
     {
         int pos = 0;
-        TupleCursorImpl<K, V> cursor = null;
+        TupleCursor<K, V> cursor = null;
 
         if ( nbElems == 0 )
         {
@@ -789,7 +790,7 @@ import org.apache.directory.mavibot.btre
 
             if ( mvHolder.isSingleValue() )
             {
-                V singleVal = mvHolder.getValue( btree );
+                V singleVal = mvHolder.getValue();
 
                 // see if the given value already matches
                 if ( btree.getValueSerializer().compare( value, singleVal ) == 0 )
@@ -807,7 +808,7 @@ import org.apache.directory.mavibot.btre
             // ('oldValue' will be not null if it matched with the 'singleValue', see above
nested if block )
             if ( oldValue == null )
             {
-                BTree<V, V> dupValues = ( BTree<V, V> ) mvHolder.getValue( btree
);
+                BTree<V, V> dupValues = ( BTree<V, V> ) mvHolder.getValue();
 
                 // return value will always be null  here 
                 if ( !dupValues.hasKey( value ) )
@@ -823,7 +824,7 @@ import org.apache.directory.mavibot.btre
         else
         {
             // Now we can inject the value
-            oldValue = newLeaf.values[pos].getValue( btree );
+            oldValue = newLeaf.values[pos].getValue();
             newLeaf.values[pos] = btree.createValueHolder( value );
         }
 
@@ -1002,12 +1003,12 @@ import org.apache.directory.mavibot.btre
 
         if ( btree.isAllowDuplicates() )
         {
-            BTree<V, V> dupTree = ( BTree<V, V> ) values[0].getValue( btree );
+            BTree<V, V> dupTree = ( BTree<V, V> ) values[0].getValue();
             val = dupTree.rootPage.getLeftMostKey();
         }
         else
         {
-            val = values[0].getValue( btree );
+            val = values[0].getValue();
         }
 
         return new Tuple<K, V>( keys[0], val );
@@ -1023,12 +1024,12 @@ import org.apache.directory.mavibot.btre
 
         if ( btree.isAllowDuplicates() )
         {
-            BTree<V, V> dupTree = ( BTree<V, V> ) values[nbElems - 1].getValue(
btree );
+            BTree<V, V> dupTree = ( BTree<V, V> ) values[nbElems - 1].getValue();
             val = dupTree.rootPage.getRightMostKey();
         }
         else
         {
-            val = values[nbElems - 1].getValue( btree );
+            val = values[nbElems - 1].getValue();
         }
 
         return new Tuple<K, V>( keys[nbElems - 1], val );

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MemoryHolder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MemoryHolder.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MemoryHolder.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MemoryHolder.java
Tue Dec  3 15:11:44 2013
@@ -54,7 +54,7 @@ public class MemoryHolder<K, V> implemen
      * {@inheritDoc}
      */
     @Override
-    public V getValue( BTree<K, V> btree )
+    public V getValue()
     {
         return value;
     }
@@ -69,7 +69,7 @@ public class MemoryHolder<K, V> implemen
 
         sb.append( "'" );
 
-        V value = getValue( btree );
+        V value = getValue();
 
         sb.append( value );
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MultipleMemoryHolder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MultipleMemoryHolder.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MultipleMemoryHolder.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/MultipleMemoryHolder.java
Tue Dec  3 15:11:44 2013
@@ -88,7 +88,7 @@ public class MultipleMemoryHolder<K, V> 
      * {@inheritDoc}
      */
     @Override
-    public V getValue( BTree<K, V> btree )
+    public V getValue()
     {
         if ( valueContainer != null )
         {
@@ -167,7 +167,7 @@ public class MultipleMemoryHolder<K, V> 
 
         sb.append( "'" );
 
-        V value = getValue( btree );
+        V value = getValue();
 
         sb.append( value );
 

Modified: 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/Node.java?rev=1547422&r1=1547421&r2=1547422&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/Node.java
Tue Dec  3 15:11:44 2013
@@ -25,6 +25,7 @@ import java.lang.reflect.Array;
 import java.util.List;
 
 import org.apache.directory.mavibot.btree.Tuple;
+import org.apache.directory.mavibot.btree.TupleCursor;
 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 
@@ -146,7 +147,7 @@ import org.apache.directory.mavibot.btre
         }
 
         // Get the child page into which we will insert the <K, V> tuple
-        Page<K, V> child = children[pos].getValue( btree );
+        Page<K, V> child = children[pos].getValue();
 
         // and insert the <K, V> into this child
         InsertResult<K, V> result = child.insert( revision, key, value );
@@ -280,7 +281,7 @@ import org.apache.directory.mavibot.btre
         // Create the new sibling, with one less element at the beginning
         Node<K, V> newSibling = new Node<K, V>( btree, revision, sibling.getNbElems()
- 1 );
 
-        K siblingKey = sibling.children[0].getValue( btree ).getLeftMostKey();
+        K siblingKey = sibling.children[0].getValue().getLeftMostKey();
 
         // Copy the keys and children of the old sibling in the new sibling
         System.arraycopy( sibling.keys, 1, newSibling.keys, 0, newSibling.getNbElems() );
@@ -363,7 +364,7 @@ import org.apache.directory.mavibot.btre
         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( btree
);
+        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 );
@@ -393,7 +394,7 @@ import org.apache.directory.mavibot.btre
         else
         {
             // Set the first key
-            newNode.keys[0] = children[0].getValue( btree ).getLeftMostKey(); //2
+            newNode.keys[0] = children[0].getValue().getLeftMostKey(); //2
 
             if ( index > 2 )
             {
@@ -475,7 +476,7 @@ import org.apache.directory.mavibot.btre
             {
                 // Copy the left part of the node keys up to the deletion point
                 // Insert the new key
-                newNode.keys[half] = children[0].getValue( btree ).getLeftMostKey(); // 3
+                newNode.keys[half] = children[0].getValue().getLeftMostKey(); // 3
 
                 if ( index > 2 )
                 {
@@ -581,12 +582,12 @@ import org.apache.directory.mavibot.btre
         if ( found )
         {
             index = -( pos + 1 );
-            child = children[-pos].getValue( btree );
+            child = children[-pos].getValue();
             deleteResult = child.delete( revision, key, value, this, -pos );
         }
         else
         {
-            child = children[pos].getValue( btree );
+            child = children[pos].getValue();
             deleteResult = child.delete( revision, key, value, this, pos );
         }
 
@@ -650,7 +651,7 @@ import org.apache.directory.mavibot.btre
                 // a sibling, or we will have to merge two pages
                 int siblingPos = selectSibling( ( Node<K, V> ) parent, parentPos );
 
-                Node<K, V> sibling = ( Node<K, V> ) ( ( ( Node<K, V> )
parent ).children[siblingPos].getValue( btree ) );
+                Node<K, V> sibling = ( Node<K, V> ) ( ( ( Node<K, V> )
parent ).children[siblingPos].getValue() );
 
                 if ( sibling.getNbElems() > halfSize )
                 {
@@ -832,11 +833,11 @@ import org.apache.directory.mavibot.btre
         {
             // Here, if we have found the key in the node, then we must go down into
             // the right child, not the left one
-            return children[-pos].getValue( btree ).get( key );
+            return children[-pos].getValue().get( key );
         }
         else
         {
-            return children[pos].getValue( btree ).get( key );
+            return children[pos].getValue().get( key );
         }
     }
 
@@ -853,11 +854,11 @@ import org.apache.directory.mavibot.btre
         {
             // Here, if we have found the key in the node, then we must go down into
             // the right child, not the left one
-            return children[-pos].getValue( btree ).getValues( key );
+            return children[-pos].getValue().getValues( key );
         }
         else
         {
-            return children[pos].getValue( btree ).getValues( key );
+            return children[pos].getValue().getValues( key );
         }
     }
 
@@ -874,11 +875,11 @@ import org.apache.directory.mavibot.btre
         {
             // Here, if we have found the key in the node, then we must go down into
             // the right child, not the left one
-            return children[-pos].getValue( btree ).hasKey( key );
+            return children[-pos].getValue().hasKey( key );
         }
         else
         {
-            Page<K, V> page = children[pos].getValue( btree );
+            Page<K, V> page = children[pos].getValue();
 
             if ( page == null )
             {
@@ -902,11 +903,11 @@ import org.apache.directory.mavibot.btre
         {
             // Here, if we have found the key in the node, then we must go down into
             // the right child, not the left one
-            return children[-pos].getValue( btree ).contains( key, value );
+            return children[-pos].getValue().contains( key, value );
         }
         else
         {
-            return children[pos].getValue( btree ).contains( key, value );
+            return children[pos].getValue().contains( key, value );
         }
     }
 
@@ -930,7 +931,7 @@ import org.apache.directory.mavibot.btre
     {
         if ( pos < nbElems + 1 )
         {
-            return children[pos].getValue( btree );
+            return children[pos].getValue();
         }
         else
         {
@@ -942,7 +943,7 @@ import org.apache.directory.mavibot.btre
     /**
      * {@inheritDoc}
      */
-    public TupleCursorImpl<K, V> browse( K key, Transaction<K, V> transaction,
ParentPos<K, V>[] stack, int depth )
+    public TupleCursor<K, V> browse( K key, Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
         throws IOException
     {
         int pos = findPos( key );
@@ -955,7 +956,7 @@ import org.apache.directory.mavibot.btre
         // We first stack the current page
         stack[depth++] = new ParentPos<K, V>( this, pos );
         
-        Page<K, V> page = children[pos].getValue( btree );
+        Page<K, V> page = children[pos].getValue();
 
         return page.browse( key, transaction, stack, depth );
     }
@@ -964,12 +965,12 @@ import org.apache.directory.mavibot.btre
     /**
      * {@inheritDoc}
      */
-    public TupleCursorImpl<K, V> browse( Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
+    public TupleCursor<K, V> browse( Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
         throws IOException
     {
         stack[depth++] = new ParentPos<K, V>( this, 0 );
         
-        Page<K, V> page = children[0].getValue( btree );
+        Page<K, V> page = children[0].getValue();
 
         return page.browse( transaction, stack, depth );
     }
@@ -1198,7 +1199,7 @@ import org.apache.directory.mavibot.btre
      */
     public K getLeftMostKey() throws EndOfFileExceededException, IOException
     {
-        return children[0].getValue( btree ).getLeftMostKey();
+        return children[0].getValue().getLeftMostKey();
     }
 
 
@@ -1211,10 +1212,10 @@ import org.apache.directory.mavibot.btre
 
         if ( children[index] != null )
         {
-            return children[index].getValue( btree ).getRightMostKey();
+            return children[index].getValue().getRightMostKey();
         }
 
-        return children[nbElems - 1].getValue( btree ).getRightMostKey();
+        return children[nbElems - 1].getValue().getRightMostKey();
     }
 
 
@@ -1223,7 +1224,7 @@ import org.apache.directory.mavibot.btre
      */
     public Tuple<K, V> findLeftMost() throws EndOfFileExceededException, IOException
     {
-        return children[0].getValue( btree ).findLeftMost();
+        return children[0].getValue().findLeftMost();
     }
 
 
@@ -1232,7 +1233,7 @@ import org.apache.directory.mavibot.btre
      */
     public Tuple<K, V> findRightMost() throws EndOfFileExceededException, IOException
     {
-        return children[nbElems].getValue( btree ).findRightMost();
+        return children[nbElems].getValue().findRightMost();
     }
 
 
@@ -1258,7 +1259,7 @@ import org.apache.directory.mavibot.btre
                 }
                 else
                 {
-                    sb.append( 'r' ).append( children[0].getValue( btree ).getRevision()
);
+                    sb.append( 'r' ).append( children[0].getValue().getRevision() );
                 }
 
                 for ( int i = 0; i < nbElems; i++ )
@@ -1271,7 +1272,7 @@ import org.apache.directory.mavibot.btre
                     }
                     else
                     {
-                        sb.append( 'r' ).append( children[i + 1].getValue( btree ).getRevision()
);
+                        sb.append( 'r' ).append( children[i + 1].getValue().getRevision()
);
                     }
                 }
             }
@@ -1299,14 +1300,14 @@ import org.apache.directory.mavibot.btre
             try
             {
                 // Start with the first child
-                sb.append( children[0].getValue( btree ).dumpPage( tabs + "    " ) );
+                sb.append( children[0].getValue().dumpPage( tabs + "    " ) );
 
                 for ( int i = 0; i < nbElems; i++ )
                 {
                     sb.append( tabs );
                     sb.append( "<" );
                     sb.append( keys[i] ).append( ">\n" );
-                    sb.append( children[i + 1].getValue( btree ).dumpPage( tabs + "    "
) );
+                    sb.append( children[i + 1].getValue().dumpPage( tabs + "    " ) );
                 }
             }
             catch ( IOException ioe )

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Page.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Page.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Page.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/Page.java
Tue Dec  3 15:11:44 2013
@@ -21,9 +21,9 @@ package org.apache.directory.mavibot.btr
 
 
 import java.io.IOException;
-import java.util.LinkedList;
 
 import org.apache.directory.mavibot.btree.Tuple;
+import org.apache.directory.mavibot.btree.TupleCursor;
 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 
@@ -135,7 +135,7 @@ import org.apache.directory.mavibot.btre
      * @return A Cursor to browse the next elements
      * @throws IOException If we have an error while trying to access the page
      */
-    TupleCursorImpl<K, V> browse( K key, Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
+    TupleCursor<K, V> browse( K key, Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
         throws IOException;
 
 
@@ -147,7 +147,7 @@ import org.apache.directory.mavibot.btre
      * @return A Cursor to browse the next elements
      * @throws IOException If we have an error while trying to access the page
      */
-    TupleCursorImpl<K, V> browse( Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
+    TupleCursor<K, V> browse( Transaction<K, V> transaction, ParentPos<K,
V>[] stack, int depth )
         throws EndOfFileExceededException, IOException;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ParentPos.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ParentPos.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ParentPos.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ParentPos.java
Tue Dec  3 15:11:44 2013
@@ -41,7 +41,7 @@ package org.apache.directory.mavibot.btr
     /* No qualifier*/int dupPos;
 
     /** the container of duplicate key's values. The tuples will be stored as <V,null>*/
-    /* No qualifier*/BTree<V, V> dupsContainer;
+    /* No qualifier*/BTree<V, V> valueCursor;
 
 
     /**

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/TupleCursorImpl.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/TupleCursorImpl.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/TupleCursorImpl.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/TupleCursorImpl.java
Tue Dec  3 15:11:44 2013
@@ -132,17 +132,17 @@ public class TupleCursorImpl<K, V> imple
 
             if ( mvHolder.isSingleValue() )
             {
-                tuple.setValue( mvHolder.getValue( btree ) );
+                tuple.setValue( mvHolder.getValue() );
                 parentPos.pos++;
             }
             else
             {
                 setDupsContainer( parentPos, btree );
 
-                tuple.setValue( parentPos.dupsContainer.rootPage.getKey( parentPos.dupPos
) );
+                tuple.setValue( parentPos.valueCursor.rootPage.getKey( parentPos.dupPos )
);
                 parentPos.dupPos++;
 
-                if ( parentPos.dupsContainer.getNbElems() == parentPos.dupPos )
+                if ( parentPos.valueCursor.getNbElems() == parentPos.dupPos )
                 {
                     parentPos.pos++;
                     changeNextDupsContainer( parentPos, btree );
@@ -151,7 +151,7 @@ public class TupleCursorImpl<K, V> imple
         }
         else
         {
-            tuple.setValue( leaf.values[parentPos.pos].getValue( btree ) );
+            tuple.setValue( leaf.values[parentPos.pos].getValue() );
             parentPos.pos++;
         }
 
@@ -193,7 +193,7 @@ public class TupleCursorImpl<K, V> imple
             {
                 // We can pick the next element at this level
                 parentPos.pos++;
-                child = ((Node<K, V>)parentPos.page).children[parentPos.pos].getValue(
btree );
+                child = ((Node<K, V>)parentPos.page).children[parentPos.pos].getValue();
                 
                 // and go down the tree through the nodes
                 while ( currentDepth < depth - 1 )
@@ -202,7 +202,7 @@ public class TupleCursorImpl<K, V> imple
                     parentPos = stack[currentDepth];
                     parentPos.page = child;
                     parentPos.pos = 0;
-                    child = ((Node<K, V>)parentPos.page).children[parentPos.pos].getValue(
btree );
+                    child = ((Node<K, V>)parentPos.page).children[parentPos.pos].getValue();
                 }
 
                 // and the leaf
@@ -257,7 +257,7 @@ public class TupleCursorImpl<K, V> imple
             {
                 // We can pick the next element at this level
                 parentPos.pos--;
-                child = ((Node<K, V>)parentPos.page).children[parentPos.pos].getValue(
btree );
+                child = ((Node<K, V>)parentPos.page).children[parentPos.pos].getValue();
                 
                 // and go down the tree through the nodes
                 while ( currentDepth < depth - 1 )
@@ -266,7 +266,7 @@ public class TupleCursorImpl<K, V> imple
                     parentPos = stack[currentDepth];
                     parentPos.pos = child.getNbElems();
                     parentPos.page = child;
-                    child = ((Node<K, V>)parentPos.page).children[((Node<K, V>)parentPos.page).nbElems].getValue(
btree );
+                    child = ((Node<K, V>)parentPos.page).children[((Node<K, V>)parentPos.page).nbElems].getValue();
                 }
 
                 // and the leaf
@@ -354,7 +354,7 @@ public class TupleCursorImpl<K, V> imple
                 if ( mvHolder.isSingleValue() )
                 {
                     tuple.setKey( leaf.keys[parentPos.pos] );
-                    tuple.setValue( mvHolder.getValue( btree ) );
+                    tuple.setValue( mvHolder.getValue() );
                 }
                 else
                 {
@@ -370,7 +370,7 @@ public class TupleCursorImpl<K, V> imple
             {
                 setDupsContainer( parentPos, btree );
 
-                if ( parentPos.dupPos == parentPos.dupsContainer.getNbElems() )
+                if ( parentPos.dupPos == parentPos.valueCursor.getNbElems() )
                 {
                     parentPos.dupPos--;
                 }
@@ -379,7 +379,7 @@ public class TupleCursorImpl<K, V> imple
                     changePrevDupsContainer( parentPos, btree );
                     parentPos.pos--;
 
-                    if ( parentPos.dupsContainer != null )
+                    if ( parentPos.valueCursor != null )
                     {
                         parentPos.dupPos--;
                     }
@@ -391,13 +391,13 @@ public class TupleCursorImpl<K, V> imple
 
                 tuple.setKey( leaf.keys[parentPos.pos] );
 
-                if ( parentPos.dupsContainer != null )
+                if ( parentPos.valueCursor != null )
                 {
-                    tuple.setValue( parentPos.dupsContainer.rootPage.getKey( parentPos.dupPos
) );
+                    tuple.setValue( parentPos.valueCursor.rootPage.getKey( parentPos.dupPos
) );
                 }
                 else
                 {
-                    tuple.setValue( leaf.values[parentPos.pos].getValue( btree ) );
+                    tuple.setValue( leaf.values[parentPos.pos].getValue() );
                 }
             }
         }
@@ -405,7 +405,7 @@ public class TupleCursorImpl<K, V> imple
         {
             parentPos.pos--;
             tuple.setKey( leaf.keys[parentPos.pos] );
-            tuple.setValue( leaf.values[parentPos.pos].getValue( btree ) );
+            tuple.setValue( leaf.values[parentPos.pos].getValue() );
         }
 
         return tuple;
@@ -444,7 +444,7 @@ public class TupleCursorImpl<K, V> imple
         else
         {
             // Check if we have some more value
-            if ( allowDuplicates && ( parentPos.dupsContainer != null )  &&
( parentPos.dupPos < parentPos.dupsContainer.getNbElems() - 1 ) )
+            if ( allowDuplicates && ( parentPos.valueCursor != null )  &&
( parentPos.dupPos < parentPos.valueCursor.getNbElems() - 1 ) )
             {
                 // We have some more values
                 return true;
@@ -663,12 +663,12 @@ public class TupleCursorImpl<K, V> imple
 
             if( !mvHolder.isSingleValue() )
             {
-                BTree<V, V> dupsContainer = ( BTree ) mvHolder.getValue( btree );
-                parentPos.dupsContainer = dupsContainer;
+                BTree<V, V> valueCursor = ( BTree ) mvHolder.getValue();
+                parentPos.valueCursor = valueCursor;
                 parentPos.dupPos = 0;
             }
             
-            TupleCursor<V, V> cursor = parentPos.dupsContainer.browse();
+            TupleCursor<V, V> cursor = parentPos.valueCursor.browse();
             cursor.beforeFirst();
             
             V value = cursor.next().getKey();
@@ -676,7 +676,7 @@ public class TupleCursorImpl<K, V> imple
         }
         else
         {
-            V value = leaf.values[parentPos.pos].getValue( btree );
+            V value = leaf.values[parentPos.pos].getValue();
             tuple.setValue( value );
         }
 
@@ -798,12 +798,11 @@ public class TupleCursorImpl<K, V> imple
 
             if( !mvHolder.isSingleValue() )
             {
-                BTree<V, V> dupsContainer = ( BTree ) mvHolder.getValue( btree );
-                parentPos.dupsContainer = dupsContainer;
+                parentPos.valueCursor = ( BTree ) mvHolder.getValue();
                 parentPos.dupPos = 0;
             }
             
-            TupleCursor<V, V> cursor = parentPos.dupsContainer.browse();
+            TupleCursor<V, V> cursor = parentPos.valueCursor.browse();
             cursor.beforeFirst();
             
             V value = cursor.next().getKey();
@@ -811,7 +810,7 @@ public class TupleCursorImpl<K, V> imple
         }
         else
         {
-            V value = leaf.values[parentPos.pos].getValue( btree );
+            V value = leaf.values[parentPos.pos].getValue();
             tuple.setValue( value );
         }
         
@@ -842,7 +841,7 @@ public class TupleCursorImpl<K, V> imple
                 parentPos.page = child;
             }
 
-            child = ((Node<K, V>)parentPos.page).children[0].getValue( btree );
+            child = ((Node<K, V>)parentPos.page).children[0].getValue();
         }
         
         // and leaf
@@ -876,6 +875,7 @@ public class TupleCursorImpl<K, V> imple
 
         Page<K, V> child = null;
 
+        // Go fown the tree picking the rightmost element of each Node
         for ( int i = 0; i < depth; i++ )
         {
             ParentPos<K, V> parentPos = stack[i];
@@ -891,20 +891,15 @@ public class TupleCursorImpl<K, V> imple
                 parentPos.pos = ((Node<K, V>)parentPos.page).nbElems;
             }
 
-            child = ((Node<K, V>)parentPos.page).children[parentPos.pos].getValue(
btree );
+            child = ((Node<K, V>)parentPos.page).children[parentPos.pos].getValue();
         }
         
-        // and leaf
+        // and now, the leaf
         ParentPos<K, V> parentPos = stack[depth];
 
-        if ( child == null )
-        {
-            parentPos.pos = ((Leaf<K, V>)parentPos.page).nbElems - 1;
-        }
-        else
+        if ( child != null )
         {
             parentPos.page = child;
-            parentPos.pos = ((Leaf<K, V>)child).nbElems - 1;
         }
 
         parentPos.pos = AFTER_LAST;

Modified: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/BTreeDuplicateKeyTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/BTreeDuplicateKeyTest.java?rev=1547422&r1=1547421&r2=1547422&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/BTreeDuplicateKeyTest.java
(original)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/BTreeDuplicateKeyTest.java
Tue Dec  3 15:11:44 2013
@@ -371,6 +371,7 @@ public class BTreeDuplicateKeyTest
         assertEquals( "a", cursor.nextKey().getKey() );
 
         i = 0;
+        
         while ( cursor.hasNext() )
         {
             assertNotNull( cursor.nextKey() );



Mime
View raw message