Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5EC4410380 for ; Tue, 3 Dec 2013 15:13:17 +0000 (UTC) Received: (qmail 19798 invoked by uid 500); 3 Dec 2013 15:12:32 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 19430 invoked by uid 500); 3 Dec 2013 15:12:10 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 19409 invoked by uid 99); 3 Dec 2013 15:12:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Dec 2013 15:12:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Dec 2013 15:12:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 89B062388A38; Tue, 3 Dec 2013 15:11:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131203151145.89B062388A38@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 prevPage = parent.children[parentPos - 1].getValue( btree ); - Page nextPage = parent.children[parentPos + 1].getValue( btree ); + Page prevPage = parent.children[parentPos - 1].getValue(); + Page 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 p = node.children[node.getNbElems()].getValue( btree ); + Page p = node.children[node.getNbElems()].getValue(); last = new ParentPos( 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 /** * Get back the element * - * @param btree The Btree storing the element - * * @return The stored element */ - E getValue( BTree 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 or { @@ -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 ) parent, parentPos ); - Leaf sibling = ( Leaf ) ( ( ( Node ) parent ).children[siblingPos].getValue( btree ) ); + Leaf sibling = ( Leaf ) ( ( ( Node ) parent ).children[siblingPos].getValue() ); if ( sibling.getNbElems() == halfSize ) { @@ -537,17 +538,17 @@ import org.apache.directory.mavibot.btre MultipleMemoryHolder mvHolder = ( MultipleMemoryHolder ) 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 dupTree = ( BTree ) mvHolder.getValue( btree ); + BTree dupTree = ( BTree ) 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( mvHolder.getValue( btree ) ); + return new DuplicateKeyVal( mvHolder.getValue() ); } - return new DuplicateKeyVal( ( BTree ) mvHolder.getValue( btree ) ); + return new DuplicateKeyVal( ( BTree ) mvHolder.getValue() ); } else { @@ -617,18 +618,18 @@ import org.apache.directory.mavibot.btre MultipleMemoryHolder mvHolder = ( MultipleMemoryHolder ) 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 dupTree = ( ( BTree ) mvHolder.getValue( btree ) ); + BTree dupTree = ( ( BTree ) 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 browse( K key, Transaction transaction, ParentPos[] stack, int depth ) + public TupleCursor browse( K key, Transaction transaction, ParentPos[] stack, int depth ) { int pos = findPos( key ); - TupleCursorImpl cursor = null; + TupleCursor cursor = null; if ( pos < 0 ) { @@ -713,10 +714,10 @@ import org.apache.directory.mavibot.btre /** * {@inheritDoc} */ - public TupleCursorImpl browse( Transaction transaction, ParentPos[] stack, int depth ) + public TupleCursor browse( Transaction transaction, ParentPos[] stack, int depth ) { int pos = 0; - TupleCursorImpl cursor = null; + TupleCursor 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 dupValues = ( BTree ) mvHolder.getValue( btree ); + BTree dupValues = ( BTree ) 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 dupTree = ( BTree ) values[0].getValue( btree ); + BTree dupTree = ( BTree ) values[0].getValue(); val = dupTree.rootPage.getLeftMostKey(); } else { - val = values[0].getValue( btree ); + val = values[0].getValue(); } return new Tuple( keys[0], val ); @@ -1023,12 +1024,12 @@ import org.apache.directory.mavibot.btre if ( btree.isAllowDuplicates() ) { - BTree dupTree = ( BTree ) values[nbElems - 1].getValue( btree ); + BTree dupTree = ( BTree ) values[nbElems - 1].getValue(); val = dupTree.rootPage.getRightMostKey(); } else { - val = values[nbElems - 1].getValue( btree ); + val = values[nbElems - 1].getValue(); } return new Tuple( 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 implemen * {@inheritDoc} */ @Override - public V getValue( BTree btree ) + public V getValue() { return value; } @@ -69,7 +69,7 @@ public class MemoryHolder 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 * {@inheritDoc} */ @Override - public V getValue( BTree btree ) + public V getValue() { if ( valueContainer != null ) { @@ -167,7 +167,7 @@ public class MultipleMemoryHolder 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 tuple - Page child = children[pos].getValue( btree ); + Page child = children[pos].getValue(); // and insert the into this child InsertResult 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 newSibling = new Node( 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 sibling, int pos ) throws IOException { // The sibling is on the left, borrow the rightmost element - Page siblingChild = sibling.children[sibling.nbElems].getValue( btree ); + Page siblingChild = sibling.children[sibling.nbElems].getValue(); // Create the new sibling, with one less element at the end Node newSibling = new Node( 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 ) parent, parentPos ); - Node sibling = ( Node ) ( ( ( Node ) parent ).children[siblingPos].getValue( btree ) ); + Node sibling = ( Node ) ( ( ( Node ) 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 page = children[pos].getValue( btree ); + Page 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 browse( K key, Transaction transaction, ParentPos[] stack, int depth ) + public TupleCursor browse( K key, Transaction transaction, ParentPos[] 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( this, pos ); - Page page = children[pos].getValue( btree ); + Page page = children[pos].getValue(); return page.browse( key, transaction, stack, depth ); } @@ -964,12 +965,12 @@ import org.apache.directory.mavibot.btre /** * {@inheritDoc} */ - public TupleCursorImpl browse( Transaction transaction, ParentPos[] stack, int depth ) + public TupleCursor browse( Transaction transaction, ParentPos[] stack, int depth ) throws IOException { stack[depth++] = new ParentPos( this, 0 ); - Page page = children[0].getValue( btree ); + Page 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 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 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 browse( K key, Transaction transaction, ParentPos[] stack, int depth ) + TupleCursor browse( K key, Transaction transaction, ParentPos[] 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 browse( Transaction transaction, ParentPos[] stack, int depth ) + TupleCursor browse( Transaction transaction, ParentPos[] 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 */ - /* No qualifier*/BTree dupsContainer; + /* No qualifier*/BTree 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 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 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 imple { // We can pick the next element at this level parentPos.pos++; - child = ((Node)parentPos.page).children[parentPos.pos].getValue( btree ); + child = ((Node)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 imple parentPos = stack[currentDepth]; parentPos.page = child; parentPos.pos = 0; - child = ((Node)parentPos.page).children[parentPos.pos].getValue( btree ); + child = ((Node)parentPos.page).children[parentPos.pos].getValue(); } // and the leaf @@ -257,7 +257,7 @@ public class TupleCursorImpl imple { // We can pick the next element at this level parentPos.pos--; - child = ((Node)parentPos.page).children[parentPos.pos].getValue( btree ); + child = ((Node)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 imple parentPos = stack[currentDepth]; parentPos.pos = child.getNbElems(); parentPos.page = child; - child = ((Node)parentPos.page).children[((Node)parentPos.page).nbElems].getValue( btree ); + child = ((Node)parentPos.page).children[((Node)parentPos.page).nbElems].getValue(); } // and the leaf @@ -354,7 +354,7 @@ public class TupleCursorImpl 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 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 imple changePrevDupsContainer( parentPos, btree ); parentPos.pos--; - if ( parentPos.dupsContainer != null ) + if ( parentPos.valueCursor != null ) { parentPos.dupPos--; } @@ -391,13 +391,13 @@ public class TupleCursorImpl 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 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 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 imple if( !mvHolder.isSingleValue() ) { - BTree dupsContainer = ( BTree ) mvHolder.getValue( btree ); - parentPos.dupsContainer = dupsContainer; + BTree valueCursor = ( BTree ) mvHolder.getValue(); + parentPos.valueCursor = valueCursor; parentPos.dupPos = 0; } - TupleCursor cursor = parentPos.dupsContainer.browse(); + TupleCursor cursor = parentPos.valueCursor.browse(); cursor.beforeFirst(); V value = cursor.next().getKey(); @@ -676,7 +676,7 @@ public class TupleCursorImpl 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 imple if( !mvHolder.isSingleValue() ) { - BTree dupsContainer = ( BTree ) mvHolder.getValue( btree ); - parentPos.dupsContainer = dupsContainer; + parentPos.valueCursor = ( BTree ) mvHolder.getValue(); parentPos.dupPos = 0; } - TupleCursor cursor = parentPos.dupsContainer.browse(); + TupleCursor cursor = parentPos.valueCursor.browse(); cursor.beforeFirst(); V value = cursor.next().getKey(); @@ -811,7 +810,7 @@ public class TupleCursorImpl 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 imple parentPos.page = child; } - child = ((Node)parentPos.page).children[0].getValue( btree ); + child = ((Node)parentPos.page).children[0].getValue(); } // and leaf @@ -876,6 +875,7 @@ public class TupleCursorImpl imple Page child = null; + // Go fown the tree picking the rightmost element of each Node for ( int i = 0; i < depth; i++ ) { ParentPos parentPos = stack[i]; @@ -891,20 +891,15 @@ public class TupleCursorImpl imple parentPos.pos = ((Node)parentPos.page).nbElems; } - child = ((Node)parentPos.page).children[parentPos.pos].getValue( btree ); + child = ((Node)parentPos.page).children[parentPos.pos].getValue(); } - // and leaf + // and now, the leaf ParentPos parentPos = stack[depth]; - if ( child == null ) - { - parentPos.pos = ((Leaf)parentPos.page).nbElems - 1; - } - else + if ( child != null ) { parentPos.page = child; - parentPos.pos = ((Leaf)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() );