Author: elecharny
Date: Sun Jul 29 13:00:24 2012
New Revision: 1366842

URL: http://svn.apache.org/viewvc?rev=1366842&view=rev
Log:
o Added a getLeftMostKey() method to avoid creating a tuple 
o Added some Javadoc

Modified:
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java
    labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java?rev=1366842&r1=1366841&r2=1366842&view=diff
==============================================================================
--- 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java 
(original)
+++ 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java 
Sun Jul 29 13:00:24 2012
@@ -428,6 +428,11 @@ public class BTree<K, V>
     }
 
 
+    /**
+     * Starts a Read Only transaction. If the transaction is not closed, it 
will be 
+     * automatically closed after the timeout
+     * @return
+     */
     public Transaction<K, V> beginReadTransaction()
     {
         Transaction<K, V> readTransaction = new Transaction<K, V>( this, 
revision.get() - 1, System.currentTimeMillis() );
@@ -436,7 +441,12 @@ public class BTree<K, V>
     }
 
 
-    public void commitTransaction( Transaction transaction )
+    /**
+     * Validate the transaction. 
+     *  
+     * @param transaction The transaction to commit
+     */
+    public void commitTransaction( Transaction<K, V> transaction )
     {
 
     }

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java?rev=1366842&r1=1366841&r2=1366842&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java 
(original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java 
Sun Jul 29 13:00:24 2012
@@ -627,6 +627,15 @@ public class Leaf<K, V> extends Abstract
     /**
      * {@inheritDoc}
      */
+    public K getLeftMostKey()
+    {
+        return keys[0];
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public Tuple<K, V> findLeftMost()
     {
         return new Tuple<K, V>( keys[0], values[0] );

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java?rev=1366842&r1=1366841&r2=1366842&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java 
(original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Node.java 
Sun Jul 29 13:00:24 2012
@@ -167,7 +167,7 @@ import java.util.LinkedList;
 
         if ( pos < 0 )
         {
-            newPage.keys[index] = 
removeResult.getModifiedPage().findLeftMost().getKey();
+            newPage.keys[index] = 
removeResult.getModifiedPage().getLeftMostKey();
         }
 
         // Modify the result and return
@@ -226,7 +226,7 @@ import java.util.LinkedList;
         // Create the new sibling, with one less element at the beginning
         Node<K, V> newSibling = new Node<K, V>( btree, revision, 
sibling.getNbElems() - 1 );
 
-        K siblingKey = sibling.children[0].findLeftMost().getKey();
+        K siblingKey = sibling.children[0].getLeftMostKey();
 
         // Copy the keys and children of the old sibling in the new sibling
         System.arraycopy( sibling.keys, 1, newSibling.keys, 0, 
newSibling.getNbElems() );
@@ -263,7 +263,7 @@ import java.util.LinkedList;
             }
 
             // Inject the new modified page key
-            newNode.keys[index - 2] = 
mergedResult.getModifiedPage().findLeftMost().getKey(); // 2
+            newNode.keys[index - 2] = 
mergedResult.getModifiedPage().getLeftMostKey(); // 2
 
             if ( index < nbElems )
             {
@@ -323,7 +323,7 @@ import java.util.LinkedList;
 
         if ( index < 2 )
         {
-            newNode.keys[0] = 
mergedResult.getModifiedPage().findLeftMost().getKey();
+            newNode.keys[0] = mergedResult.getModifiedPage().getLeftMostKey();
             System.arraycopy( keys, 1, newNode.keys, 1, nbElems - 1 );
 
             newNode.children[1] = mergedResult.getModifiedPage();
@@ -332,7 +332,7 @@ import java.util.LinkedList;
         else
         {
             // Set the first key
-            newNode.keys[0] = children[0].findLeftMost().getKey(); //2
+            newNode.keys[0] = children[0].getLeftMostKey(); //2
 
             if ( index > 2 )
             {
@@ -341,7 +341,7 @@ import java.util.LinkedList;
             }
 
             // Inject the modified key
-            newNode.keys[index - 1] = 
mergedResult.getModifiedPage().findLeftMost().getKey(); // 3
+            newNode.keys[index - 1] = 
mergedResult.getModifiedPage().getLeftMostKey(); // 3
 
             if ( index < nbElems )
             {
@@ -395,7 +395,7 @@ import java.util.LinkedList;
             // Then copy all the elements up to the deletion point
             if ( index < 2 )
             {
-                newNode.keys[half] = 
mergedResult.getModifiedPage().findLeftMost().getKey();
+                newNode.keys[half] = 
mergedResult.getModifiedPage().getLeftMostKey();
                 System.arraycopy( keys, 1, newNode.keys, half + 1, half - 1 );
 
                 newNode.children[half + 1] = mergedResult.getModifiedPage();
@@ -405,7 +405,7 @@ import java.util.LinkedList;
             {
                 // Copy the left part of the node keys up to the deletion point
                 // Insert the new key
-                newNode.keys[half] = children[0].findLeftMost().getKey(); // 3
+                newNode.keys[half] = children[0].getLeftMostKey(); // 3
 
                 if ( index > 2 )
                 {
@@ -413,7 +413,7 @@ import java.util.LinkedList;
                 }
 
                 // Inject the new merged key
-                newNode.keys[half + index - 1] = 
mergedResult.getModifiedPage().findLeftMost().getKey(); //5
+                newNode.keys[half + index - 1] = 
mergedResult.getModifiedPage().getLeftMostKey(); //5
 
                 if ( index < half )
                 {
@@ -455,7 +455,7 @@ import java.util.LinkedList;
                 System.arraycopy( children, 0, newNode.children, 0, index - 1 
); //6
 
                 // Inject the modified key
-                newNode.keys[index - 2] = 
mergedResult.getModifiedPage().findLeftMost().getKey(); //2
+                newNode.keys[index - 2] = 
mergedResult.getModifiedPage().getLeftMostKey(); //2
 
                 // Inject the modified children
                 newNode.children[index - 1] = mergedResult.getModifiedPage(); 
// 7
@@ -974,6 +974,15 @@ import java.util.LinkedList;
     /**
      * {@inheritDoc}
      */
+    public K getLeftMostKey()
+    {
+        return children[0].getLeftMostKey();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public Tuple<K, V> findLeftMost()
     {
         return children[0].findLeftMost();

Modified: 
labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java
URL: 
http://svn.apache.org/viewvc/labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java?rev=1366842&r1=1366841&r2=1366842&view=diff
==============================================================================
--- labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java 
(original)
+++ labs/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/btree/Page.java 
Sun Jul 29 13:00:24 2012
@@ -125,6 +125,15 @@ import java.util.LinkedList;
 
 
     /**
+     * Find the leftmost key in this page. If the page is a node, it will go
+     * down in the leftmost children to recursively find the leftmost key.
+     * 
+     * @return The leftmost key in the tree
+     */
+    K getLeftMostKey();
+
+
+    /**
      * Find the leftmost element in this page. If the page is a node, it will 
go
      * down in the leftmost children to recursively find the leftmost element.
      * 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to