directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1549961 [1/3] - in /directory/mavibot/trunk/mavibot/src: main/java/org/apache/directory/mavibot/btree/ main/java/org/apache/directory/mavibot/btree/managed/ main/java/org/apache/directory/mavibot/btree/memory/ test/java/org/apache/director...
Date Tue, 10 Dec 2013 20:42:17 GMT
Author: elecharny
Date: Tue Dec 10 20:42:16 2013
New Revision: 1549961

URL: http://svn.apache.org/r1549961
Log:
o Heavy refactoring of both managed and in-memory btree, which are now sharing more code (Result classes, Page, ParentPos, Transaction)
o Lots of fixes in the cursor code
o Fixes in the tests to reflect those changes

Added:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BorrowedFromSiblingResult.java
      - copied, changed from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromSiblingResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/DeleteResult.java
      - copied, changed from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/DeleteResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/InsertResult.java
      - copied, changed from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/InsertResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java
      - copied, changed from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Page.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ParentPos.java
      - copied, changed from r1547456, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ParentPos.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java
      - copied, changed from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Transaction.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ValueHolder.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/managed/BTreeDuplicateKeyTest.java
Removed:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromSiblingResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/DeleteResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/InsertResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/InternalUtil.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Page.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ParentPos.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Transaction.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/DeleteResult.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/InsertResult.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/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/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/Transaction.java
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/managed/AbstractBorrowedFromSiblingResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractDeleteResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractPage.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTreeFactory.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromLeftResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromRightResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Leaf.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ManagedBTreeBuilder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/MergedWithSiblingResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ModifyResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/NotPresentResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RemoveResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/SplitResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/TupleCursorImpl.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ValueHolder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractBorrowedFromSiblingResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractDeleteResult.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/AbstractResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeBuilder.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/BorrowedFromLeftResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromRightResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromSiblingResult.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/MergedWithSiblingResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/ModifyResult.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/NotPresentResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/RemoveResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/SplitResult.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
    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/InMemoryBTreeTestOps.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/LeafTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/memory/MultiThreadedBtreeTest.java

