You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2008/03/26 17:34:42 UTC

svn commit: r641385 - in /directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm: JdbmTable.java KeyTupleAvlCursor.java

Author: kayyagari
Date: Wed Mar 26 09:34:36 2008
New Revision: 641385

URL: http://svn.apache.org/viewvc?rev=641385&view=rev
Log:
KeyTupleAvlCursor
 removed comparator parameter from the constructor and from file
 fixed the first() and last() methods
 removed redundant code from after() method 
 
updated JdbmTable to use the new KeyTupleAvlCursor constructor

Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java?rev=641385&r1=641384&r2=641385&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java Wed Mar 26 09:34:36 2008
@@ -794,7 +794,7 @@
         }
 
         AvlTree<V> set = marshaller.deserialize( serialized );
-        return new KeyTupleAvlCursor<K,V>( set, key, valueComparator );
+        return new KeyTupleAvlCursor<K,V>( set, key );
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java?rev=641385&r1=641384&r2=641385&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java Wed Mar 26 09:34:36 2008
@@ -25,8 +25,6 @@
 import org.apache.directory.server.core.avltree.AvlTree;
 import org.apache.directory.server.core.avltree.AvlTreeCursor;
 
-import java.util.Comparator;
-
 
 /**
  * Cursor over a set of values for the same key which are store in an in
@@ -38,7 +36,6 @@
  */
 public class KeyTupleAvlCursor<K,V> extends AbstractCursor<Tuple<K,V>>
 {
-    private final Comparator<V> comparator;
     private final AvlTreeCursor<V> wrapped;
     private final K key;
 
@@ -51,12 +48,10 @@
      *
      * @param avlTree the AvlTree to build a Tuple returning Cursor over
      * @param key the constant key for which values are returned
-     * @param comparator the Comparator used to determine <b>key</b> ordering
      */
-    public KeyTupleAvlCursor( AvlTree<V> avlTree, K key, Comparator<V> comparator )
+    public KeyTupleAvlCursor( AvlTree<V> avlTree, K key )
     {
         this.key = key;
-        this.comparator = comparator;
         this.wrapped = new AvlTreeCursor<V>( avlTree );
     }
 
@@ -93,45 +88,6 @@
     public void after( Tuple<K,V> element ) throws Exception
     {
         wrapped.after( element.getValue() );
-
-        /*
-         * While the next value is less than or equal to the element keep
-         * advancing forward to the next item.  If we cannot advance any
-         * further then stop and return.  If we find a value greater than
-         * the element then we stop, backup, and return so subsequent calls
-         * to getNext() will return a value greater than the element.
-         */
-        while ( wrapped.next() )
-        {
-            V next = wrapped.get();
-
-            int nextCompared = comparator.compare( next, element.getValue() );
-
-            if ( nextCompared <= 0 )
-            {
-                // just continue
-            }
-            else if ( nextCompared > 0 )
-            {
-                /*
-                 * If we just have values greater than the element argument
-                 * then we are before the first element and cannot backup, and
-                 * the call below to previous() will fail.  In this special
-                 * case we just reset the Cursor's position and return.
-                 */
-                if ( wrapped.previous() )
-                {
-                }
-                else
-                {
-                    wrapped.before( element.getValue() );
-                }
-
-                clearValue();
-                return;
-            }
-        }
-
         clearValue();
     }
 
@@ -151,13 +107,15 @@
 
     public boolean first() throws Exception
     {
-        return wrapped.first();
+        beforeFirst();
+        return next();
     }
 
 
     public boolean last() throws Exception
     {
-        return wrapped.last();
+        afterLast();
+        return previous();
     }