You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by el...@apache.org on 2013/03/30 20:13:05 UTC
svn commit: r1462846 -
/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java
Author: elecharny
Date: Sat Mar 30 19:13:05 2013
New Revision: 1462846
URL: http://svn.apache.org/r1462846
Log:
Merged changes made by Kiran with my local changes
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java
Modified: labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java
URL: http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java?rev=1462846&r1=1462845&r2=1462846&view=diff
==============================================================================
--- labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java (original)
+++ labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/AbstractPage.java Sat Mar 30 19:13:05 2013
@@ -23,8 +23,6 @@ package org.apache.mavibot.btree;
import java.io.IOException;
import java.lang.reflect.Array;
-import org.apache.mavibot.btree.exception.EndOfFileExceededException;
-
/**
* A MVCC abstract Page. It stores the field and the methods shared by the Node and Leaf
@@ -83,16 +81,15 @@ public abstract class AbstractPage<K, V>
/**
- * Select the sibling (the prev or next page with the same parent) which has
+ * Selects the sibling (the previous or next page with the same parent) which has
* the more element assuming it's above N/2
*
* @param parent The parent of the current page
* @param The position of the current page reference in its parent
* @return The position of the sibling, or -1 if we have'nt found any sibling
- * @throws IOException
- * @throws EndOfFileExceededException
+ * @throws IOException If we have an error while trying to access the page
*/
- protected int selectSibling( Node<K, V> parent, int parentPos ) throws EndOfFileExceededException, IOException
+ protected int selectSibling( Node<K, V> parent, int parentPos ) throws IOException
{
if ( parentPos == 0 )
{
@@ -135,7 +132,40 @@ public abstract class AbstractPage<K, V>
/**
- * {@inheritDoc}
+ * Finds the position of the given key in the page. If we have found the key,
+ * we will return its position as a negative value.
+ * <p/>
+ * Assuming that the array is zero-indexed, the returned value will be : <br/>
+ * position = - ( position + 1)
+ * <br/>
+ * So for the following table of keys : <br/>
+ * <pre>
+ * +---+---+---+---+
+ * | b | d | f | h |
+ * +---+---+---+---+
+ * 0 1 2 3
+ * </pre>
+ * looking for 'b' will return -1 (-(0+1)) and looking for 'f' will return -3 (-(2+1)).<br/>
+ * Computing the real position is just a matter to get -(position++).
+ * <p/>
+ * If we don't find the key in the table, we will return the position of the key
+ * immediately above the key we are looking for. <br/>
+ * For instance, looking for :
+ * <ul>
+ * <li>'a' will return 0</li>
+ * <li>'b' will return -1</li>
+ * <li>'c' will return 1</li>
+ * <li>'d' will return -2</li>
+ * <li>'e' will return 2</li>
+ * <li>'f' will return -3</li>
+ * <li>'g' will return 3</li>
+ * <li>'h' will return -4</li>
+ * <li>'i' will return 4</li>
+ * </ul>
+ *
+ *
+ * @param key The key to find
+ * @return The position in the page.
*/
public int findPos( K key )
{
@@ -194,7 +224,7 @@ public abstract class AbstractPage<K, V>
/**
- * Compare two keys
+ * Compares two keys
*
* @param key1 The first key
* @param key2 The second key
@@ -248,7 +278,8 @@ public abstract class AbstractPage<K, V>
/**
- * Set the key at a give position
+ * Sets the key at a give position
+ *
* @param pos The position in the keys array
* @param key the key to inject
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org