You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/06/21 15:02:38 UTC
svn commit: r1137989 -
/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java
Author: elecharny
Date: Tue Jun 21 13:02:37 2011
New Revision: 1137989
URL: http://svn.apache.org/viewvc?rev=1137989&view=rev
Log:
o Some more Javadoc addition
o Some more minor code refactoring
Modified:
directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java
Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java?rev=1137989&r1=1137988&r2=1137989&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java Tue Jun 21 13:02:37 2011
@@ -77,6 +77,9 @@ public class DupsContainerCursor<K,V> ex
}
+ /**
+ * Clean the tuples we use to store the returned resut.
+ */
private void clearValue()
{
returnedTuple.setKey( null );
@@ -103,6 +106,7 @@ public class DupsContainerCursor<K,V> ex
public void beforeKey( K key ) throws Exception
{
checkNotClosed( "beforeKey()" );
+
browser = ((BTree<K,V>)table.getBTree()).browse( key );
forwardDirection = null;
clearValue();
@@ -115,6 +119,8 @@ public class DupsContainerCursor<K,V> ex
@SuppressWarnings("unchecked")
public void afterKey( K key ) throws Exception
{
+ checkNotClosed( "afterKey()" );
+
browser = ((BTree<K,V>)table.getBTree()).browse( key );
forwardDirection = null;
@@ -256,30 +262,38 @@ public class DupsContainerCursor<K,V> ex
// only want to set this if the advance is a success which means we
// are not at front
- if ( ( forwardDirection == null ) && advanceSuccess )
+ if ( forwardDirection == null )
{
- forwardDirection = false;
+ if ( advanceSuccess)
+ {
+ forwardDirection = false;
+ }
+ else
+ {
+ clearValue();
+
+ return false;
+ }
}
-
- if ( ( forwardDirection != null ) && forwardDirection )
+ else if ( forwardDirection )
{
advanceSuccess = browser.getPrevious( jdbmTuple );
forwardDirection = false;
}
- if ( advanceSuccess )
+ valueAvailable = advanceSuccess;
+
+ if ( valueAvailable )
{
returnedTuple.setKey( ( K ) jdbmTuple.getKey() );
returnedTuple.setValue( table.getDupsContainer( ( byte[] ) jdbmTuple.getValue() ) );
-
- return valueAvailable = true;
}
else
{
clearValue();
-
- return false;
}
+
+ return valueAvailable;
}
@@ -324,12 +338,16 @@ public class DupsContainerCursor<K,V> ex
valueAvailable = advanceSuccess;
- if ( advanceSuccess )
+ if ( valueAvailable )
{
// create the fetched tuple containing the key and the deserialized value
returnedTuple.setKey( jdbmTuple.getKey() );
returnedTuple.setValue( table.getDupsContainer( ( byte[] ) jdbmTuple.getValue() ) );
}
+ else
+ {
+ clearValue();
+ }
return valueAvailable;
}