Author: kayyagari
Date: Wed Apr 10 05:07:44 2013
New Revision: 1466336
URL: http://svn.apache.org/r1466336
Log:
added a method to get the multiple values of a key
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Node.java
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Page.java
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java?rev=1466336&r1=1466335&r2=1466336&view=diff
==============================================================================
---
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
(original)
+++
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/BTree.java
Wed Apr 10 05:07:44 2013
@@ -969,6 +969,15 @@ public class BTree<K, V>
/**
+ * @see Page#getValues(Object)
+ */
+ public BTree<V,V> getValues( K key ) throws IOException,
KeyNotFoundException
+ {
+ return rootPage.getValues( key );
+ }
+
+
+ /**
* Find a value in the tree, given its key, at a specific revision. If the
key is not found,
* it will throw a KeyNotFoundException. <br/>
* Note that we can get a null value stored, or many values.
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java?rev=1466336&r1=1466335&r2=1466336&view=diff
==============================================================================
---
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
(original)
+++
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Leaf.java
Wed Apr 10 05:07:44 2013
@@ -491,6 +491,32 @@ import org.apache.mavibot.btree.exceptio
/**
* {@inheritDoc}
*/
+ @Override
+ public BTree<V, V> getValues( K key ) throws KeyNotFoundException,
IOException, IllegalArgumentException
+ {
+ if( !btree.isAllowDuplicates() )
+ {
+ throw new IllegalArgumentException( "Duplicates are not allowed in
this tree" );
+ }
+
+ int pos = findPos( key );
+
+ if ( pos < 0 )
+ {
+ V v = values[-( pos + 1 )].getValue( btree );
+
+ return ( ( BTree<V, V> ) v );
+ }
+ else
+ {
+ throw new KeyNotFoundException( "Cannot find an entry for key " +
key );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public boolean hasKey( K key )
{
int pos = findPos( key );
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Node.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Node.java?rev=1466336&r1=1466335&r2=1466336&view=diff
==============================================================================
---
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Node.java
(original)
+++
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Node.java
Wed Apr 10 05:07:44 2013
@@ -833,6 +833,27 @@ import org.apache.mavibot.btree.exceptio
* {@inheritDoc}
*/
@Override
+ public BTree<V, V> getValues( K key ) throws KeyNotFoundException,
IOException, IllegalArgumentException
+ {
+ int pos = findPos( key );
+
+ if ( pos < 0 )
+ {
+ // 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 );
+ }
+ else
+ {
+ return children[pos].getValue( btree ).getValues( key );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean hasKey( K key ) throws IOException
{
int pos = findPos( key );
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Page.java
URL:
http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Page.java?rev=1466336&r1=1466335&r2=1466336&view=diff
==============================================================================
---
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Page.java
(original)
+++
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/Page.java
Wed Apr 10 05:07:44 2013
@@ -95,7 +95,22 @@ import org.apache.mavibot.btree.exceptio
*/
V get( K key ) throws KeyNotFoundException, IOException;
+
+ /**
+ * Gets the values associated with the given key, if any. If we don't have
+ * the key, this method will throw a KeyNotFoundException.<br/>
+ * Note that we may get back null if a null value has been associated
+ * with the key.
+ *
+ * @param key The key we are looking for
+ * @return The associated value, which can be null
+ * @throws KeyNotFoundException If no entry with the given key can be found
+ * @throws IOException If we have an error while trying to access the page
+ * @throws IllegalArgumentException If duplicates are not enabled
+ */
+ BTree<V,V> getValues( K key ) throws KeyNotFoundException, IOException,
IllegalArgumentException;
+
/**
* Checks if the page contains the given key with the given value.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]