o Fixed the hasNext() method which was returning false when teh cursor was on the...
authorEmmanuel Lécharny <elecharny@apache.org>
Fri, 13 Feb 2015 13:40:11 +0000 (13:40 +0000)
committerEmmanuel Lécharny <elecharny@apache.org>
Fri, 13 Feb 2015 13:40:11 +0000 (13:40 +0000)
mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java

index 626b88d..14dd560 100644 (file)
@@ -196,6 +196,25 @@ public class TupleCursor<K, V>
 
         if ( parentPos.pos == AFTER_LAST )
         {
+            // Ok, here, we have reached the last value in the leaf. We have to go up and
+            // see if we have some remaining values
+            int currentDepth = depth - 1;
+
+            while ( currentDepth >= 0 )
+            {
+                parentPos = stack[currentDepth];
+
+                if ( parentPos.pos < parentPos.page.getNbElems() )
+                {
+                    // The parent has some remaining values on the right, get out
+                    return true;
+                }
+                else
+                {
+                    currentDepth--;
+                }
+            }
+
             return false;
         }