Copied: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BorrowedFromSiblingResult.java (from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromSiblingResult.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BorrowedFromSiblingResult.java?p2=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BorrowedFromSiblingResult.java&p1=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromSiblingResult.java&r1=1547056&r2=1549961&rev=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromSiblingResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BorrowedFromSiblingResult.java Tue Dec 10 20:42:16 2013
@@ -17,7 +17,8 @@
  *  under the License.
  *
  */
-package org.apache.directory.mavibot.btree.managed;
+package org.apache.directory.mavibot.btree;
+
 
 
 /**
@@ -28,7 +29,7 @@ package org.apache.directory.mavibot.btr
 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-interface BorrowedFromSiblingResult<K, V> extends DeleteResult<K, V>
+public interface BorrowedFromSiblingResult<K, V> extends DeleteResult<K, V>
 {
     /**
      * @return the modifiedSibling

Copied: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/DeleteResult.java (from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/DeleteResult.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/DeleteResult.java?p2=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/DeleteResult.java&p1=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/DeleteResult.java&r1=1547056&r2=1549961&rev=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/DeleteResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/DeleteResult.java Tue Dec 10 20:42:16 2013
@@ -17,11 +17,9 @@
  *  under the License.
  *
  */
-package org.apache.directory.mavibot.btree.managed;
+package org.apache.directory.mavibot.btree;
 
 
-import org.apache.directory.mavibot.btree.Result;
-import org.apache.directory.mavibot.btree.Tuple;
 
 
 /**
@@ -32,7 +30,7 @@ import org.apache.directory.mavibot.btre
 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-interface DeleteResult<K, V> extends Result<Page<K, V>>
+public interface DeleteResult<K, V> extends Result<Page<K, V>>
 {
     /**
      * @return the modifiedPage

Copied: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/InsertResult.java (from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/InsertResult.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/InsertResult.java?p2=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/InsertResult.java&p1=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/InsertResult.java&r1=1547056&r2=1549961&rev=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/InsertResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/InsertResult.java Tue Dec 10 20:42:16 2013
@@ -17,10 +17,9 @@
  *  under the License.
  *
  */
-package org.apache.directory.mavibot.btree.managed;
+package org.apache.directory.mavibot.btree;
 
 
-import org.apache.directory.mavibot.btree.Result;
 
 
 /**
@@ -33,6 +32,6 @@ import org.apache.directory.mavibot.btre
 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-interface InsertResult<K, V> extends Result<Page<K, V>>
+public interface InsertResult<K, V> extends Result<Page<K, V>>
 {
 }

Copied: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java (from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Page.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java?p2=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java&p1=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Page.java&r1=1547056&r2=1549961&rev=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Page.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java Tue Dec 10 20:42:16 2013
@@ -17,15 +17,11 @@
  *  under the License.
  *
  */
-package org.apache.directory.mavibot.btree.managed;
+package org.apache.directory.mavibot.btree;
 
 
 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.ValueCursor;
 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 
@@ -41,7 +37,7 @@ import org.apache.directory.mavibot.btre
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/* No qualifier */interface Page<K, V>
+public interface Page<K, V>
 {
     /**
      * @return The number of keys present in this page

Copied: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ParentPos.java (from r1547456, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ParentPos.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ParentPos.java?p2=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ParentPos.java&p1=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ParentPos.java&r1=1547456&r2=1549961&rev=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ParentPos.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ParentPos.java Tue Dec 10 20:42:16 2013
@@ -17,9 +17,8 @@
  *  under the License.
  *
  */
-package org.apache.directory.mavibot.btree.managed;
+package org.apache.directory.mavibot.btree;
 
-import org.apache.directory.mavibot.btree.ValueCursor;
 
 
 /**
@@ -31,16 +30,19 @@ import org.apache.directory.mavibot.btre
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-/* No qualifier*/class ParentPos<K, V>
+public class ParentPos<K, V>
 {
     /** The page we are browsing */
-    /* No qualifier*/Page<K, V> page;
+    public Page<K, V> page;
 
     /** The current position in the page */
-    /* No qualifier*/int pos;
+    public int pos;
 
     /** The current position of the duplicate container in the page */
-    /* No qualifier*/ValueCursor<V> valueCursor;
+    public int dupPos;
+
+    /** The current position of the duplicate container in the page */
+    public ValueCursor<V> valueCursor;
 
 
     /**
@@ -48,7 +50,7 @@ import org.apache.directory.mavibot.btre
      * @param page The current Page
      * @param pos The current position in the page
      */
-    /* No qualifier*/ParentPos( Page<K, V> page, int pos )
+    public ParentPos( Page<K, V> page, int pos )
     {
         this.page = page;
         this.pos = pos;

Copied: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java (from r1547056, directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Transaction.java)
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java?p2=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java&p1=directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Transaction.java&r1=1547056&r2=1549961&rev=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Transaction.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java Tue Dec 10 20:42:16 2013
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.directory.mavibot.btree.managed;
+package org.apache.directory.mavibot.btree;
 
 
 import java.util.Date;

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=1549961&r1=1549960&r2=1549961&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 10 20:42:16 2013
@@ -78,12 +78,15 @@ public interface TupleCursor<K, V> exten
 
 
     /**
+     * Get the current revision
+     * 
      * @return The revision this cursor is based on
      */
     long getRevision();
 
 
     /**
+     * Get the creation date
      * @return The creation date for this cursor
      */
     long getCreationDate();

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractBorrowedFromSiblingResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractBorrowedFromSiblingResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractBorrowedFromSiblingResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractBorrowedFromSiblingResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,8 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.BorrowedFromSiblingResult;
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractDeleteResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractDeleteResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractDeleteResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractDeleteResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,8 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.DeleteResult;
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractPage.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractPage.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractPage.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractPage.java Tue Dec 10 20:42:16 2013
@@ -23,6 +23,7 @@ package org.apache.directory.mavibot.btr
 import java.io.IOException;
 import java.lang.reflect.Array;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/AbstractResult.java Tue Dec 10 20:42:16 2013
@@ -23,6 +23,7 @@ package org.apache.directory.mavibot.btr
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Result;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTree.java Tue Dec 10 20:42:16 2013
@@ -32,6 +32,12 @@ import net.sf.ehcache.Cache;
 import net.sf.ehcache.config.CacheConfiguration;
 
 import org.apache.directory.mavibot.btree.BTreeHeader;
+import org.apache.directory.mavibot.btree.Cursor;
+import org.apache.directory.mavibot.btree.DeleteResult;
+import org.apache.directory.mavibot.btree.InsertResult;
+import org.apache.directory.mavibot.btree.Page;
+import org.apache.directory.mavibot.btree.ParentPos;
+import org.apache.directory.mavibot.btree.Transaction;
 import org.apache.directory.mavibot.btree.Tuple;
 import org.apache.directory.mavibot.btree.TupleCursor;
 import org.apache.directory.mavibot.btree.ValueCursor;
@@ -744,7 +750,7 @@ public class BTree<K, V> implements Clos
                 // Write the modified page on disk
                 // Note that we don't use the holder, the new root page will
                 // remain in memory.
-                ElementHolder<Page<K, V>, K, V> holder = recordManager.writePage( this, modifiedPage,
+                PageHolder<K, V> holder = recordManager.writePage( this, modifiedPage,
                     revision );
 
                 // Store the offset on disk in the page in memory
@@ -915,7 +921,11 @@ public class BTree<K, V> implements Clos
         Transaction<K, V> transaction = beginReadTransaction();
 
         // Fetch the root page for this revision
-        TupleCursor<K, V> cursor = rootPage.browse( transaction, new ParentPos[32], 0 );
+        ParentPos<K, V>[] stack = new ParentPos[32];
+        TupleCursor<K, V> cursor = rootPage.browse( transaction, stack, 0 );
+        
+        // Set the position before the first element
+        cursor.beforeFirst();
 
         return cursor;
     }
@@ -1026,7 +1036,7 @@ public class BTree<K, V> implements Clos
             // Write the modified page on disk
             // Note that we don't use the holder, the new root page will
             // remain in memory.
-            ElementHolder<Page<K, V>, K, V> holder = recordManager.writePage( this, modifiedPage,
+            PageHolder<K, V> holder = recordManager.writePage( this, modifiedPage,
                 revision );
             
             // The root has just been modified, we haven't split it
@@ -1048,10 +1058,10 @@ public class BTree<K, V> implements Clos
 
             // If the BTree is managed, we have to write the two pages that were created
             // and to keep a track of the two offsets for the upper node
-            ElementHolder<Page<K, V>, K, V> holderLeft = recordManager.writePage( this,
+            PageHolder<K, V> holderLeft = recordManager.writePage( this,
                 leftPage, revision );
 
-            ElementHolder<Page<K, V>, K, V> holderRight = recordManager.writePage( this,
+            PageHolder<K, V> holderRight = recordManager.writePage( this,
                 rightPage, revision );
 
             // Create the new rootPage
@@ -1059,7 +1069,7 @@ public class BTree<K, V> implements Clos
 
             // 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
-            ElementHolder<Page<K, V>, K, V> holder = recordManager
+            PageHolder<K, V> holder = recordManager
                 .writePage( this, newRootPage, revision );
 
             rootPage = newRootPage;
@@ -1259,7 +1269,7 @@ public class BTree<K, V> implements Clos
     @SuppressWarnings("unchecked")
     /* no qualifier */ValueHolder<V> createValueHolder( V value )
     {
-        return new ValueHolder<V>( this, valueSerializer, value );
+        return new ValueHolder<V>( this, value );
     }
 
 
@@ -1269,7 +1279,7 @@ public class BTree<K, V> implements Clos
      * @param value The value to store
      * @return The value holder
      */
-    /* no qualifier */ElementHolder<Page<K, V>, K, V> createPageHolder( Page<K, V> value )
+    /* no qualifier */PageHolder<K, V> createPageHolder( Page<K, V> value )
     {
         return new PageHolder<K, V>( this, value,
             value.getOffset(), value.getLastOffset() );

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTreeFactory.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTreeFactory.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTreeFactory.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BTreeFactory.java Tue Dec 10 20:42:16 2013
@@ -23,6 +23,8 @@ package org.apache.directory.mavibot.btr
 import java.io.IOException;
 import java.util.LinkedList;
 
+import org.apache.directory.mavibot.btree.Page;
+import org.apache.directory.mavibot.btree.ParentPos;
 import org.apache.directory.mavibot.btree.serializer.ElementSerializer;
 
 
@@ -249,7 +251,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, ElementHolder<Page<K, V>, K, V> value )
+    public static <K, V> void setValue( Node<K, V> page, int pos, PageHolder<K, V> value )
     {
         page.setValue( pos, value );
     }
@@ -271,7 +273,9 @@ public class BTreeFactory
 
         if ( btree.rootPage instanceof Leaf )
         {
-            InternalUtil.setLastDupsContainer( last, btree );
+            Leaf<K, V> leaf = ( Leaf<K, V> ) ( btree.rootPage );
+            ValueHolder<V> valueHolder = leaf.values[last.pos];
+            last.valueCursor = valueHolder.getCursor();
         }
         else
         {
@@ -286,7 +290,9 @@ public class BTreeFactory
 
                 if ( p instanceof Leaf )
                 {
-                    InternalUtil.setLastDupsContainer( last, btree );
+                    Leaf<K, V> leaf = ( Leaf<K, V> ) ( last.page );
+                    ValueHolder<V> valueHolder = leaf.values[last.pos];
+                    last.valueCursor = valueHolder.getCursor();
                     break;
                 }
             }

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromLeftResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromLeftResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromLeftResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromLeftResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,7 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromRightResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromRightResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromRightResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/BorrowedFromRightResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,7 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Leaf.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Leaf.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Leaf.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Leaf.java Tue Dec 10 20:42:16 2013
@@ -22,8 +22,12 @@ package org.apache.directory.mavibot.btr
 
 import java.io.IOException;
 import java.lang.reflect.Array;
-import java.util.LinkedList;
 
+import org.apache.directory.mavibot.btree.DeleteResult;
+import org.apache.directory.mavibot.btree.InsertResult;
+import org.apache.directory.mavibot.btree.Page;
+import org.apache.directory.mavibot.btree.ParentPos;
+import org.apache.directory.mavibot.btree.Transaction;
 import org.apache.directory.mavibot.btree.Tuple;
 import org.apache.directory.mavibot.btree.TupleCursor;
 import org.apache.directory.mavibot.btree.ValueCursor;
@@ -159,17 +163,9 @@ import org.apache.directory.mavibot.btre
         {
             if ( valueHolder.contains( value ) )
             {
+                keyRemoved = ( valueHolder.size() == 1 );
 
-                if ( valueHolder.size() == 1 )
-                {
-                    removedElement = new Tuple<K, V>( keys[index].getKey(), null ); // the entire value was removed
-                    keyRemoved = true;
-                }
-                else
-                {
-                    removedElement = new Tuple<K, V>( keys[index].getKey(), value ); // only one value was removed
-                    //valueHolder.remove( value );
-                }
+                removedElement = new Tuple<K, V>( keys[index].getKey(), value ); // only one value was removed
             }
             else
             {
@@ -647,8 +643,6 @@ import org.apache.directory.mavibot.btre
         {
             pos = -( pos + 1 );
 
-            cursor = new TupleCursorImpl<K, V>( btree, transaction, null, 0 );
-
             // Start at the beginning of the page
             ParentPos<K, V> parentPos = new ParentPos<K, V>( this, pos );
             
@@ -700,7 +694,7 @@ import org.apache.directory.mavibot.btre
                 // Not found, because there are no elements : return a null cursor
                 stack[depth] = null;
 
-                return new TupleCursorImpl<K, V>( btree, transaction, null, 0 );
+                cursor = new TupleCursorImpl<K, V>( btree, transaction, null, 0 );
             }
         }
 
@@ -804,6 +798,7 @@ import org.apache.directory.mavibot.btre
 
         // Get the previous value from the leaf (it's a copy)
         ValueHolder<V> valueHolder = newLeaf.values[pos];
+        V replacedValue = null;
 
         if ( !valueHolder.contains( value ) )
         {
@@ -815,12 +810,12 @@ import org.apache.directory.mavibot.btre
             // As strange as it sounds, we need to remove the value to reinject it.
             // There are cases where the value retrieval just use one part of the
             // value only (typically for LDAP Entries, where we use the DN)
-            valueHolder.remove( value );
+            replacedValue = valueHolder.remove( value );
             valueHolder.add( value );
         }
 
         // Create the result
-        InsertResult<K, V> result = new ModifyResult<K, V>( newLeaf, ( V ) valueHolder );
+        InsertResult<K, V> result = new ModifyResult<K, V>( newLeaf, replacedValue );
         result.addCopiedPage( this );
 
         return result;

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ManagedBTreeBuilder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ManagedBTreeBuilder.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ManagedBTreeBuilder.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ManagedBTreeBuilder.java Tue Dec 10 20:42:16 2013
@@ -33,6 +33,7 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 import org.apache.directory.mavibot.btree.serializer.ElementSerializer;
 
@@ -88,8 +89,7 @@ public class ManagedBTreeBuilder<K, V>
             
             setKey( leaf1, leafIndex, tuple.getKey() );
 
-            ValueHolder<V> eh = new ValueHolder<V>( btree, btree.getValueSerializer(),
-                tuple.getValue() );
+            ValueHolder<V> eh = new ValueHolder<V>( btree, tuple.getValue() );
 
             setValue( leaf1, leafIndex, eh );
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/MergedWithSiblingResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/MergedWithSiblingResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/MergedWithSiblingResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/MergedWithSiblingResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,7 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ModifyResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ModifyResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ModifyResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ModifyResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,9 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.InsertResult;
+import org.apache.directory.mavibot.btree.Page;
+
 
 /**
  * The result of an insert operation, when the child has not been split. It contains the

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/Node.java Tue Dec 10 20:42:16 2013
@@ -24,6 +24,12 @@ import java.io.IOException;
 import java.lang.reflect.Array;
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.BorrowedFromSiblingResult;
+import org.apache.directory.mavibot.btree.DeleteResult;
+import org.apache.directory.mavibot.btree.InsertResult;
+import org.apache.directory.mavibot.btree.Page;
+import org.apache.directory.mavibot.btree.ParentPos;
+import org.apache.directory.mavibot.btree.Transaction;
 import org.apache.directory.mavibot.btree.Tuple;
 import org.apache.directory.mavibot.btree.TupleCursor;
 import org.apache.directory.mavibot.btree.ValueCursor;
@@ -43,7 +49,7 @@ import org.apache.directory.mavibot.btre
 /* No qualifier */class Node<K, V> extends AbstractPage<K, V>
 {
     /** Children pages associated with keys. */
-    protected ElementHolder<Page<K, V>, K, V>[] children;
+    protected PageHolder<K, V>[] children;
 
 
     /**
@@ -61,7 +67,7 @@ import org.apache.directory.mavibot.btre
         super( btree, revision, nbElems );
 
         // Create the children array
-        children = ( ElementHolder<Page<K, V>, K, V>[] ) Array.newInstance( ElementHolder.class, nbElems + 1 );
+        children = ( PageHolder<K, V>[] ) Array.newInstance( PageHolder.class, nbElems + 1 );
     }
 
 
@@ -109,8 +115,8 @@ import org.apache.directory.mavibot.btre
      * @param rightPage The right page
      */
     @SuppressWarnings("unchecked")
-    /* No qualifier */Node( BTree<K, V> btree, long revision, K key, ElementHolder<Page<K, V>, K, V> leftPage,
-        ElementHolder<Page<K, V>, K, V> rightPage )
+    /* No qualifier */Node( BTree<K, V> btree, long revision, K key, PageHolder<K, V> leftPage,
+        PageHolder<K, V> rightPage )
     {
         super( btree, revision, 1 );
 
@@ -616,7 +622,7 @@ import org.apache.directory.mavibot.btre
         // the current page
         if ( deleteResult instanceof BorrowedFromSiblingResult )
         {
-            RemoveResult<K, V> removeResult = handleBorrowedResult( ( BorrowedFromSiblingResult<K, V> ) deleteResult,
+            RemoveResult<K, V> removeResult = handleBorrowedResult( (org.apache.directory.mavibot.btree.BorrowedFromSiblingResult<K, V> ) deleteResult,
                 pos );
 
             return removeResult;
@@ -942,7 +948,7 @@ import org.apache.directory.mavibot.btre
      * @param pos The position in the values array
      * @param value the value to inject
      */
-    public void setValue( int pos, ElementHolder<Page<K, V>, K, V> value )
+    public void setValue( int pos, PageHolder<K, V> value )
     {
         children[pos] = value;
     }
@@ -1039,9 +1045,9 @@ import org.apache.directory.mavibot.btre
      * @return A holder contaning a reference to the child page
      * @throws IOException If we have an error while trying to access the page
      */
-    private ElementHolder<Page<K, V>, K, V> createHolder( Page<K, V> page ) throws IOException
+    private PageHolder<K, V> createHolder( Page<K, V> page ) throws IOException
     {
-        ElementHolder<Page<K, V>, K, V> holder = btree.getRecordManager().writePage( btree,
+        PageHolder<K, V> holder = btree.getRecordManager().writePage( btree,
             page,
             revision );
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/NotPresentResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/NotPresentResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/NotPresentResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/NotPresentResult.java Tue Dec 10 20:42:16 2013
@@ -20,6 +20,8 @@
 package org.apache.directory.mavibot.btree.managed;
 
 
+import org.apache.directory.mavibot.btree.DeleteResult;
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/PageHolder.java Tue Dec 10 20:42:16 2013
@@ -24,6 +24,7 @@ import java.io.IOException;
 
 import net.sf.ehcache.Element;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
 
 
@@ -38,7 +39,7 @@ import org.apache.directory.mavibot.btre
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class PageHolder<K, V> implements ElementHolder<Page<K, V>, K, V>
+public class PageHolder<K, V>
 {
     /** The BTree */
     private BTree<K, V> btree;
@@ -77,7 +78,6 @@ public class PageHolder<K, V> implements
      * @throws IOException 
      * @throws EndOfFileExceededException 
      */
-    @Override
     public Page<K, V> getValue( BTree<K, V> btree ) throws EndOfFileExceededException, IOException
     {
         Element element = btree.getCache().get( offset );
@@ -93,7 +93,7 @@ public class PageHolder<K, V> implements
             return page;
         }
 
-        Page<K, V> page = ( Page<K, V> ) element.getObjectValue();
+        Page<K, V> page = (org.apache.directory.mavibot.btree.Page<K, V> ) element.getObjectValue();
 
         if ( page == null )
         {

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RecordManager.java Tue Dec 10 20:42:16 2013
@@ -33,6 +33,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.exception.BTreeAlreadyManagedException;
 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
@@ -643,7 +644,7 @@ public class RecordManager
                 
                 // Create the valueHolder. As the number of values is negative, we have to switch
                 // to a positive value but as we start at -1 for 0 value, add 1.
-                valueHolder = new ValueHolder<V>( btree, btree.getValueSerializer(), 1 - nbValues, btreeOffsetBytes );
+                valueHolder = new ValueHolder<V>( btree, 1 - nbValues, btreeOffsetBytes );
             }
             else
             {
@@ -654,7 +655,7 @@ public class RecordManager
                 // This is an Array of values, read the byte[] associated with it
                 byte[] arrayBytes = new byte[valueLengths[i]];
                 byteBuffer.get( arrayBytes );
-                valueHolder = new ValueHolder<V>( btree, btree.getValueSerializer(), nbValues, arrayBytes );
+                valueHolder = new ValueHolder<V>( btree, nbValues, arrayBytes );
             }
 
             BTreeFactory.setValue( leaf, i, valueHolder );
@@ -1912,7 +1913,7 @@ public class RecordManager
      * @return The offset of the new page
      * @throws IOException 
      */
-    /* No qualifier*/<K, V> ElementHolder<Page<K, V>, K, V> writePage( BTree<K, V> btree, Page<K, V> newPage,
+    /* No qualifier*/<K, V> PageHolder<K, V> writePage( BTree<K, V> btree, Page<K, V> newPage,
         long newRevision )
         throws IOException
     {
@@ -1927,7 +1928,7 @@ public class RecordManager
         // Build the resulting reference
         long offset = pageIos[0].getOffset();
         long lastOffset = pageIos[pageIos.length - 1].getOffset();
-        ElementHolder<Page<K, V>, K, V> valueHolder = new PageHolder<K, V>( btree, newPage, offset,
+        PageHolder<K, V> valueHolder = new PageHolder<K, V>( btree, newPage, offset,
             lastOffset );
 
         if ( LOG_CHECK.isDebugEnabled() )

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RemoveResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RemoveResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RemoveResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/RemoveResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,7 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/SplitResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/SplitResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/SplitResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/SplitResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,9 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.InsertResult;
+import org.apache.directory.mavibot.btree.Page;
+
 
 /**
  * The result of an insert operation, when the page has been split. It contains

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/TupleCursorImpl.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/TupleCursorImpl.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/TupleCursorImpl.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/TupleCursorImpl.java Tue Dec 10 20:42:16 2013
@@ -23,6 +23,9 @@ package org.apache.directory.mavibot.btr
 import java.io.IOException;
 import java.util.NoSuchElementException;
 
+import org.apache.directory.mavibot.btree.Page;
+import org.apache.directory.mavibot.btree.ParentPos;
+import org.apache.directory.mavibot.btree.Transaction;
 import org.apache.directory.mavibot.btree.Tuple;
 import org.apache.directory.mavibot.btree.TupleCursor;
 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
@@ -76,11 +79,7 @@ public class TupleCursorImpl<K, V> imple
 
 
     /**
-     * Find the next key/value
-     * 
-     * @return A Tuple containing the found key and value
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * {@inheritDoc}
      */
     public Tuple<K, V> next() throws EndOfFileExceededException, IOException
     {
@@ -141,7 +140,7 @@ public class TupleCursorImpl<K, V> imple
             {
                 parentPos.pos++;
             }
-                
+
             try
             {
                 ValueHolder<V> valueHolder = ( ( Leaf<K, V> ) parentPos.page ).getValue( parentPos.pos );
@@ -189,7 +188,7 @@ public class TupleCursorImpl<K, V> imple
             // is not the last one
             ParentPos<K, V> parentPos = stack[currentDepth];
 
-            if ( parentPos.pos == parentPos.page.getNbElems() )
+            if ( parentPos.pos + 1 > parentPos.page.getNbElems() )
             {
                 // No more element on the right : go up
                 currentDepth--;
@@ -205,15 +204,15 @@ public class TupleCursorImpl<K, V> imple
                 {
                     currentDepth++;
                     parentPos = stack[currentDepth];
-                    parentPos.page = child;
                     parentPos.pos = 0;
-                    child = ((Node<K, V>)parentPos.page).children[parentPos.pos].getValue( btree );
+                    parentPos.page = child;
+                    child = ((Node<K, V>)child).children[0].getValue( btree );
                 }
 
                 // and the leaf
                 parentPos = stack[depth];
-                parentPos.pos = 0;
                 parentPos.page = child;
+                parentPos.pos = 0;
                 parentPos.valueCursor = ((Leaf<K, V>)child).values[0].getCursor();
 
                 return parentPos;
@@ -222,6 +221,106 @@ public class TupleCursorImpl<K, V> imple
 
         return null;
     }
+
+
+    /**
+     * Tells if there is a next ParentPos
+     * 
+     * @return the new ParentPos instance, or null if we have no following leaf
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
+     */
+    private boolean hasNextParentPos() throws EndOfFileExceededException, IOException
+    {
+        if ( depth == 0 )
+        {
+            // No need to go any further, there is only one leaf in the btree
+            return false;
+        }
+
+        int currentDepth = depth - 1;
+        Page<K, V> child = null;
+
+        // First, go up the tree until we find a Node which has some element on the right
+        while ( currentDepth >= 0 )
+        {
+            // We first go up the tree, until we reach a page whose current position
+            // is not the last one
+            ParentPos<K, V> parentPos = stack[currentDepth];
+
+            if ( parentPos.pos + 1 > parentPos.page.getNbElems() )
+            {
+                // No more element on the right : go up
+                currentDepth--;
+            }
+            else
+            {
+                // We can pick the next element at this level
+                child = ((Node<K, V>)parentPos.page).children[parentPos.pos + 1].getValue( btree );
+                
+                // and go down the tree through the nodes
+                while ( currentDepth < depth - 1 )
+                {
+                    currentDepth++;
+                    child = ((Node<K, V>)child).children[0].getValue( btree );
+                }
+
+                return true;
+            }
+        }
+
+        return false;
+    }
+    
+    
+    /**
+     * Tells if there is a prev ParentPos
+     * 
+     * @return the new ParentPos instance, or null if we have no previous leaf
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
+     */
+    private boolean hasPrevParentPos() throws EndOfFileExceededException, IOException
+    {
+        if ( depth == 0 )
+        {
+            // No need to go any further, there is only one leaf in the btree
+            return false;
+        }
+
+        int currentDepth = depth - 1;
+        Page<K, V> child = null;
+
+        // First, go up the tree until we find a Node which has some element on the right
+        while ( currentDepth >= 0 )
+        {
+            // We first go up the tree, until we reach a page whose current position
+            // is not the last one
+            ParentPos<K, V> parentPos = stack[currentDepth];
+
+            if ( parentPos.pos == 0 )
+            {
+                // No more element on the left : go up
+                currentDepth--;
+            }
+            else
+            {
+                // We can pick the previous element at this level
+                child = ((Node<K, V>)parentPos.page).children[parentPos.pos - 1].getValue( btree );
+                
+                // and go down the tree through the nodes
+                while ( currentDepth < depth - 1 )
+                {
+                    currentDepth++;
+                    child = ((Node<K, V>)child).children[child.getNbElems()].getValue( btree );
+                }
+
+                return true;
+            }
+        }
+
+        return false;
+    }
     
     
     /**
@@ -287,11 +386,7 @@ public class TupleCursorImpl<K, V> imple
 
 
     /**
-     * Find the previous key/value
-     * 
-     * @return A Tuple containing the found key and value
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * {@inheritDoc}
      */
     public Tuple<K, V> prev() throws EndOfFileExceededException, IOException
     {
@@ -504,7 +599,7 @@ public class TupleCursorImpl<K, V> imple
 
 
     /**
-     * Closes the cursor, thus releases the associated transaction
+     * {@inheritDoc}
      */
     public void close()
     {
@@ -513,7 +608,7 @@ public class TupleCursorImpl<K, V> imple
 
 
     /**
-     * @return The revision this cursor is based on
+     * {@inheritDoc}
      */
     public long getRevision()
     {
@@ -522,7 +617,7 @@ public class TupleCursorImpl<K, V> imple
 
 
     /**
-     * @return The creation date for this cursor
+     * {@inheritDoc}
      */
     public long getCreationDate()
     {
@@ -554,20 +649,7 @@ public class TupleCursorImpl<K, V> imple
         {
             // End of the leaf. We have to go back into the stack up to the
             // parent, and down to the next leaf
-            parentPos = findNextParentPos();
-
-            // we also need to check the result of the call to
-            // findNextParentPos as it will return a null ParentPos
-            if ( ( parentPos == null ) || ( parentPos.page == null ) )
-            {
-                // This is the end : no more key
-                return false;
-            }
-            else
-            {
-                // We have more keys
-                return true;
-            }
+            return hasNextParentPos();
         }
         else
         {
@@ -664,17 +746,7 @@ public class TupleCursorImpl<K, V> imple
         {
             // Beginning of the leaf. We have to go back into the stack up to the
             // parent, and down to the leaf
-            parentPos = findPrevParentPos();
-
-            if ( ( parentPos == null ) || ( parentPos.page == null ) )
-            {
-                // This is the end : no more key
-                return false;
-            }
-            else
-            {
-                return true;
-            }
+            return hasPrevParentPos();
         }
         else
         {
@@ -778,15 +850,16 @@ public class TupleCursorImpl<K, V> imple
             parentPos.page = child;
         }
         
-        parentPos.valueCursor = ((Leaf<K, V>)parentPos.page).values[0].getCursor();
-        parentPos.valueCursor.beforeFirst();
+        if ( parentPos.valueCursor != null )
+        {
+            parentPos.valueCursor = ((Leaf<K, V>)parentPos.page).values[0].getCursor();
+            parentPos.valueCursor.beforeFirst();
+        }
     }
 
 
     /**
-     * Places the cursor at the end of the last position
-     * 
-     * @throws IOException
+     * {@inheritDoc}
      */
     public void afterLast() throws IOException
     {

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ValueHolder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ValueHolder.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ValueHolder.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/managed/ValueHolder.java Tue Dec 10 20:42:16 2013
@@ -25,6 +25,7 @@ import java.lang.reflect.Array;
 import java.util.Comparator;
 import java.util.UUID;
 
+import org.apache.directory.mavibot.btree.Tuple;
 import org.apache.directory.mavibot.btree.TupleCursor;
 import org.apache.directory.mavibot.btree.ValueCursor;
 import org.apache.directory.mavibot.btree.exception.BTreeAlreadyManagedException;
@@ -57,7 +58,7 @@ public class ValueHolder<V> implements C
     /** A flag to signal that the raw value represent the serialized values in their last state */
     private boolean isRawUpToDate = false;
 
-    /** The RecordManager */
+    /** The parent BTree */
     private BTree<?, V> btree;
 
     /** The Value serializer */
@@ -68,16 +69,15 @@ public class ValueHolder<V> implements C
      * Creates a new instance of a ValueHolder, containing the serialized values.
      * 
      * @param btree the container BTree
-     * @param valueSerializer The Value's serializer
      * @param raw The raw data containing the values
      * @param nbValues the number of stored values
      * @param raw the byte[] containing either the serialized array of values or the sub-btree offset
      */
-    /* No qualifier */ValueHolder( BTree<?, V> btree, ElementSerializer<V> valueSerializer, int nbValues, byte[] raw )
+    /* No qualifier */ValueHolder( BTree<?, V> btree, int nbValues, byte[] raw )
     {
-        this.valueSerializer = valueSerializer;
-        this.raw = raw;
         this.btree = btree;
+        this.valueSerializer = btree.getValueSerializer();
+        this.raw = raw;
         isRawUpToDate = true;
 
         // We create the array of values if they fit in an array. If they are stored in a 
@@ -97,10 +97,10 @@ public class ValueHolder<V> implements C
      * @param valueSerializer The Value's serializer
      * @param values The Values stored in the ValueHolder
      */
-    /* No qualifier */ValueHolder( BTree<?, V> btree, ElementSerializer<V> valueSerializer, V... values )
+    /* No qualifier */ValueHolder( BTree<?, V> btree, V... values )
     {
-        this.valueSerializer = valueSerializer;
         this.btree = btree;
+        this.valueSerializer = btree.getValueSerializer();
 
         if ( values != null )
         {
@@ -767,7 +767,7 @@ public class ValueHolder<V> implements C
     /**
      * Remove a value from an array
      */
-    private void removeFromArray( V value )
+    private V removeFromArray( V value )
     {
         checkAndDeserialize();
 
@@ -777,7 +777,7 @@ public class ValueHolder<V> implements C
         if ( pos < 0 )
         {
             // The value does not exists : nothing to do
-            return;
+            return null;
         }
 
         // Ok, we just have to delete the new element at the right position
@@ -787,20 +787,25 @@ public class ValueHolder<V> implements C
         System.arraycopy( valueArray, 0, newValueArray, 0, pos );
         System.arraycopy( valueArray, pos + 1, newValueArray, pos, valueArray.length - pos - 1 );
 
+        // Get the removed element
+        V removedValue = valueArray[pos];
+        
         // And switch the arrays
         valueArray = newValueArray;
+        
+        return removedValue;
     }
 
     
     /**
      * Remove the value from a sub btree
      */
-    private void removeFromBtree( V value )
+    private V removeFromBtree( V removedValue )
     {
         // First check that we have a loaded BTree
         checkAndDeserialize();
 
-        if ( btreeContains( value ) )
+        if ( btreeContains( removedValue ) )
         {
             try
             {
@@ -811,19 +816,55 @@ public class ValueHolder<V> implements C
                     // We have to switch to an Array of values
                     valueArray = ( V[] ) Array.newInstance( valueSerializer.getType(), nbValues );
     
-                    // Now copy all the value sbut the one we have removed
+                    // Now copy all the value but the one we have removed
+                    TupleCursor<V,V> cursor = valueBtree.browse();
+                    V returnedValue = null;
+                    int pos = 0;
+                    
+                    while ( cursor.hasNext() )
+                    {
+                        Tuple<V, V> tuple = cursor.next();
+                        
+                        V value = tuple.getKey();
+                        
+                        if ( valueSerializer.getComparator().compare( removedValue, value ) == 0 )
+                        {
+                            // This is the removed value : skip it
+                            returnedValue = value;
+                        }
+                        else
+                        {
+                            valueArray[pos++] = value;
+                        }
+                    }
+                    
+                    return returnedValue;
                 }
                 else
                 {
-                    valueBtree.delete( value );
+                    Tuple<V, V> removedTuple = valueBtree.delete( removedValue );
+                    
+                    if ( removedTuple != null )
+                    {
+                        return removedTuple.getKey();
+                    }
+                    else
+                    {
+                        return null;
+                    }
                 }
             }
             catch ( IOException e )
             {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
+                return null;
             }
         }
+        else
+        {
+            return null;
+        }
     }
 
     /**
@@ -831,20 +872,24 @@ public class ValueHolder<V> implements C
      * 
      * @param value The added value
      */
-    public void remove( V value )
+    public V remove( V value )
     {
+        V removedValue = null;
+        
         if ( valueArray != null )
         {
-            removeFromArray( value );
+            removedValue = removeFromArray( value );
         }
         else
         {
-            removeFromBtree( value );
+            removedValue = removeFromBtree( value );
         }
 
         // The raw value is not anymore up to date wth the content
         isRawUpToDate = false;
         raw = null;
+        
+        return removedValue;
     }
     
     

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractBorrowedFromSiblingResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractBorrowedFromSiblingResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractBorrowedFromSiblingResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractBorrowedFromSiblingResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,7 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractDeleteResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractDeleteResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractDeleteResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractDeleteResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,8 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.DeleteResult;
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

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=1549961&r1=1549960&r2=1549961&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 10 20:42:16 2013
@@ -23,6 +23,7 @@ package org.apache.directory.mavibot.btr
 import java.io.IOException;
 import java.lang.reflect.Array;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 
 
@@ -114,8 +115,8 @@ import org.apache.directory.mavibot.btre
             return parentPos - 1;
         }
 
-        Page<K, V> prevPage = parent.children[parentPos - 1].getValue();
-        Page<K, V> nextPage = parent.children[parentPos + 1].getValue();
+        Page<K, V> prevPage = parent.children[parentPos - 1];
+        Page<K, V> nextPage = parent.children[parentPos + 1];
 
         int prevPageSize = prevPage.getNbElems();
         int nextPageSize = nextPage.getNbElems();

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/AbstractResult.java Tue Dec 10 20:42:16 2013
@@ -23,6 +23,7 @@ package org.apache.directory.mavibot.btr
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Result;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTree.java Tue Dec 10 20:42:16 2013
@@ -39,10 +39,16 @@ import net.sf.ehcache.config.CacheConfig
 
 import org.apache.directory.mavibot.btree.Addition;
 import org.apache.directory.mavibot.btree.BTreeHeader;
+import org.apache.directory.mavibot.btree.DeleteResult;
 import org.apache.directory.mavibot.btree.Deletion;
+import org.apache.directory.mavibot.btree.InsertResult;
 import org.apache.directory.mavibot.btree.Modification;
+import org.apache.directory.mavibot.btree.Page;
+import org.apache.directory.mavibot.btree.ParentPos;
+import org.apache.directory.mavibot.btree.Transaction;
 import org.apache.directory.mavibot.btree.Tuple;
 import org.apache.directory.mavibot.btree.TupleCursor;
+import org.apache.directory.mavibot.btree.ValueCursor;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 import org.apache.directory.mavibot.btree.serializer.BufferHandler;
 import org.apache.directory.mavibot.btree.serializer.ElementSerializer;
@@ -824,7 +830,7 @@ public class BTree<K, V> implements Clos
     /**
      * @see Page#getValues(Object)
      */
-    public DuplicateKeyVal<V> getValues( K key ) throws IOException, KeyNotFoundException
+    public ValueCursor<V> getValues( K key ) throws IOException, KeyNotFoundException
     {
         return rootPage.getValues( key );
     }
@@ -934,6 +940,9 @@ public class BTree<K, V> implements Clos
 
         // Fetch the root page for this revision
         TupleCursor<K, V> cursor = rootPage.browse( transaction, new ParentPos[32], 0 );
+        
+        // Set the position before the first element
+        cursor.beforeFirst();
 
         return cursor;
     }
@@ -1499,28 +1508,9 @@ public class BTree<K, V> implements Clos
      * @param value The value to store
      * @return The value holder
      */
-    /* no qualifier */ElementHolder<V, K, V> createValueHolder( V value )
+    /* no qualifier */ValueHolder<V> createValueHolder( V value )
     {
-        if ( isAllowDuplicates() )
-        {
-            return new MultipleMemoryHolder<K, V>( this, value );
-        }
-        else
-        {
-            return new MemoryHolder( this, value );
-        }
-    }
-
-
-    /**
-     * Create a ValueHolder depending on the kind of holder we want.
-     * 
-     * @param value The value to store
-     * @return The value holder
-     */
-    /* no qualifier */ElementHolder<Page<K, V>, K, V> createPageHolder( Page<K, V> value )
-    {
-        return new MemoryHolder( this, value );
+        return new ValueHolder<V>( this, value );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeBuilder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeBuilder.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeBuilder.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BTreeBuilder.java Tue Dec 10 20:42:16 2013
@@ -32,6 +32,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 import org.apache.directory.mavibot.btree.serializer.ElementSerializer;
 
@@ -82,7 +83,7 @@ public class BTreeBuilder<K, V>
 
             setKey( leaf1, leafIndex, tuple.getKey() );
 
-            MemoryHolder<K, V> eh = new MemoryHolder<K, V>( btree, tuple.getValue() );
+            ValueHolder<V> eh = new ValueHolder<V>( btree, tuple.getValue() );
 
             setValue( leaf1, leafIndex, eh );
 
@@ -115,8 +116,8 @@ public class BTreeBuilder<K, V>
                 lastLeaf.keys = ( K[] ) Array.newInstance( keyType, n );
                 System.arraycopy( keys, 0, lastLeaf.keys, 0, n );
 
-                ElementHolder<V, K, V>[] values = lastLeaf.values;
-                lastLeaf.values = ( MemoryHolder<K, V>[] ) Array.newInstance( MemoryHolder.class, n );
+                ValueHolder<V>[] values = lastLeaf.values;
+                lastLeaf.values = ( ValueHolder<V>[] ) Array.newInstance( ValueHolder.class, n );
                 System.arraycopy( values, 0, lastLeaf.values, 0, n );
 
                 break;
@@ -157,7 +158,7 @@ public class BTreeBuilder<K, V>
                 setKey( node, i - 1, p.getLeftMostKey() );
             }
 
-            node.children[i] = btree.createPageHolder( p );
+            node.children[i] = p;
 
             i++;
             totalNodes++;

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=1549961&r1=1549960&r2=1549961&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 10 20:42:16 2013
@@ -23,6 +23,8 @@ package org.apache.directory.mavibot.btr
 import java.io.IOException;
 import java.util.LinkedList;
 
+import org.apache.directory.mavibot.btree.Page;
+import org.apache.directory.mavibot.btree.ParentPos;
 import org.apache.directory.mavibot.btree.serializer.ElementSerializer;
 
 
@@ -215,7 +217,7 @@ public class BTreeFactory
      * @param pos The position in the values array
      * @param value the value to inject
      */
-    public static <K, V> void setValue( Leaf<K, V> page, int pos, ElementHolder<V, K, V> value )
+    public static <K, V> void setValue( Leaf<K, V> page, int pos, ValueHolder<V> value )
     {
         page.setValue( pos, value );
     }
@@ -226,9 +228,9 @@ 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, ElementHolder<Page<K, V>, K, V> value )
+    public static <K, V> void setValue( Node<K, V> page, int pos, Page<K, V> value )
     {
-        page.setValue( pos, value );
+        page.children[pos] = value;
     }
 
 
@@ -248,7 +250,9 @@ public class BTreeFactory
 
         if ( btree.rootPage instanceof Leaf )
         {
-            InternalUtil.setLastDupsContainer( last, btree );
+            Leaf<K, V> leaf = ( Leaf<K, V> ) ( btree.rootPage );
+            ValueHolder<V> valueHolder = leaf.values[last.pos];
+            last.valueCursor = valueHolder.getCursor();
         }
         else
         {
@@ -256,14 +260,16 @@ public class BTreeFactory
 
             while ( true )
             {
-                Page<K, V> p = node.children[node.getNbElems()].getValue();
+                Page<K, V> p = node.children[node.getNbElems()];
 
                 last = new ParentPos<K, V>( p, p.getNbElems() );
                 stack.push( last );
 
                 if ( p instanceof Leaf )
                 {
-                    InternalUtil.setLastDupsContainer( last, btree );
+                    Leaf<K, V> leaf = ( Leaf<K, V> ) ( last.page );
+                    ValueHolder<V> valueHolder = leaf.values[last.pos];
+                    last.valueCursor = valueHolder.getCursor();
                     break;
                 }
             }

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromLeftResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromLeftResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromLeftResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromLeftResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,7 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromRightResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromRightResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromRightResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromRightResult.java Tue Dec 10 20:42:16 2013
@@ -22,6 +22,7 @@ package org.apache.directory.mavibot.btr
 
 import java.util.List;
 
+import org.apache.directory.mavibot.btree.Page;
 import org.apache.directory.mavibot.btree.Tuple;
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromSiblingResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromSiblingResult.java?rev=1549961&r1=1549960&r2=1549961&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromSiblingResult.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BorrowedFromSiblingResult.java Tue Dec 10 20:42:16 2013
@@ -19,6 +19,9 @@
  */
 package org.apache.directory.mavibot.btree.memory;
 
+import org.apache.directory.mavibot.btree.DeleteResult;
+import org.apache.directory.mavibot.btree.Page;
+
 
 /**
  * The result of an delete operation, when we have borrowed some element from a sibling.



Mime
View raw message