directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r606795 - in /directory/sandbox/akarasulu/bigbang/apacheds: btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ core-cursor/src/main/java/org/apache/directory/server/core/cursor/ core-cursor/src/test/java/org/apa...
Date Tue, 25 Dec 2007 15:49:27 GMT
Author: akarasulu
Date: Tue Dec 25 07:49:25 2007
New Revision: 606795

URL: http://svn.apache.org/viewvc?rev=606795&view=rev
Log:
removed relative() and isXxxx methods and cleaned up things a tiny bit

Removed:
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/test/java/org/apache/directory/server/core/cursor/CursorBehaviorTests.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/test/java/org/apache/directory/server/core/cursor/SingletonCursorTest.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/AfterInnerState.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/AfterLastState.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/BeforeFirstState.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/BeforeInnerState.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/ClosedState.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/EmptyCursorState.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/OnFirstState.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/OnInnerState.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/OnLastState.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/OpenedState.java
Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoDupsCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/ListCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/test/java/org/apache/directory/server/core/cursor/ListCursorTest.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursorTest.java
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeCursor.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoDupsCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoDupsCursor.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoDupsCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoDupsCursor.java Tue Dec 25 07:49:25 2007
@@ -38,7 +38,6 @@
     private final Tuple tuple = new Tuple();
     private final TupleBrowserFactory factory;
 
-    private long pos = BEFORE_FIRST;
     private long size;  // cache the size to prevent needless lookups
     private boolean afterLast;
     private boolean beforeFirst;
@@ -70,7 +69,6 @@
     public NoDupsCursor( TupleBrowserFactory factory, int absolute ) throws IOException
     {
         this.factory = factory;
-        absolute( absolute );
     }
 
 
@@ -96,7 +94,6 @@
         beforeFirst = false;
         afterLast = false;
         size = factory.size();
-        pos = BEFORE_FIRST;
         success = true;
 
         throw new NotImplementedException( "Need to fix the todo on this before going further" );
@@ -109,7 +106,7 @@
     }
 
 
-    public boolean after( Tuple element ) throws IOException
+    public void after( Tuple element ) throws IOException
     {
         throw new NotImplementedException();
     }
@@ -123,7 +120,6 @@
             afterLast = false;
             success = false;
             size = factory.size();
-            pos = BEFORE_FIRST;
             browser = factory.beforeFirst();
         }
     }
@@ -137,128 +133,11 @@
             afterLast = true;
             success = false;
             size = factory.size();
-            pos = size;
             browser = factory.afterLast();
         }
     }
 
 
-    public boolean absolute( int absolutePosition ) throws IOException
-    {
-        // -------------------------------------------------------------------
-        // Special cases under or above the valid range puts the cursor
-        // respectively before the first or after the last position
-        // -------------------------------------------------------------------
-
-        if ( absolutePosition >= size )
-        {
-            afterLast();
-            return false;
-        }
-
-        if ( absolutePosition < 0 )
-        {
-            beforeFirst();
-            return false;
-        }
-
-        // -------------------------------------------------------------------
-        // Special case where position is valid and that's the new position
-        // -------------------------------------------------------------------
-
-        if ( absolutePosition == pos )
-        {
-            return success;
-        }
-
-        // -------------------------------------------------------------------
-        // Special easy to get to cases where we don't have to walk the tree
-        // -------------------------------------------------------------------
-
-        if ( absolutePosition == 0 && beforeFirst )
-        {
-            return next();
-        }
-
-        if ( ( absolutePosition == size - 1  ) && afterLast )
-        {
-            return previous();
-        }
-
-        // -------------------------------------------------------------------
-        // Cases we have to walk the tree forward or backwards to get to target
-        // -------------------------------------------------------------------
-
-        if ( absolutePosition > pos )
-        {
-            while ( success && pos < absolutePosition )
-            {
-                next();
-            }
-        }
-        else
-        {
-            while ( success && pos > absolutePosition )
-            {
-                previous();
-            }
-        }
-
-        return success;
-    }
-
-
-    public boolean relative( int relativePosition ) throws IOException
-    {
-        // -------------------------------------------------------------------
-        // Special cases under or above the valid range puts the cursor
-        // respectively before the first or after the last position
-        // -------------------------------------------------------------------
-
-        if ( ( relativePosition + pos ) >= size )
-        {
-            afterLast();
-            return false;
-        }
-
-        if ( ( relativePosition + pos ) < 0 )
-        {
-            beforeFirst();
-            return false;
-        }
-
-        // -------------------------------------------------------------------
-        // Special case where position is valid and that's the new position
-        // -------------------------------------------------------------------
-
-        if ( relativePosition == 0 )
-        {
-            return success;
-        }
-
-        // -------------------------------------------------------------------
-        // Cases we have to walk the tree forward or backwards
-        // -------------------------------------------------------------------
-
-        if ( relativePosition > 0 )
-        {
-            for ( ; success && relativePosition > 0; relativePosition-- )
-            {
-                next();
-            }
-        }
-        else
-        {
-            for ( ; success && relativePosition < 0; relativePosition++ )
-            {
-                previous();
-            }
-        }
-
-        return success;
-    }
-
-
     public boolean first() throws IOException
     {
         if ( beforeFirst )
@@ -266,11 +145,6 @@
             return next();
         }
 
-        if ( pos == 0 )
-        {
-            return success;
-        }
-
         beforeFirst();
         return next();
     }
@@ -283,40 +157,11 @@
             return previous();
         }
 
-        if ( pos == ( size - 1 ) )
-        {
-            return success;
-        }
-
         afterLast();
         return previous();
     }
 
 
-    public boolean isFirst() throws IOException
-    {
-        return pos == 0;
-    }
-
-
-    public boolean isLast() throws IOException
-    {
-        return pos == ( size - 1 );
-    }
-
-
-    public boolean isAfterLast() throws IOException
-    {
-        return afterLast;
-    }
-
-
-    public boolean isBeforeFirst() throws IOException
-    {
-        return beforeFirst;
-    }
-
-
     public boolean previous() throws IOException
     {
         if ( beforeFirst )
@@ -331,25 +176,11 @@
             {
                 afterLast = false;
                 beforeFirst = false;
-                pos = size - 1;
             }
             return success;
         }
 
-        if ( pos == 0 )
-        {
-            success = false;
-            afterLast = false;
-            beforeFirst = true;
-            pos = BEFORE_FIRST;
-            return false;
-        }
-
         success = browser.getPrevious( tuple );
-        if ( success )
-        {
-            pos--;
-        }
         return success;
     }
 
@@ -360,20 +191,8 @@
     }
 
 
-    private boolean inRangeOnValue()
-    {
-        return pos > BEFORE_FIRST && pos < size;
-    }
-
-
-
     public Tuple get() throws IOException
     {
-        if ( ! inRangeOnValue() )
-        {
-            throw new InvalidCursorPositionException();
-        }
-
         if ( success )
         {
             return tuple;

Modified: directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ValueArrayCursor.java Tue Dec 25 07:49:25 2007
@@ -79,7 +79,7 @@
     }
 
 
-    public boolean after( Tuple element ) throws IOException
+    public void after( Tuple element ) throws IOException
     {
         throw new NotImplementedException();
     }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/Cursor.java Tue Dec 25 07:49:25 2007
@@ -100,31 +100,6 @@
 
 
     /**
-     * Positions this Curser an offset number of elements before or after the
-     * current position.  Negative offsets are used to move the Cursor's
-     * position back, while positive offsets are used to advance the Cursor's
-     * position forward.
-     *
-     * If the specified position is past the first or last element, the Cursor
-     * is positioned before the first or after the last element respectively.
-     *
-     * Note that this is not the most efficient means to advance a Cursor over
-     * a BTree.  The best mechanism is to advance by using a specific key via
-     * the Cursor#before() and Cursor#after() methods.  Most implementations
-     * of this method will have to walk through BTree records.
-     *
-     * @param offset the relative offset to move this Cursor to
-     * @return true if the position has been successfully changed to an
-     * existing element retreivable by Cursor#get() at the new relative
-     * position, of this Cursor, otherwise false
-     * @throws IOException if there are problems positioning this Cursor or if
-     * this Cursor is closed
-     * @throws UnsupportedOperationException if this method is not supported
-     */
-    boolean relative( int offset ) throws IOException;
-
-
-    /**
      * Positions this Curser at the first element.
      *
      * @return true if the position has been successfully changed to the first
@@ -146,54 +121,6 @@
      * @throws UnsupportedOperationException if this method is not supported
      */
     boolean last() throws IOException;
-
-
-    /**
-     * Checks if this Curser is positioned at the first element.
-     *
-     * @return true if the current position is at the first element, false
-     * otherwise
-     * @throws IOException if there are problems determining this Cursor's
-     * position, or if this Cursor is closed
-     * @throws UnsupportedOperationException if this method is not supported
-     */
-    boolean isFirst() throws IOException;
-
-
-    /**
-     * Checks if this Curser is positioned at the last element.
-     *
-     * @return true if the current position is at the last element, false
-     * otherwise
-     * @throws IOException if there are problems determining this Cursor's
-     * position, or if this Cursor is closed
-     * @throws UnsupportedOperationException if this method is not supported
-     */
-    boolean isLast() throws IOException;
-
-
-    /**
-     * Checks if this Curser is positioned after the last element.
-     *
-     * @return true if the current position is after the last element, false
-     * otherwise
-     * @throws IOException if there are problems determining this Cursor's
-     * position, or if this Cursor is closed
-     * @throws UnsupportedOperationException if this method is not supported
-     */
-    boolean isAfterLast() throws IOException;
-
-
-    /**
-     * Checks if this Curser is positioned before the first element.
-     *
-     * @return true if the current position is before the first element, false
-     * otherwise
-     * @throws IOException if there are problems determining this Cursor's
-     * position, or if this Cursor is closed
-     * @throws UnsupportedOperationException if this method is not supported
-     */
-    boolean isBeforeFirst() throws IOException;
 
 
     /**

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/CursorState.java Tue Dec 25 07:49:25 2007
@@ -41,8 +41,6 @@
 
     void afterLast() throws IOException;
 
-    boolean relative( int offset ) throws IOException;
-
     boolean first() throws IOException;
 
     boolean last() throws IOException;

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java Tue Dec 25 07:49:25 2007
@@ -54,14 +54,6 @@
     }
 
 
-    @SuppressWarnings ( { "UnusedDeclaration" } )
-    public boolean relative( int relativePosition ) throws CursorClosedException
-    {
-        checkClosed( "relative()" );
-        return false;
-    }
-
-
     public boolean first() throws CursorClosedException
     {
         checkClosed( "first()" );
@@ -72,34 +64,6 @@
     public boolean last() throws CursorClosedException
     {
         checkClosed( "last()" );
-        return false;
-    }
-
-
-    public boolean isFirst() throws CursorClosedException
-    {
-        checkClosed( "isFirst()" );
-        return false;
-    }
-
-
-    public boolean isLast() throws CursorClosedException
-    {
-        checkClosed( "isLast()" );
-        return false;
-    }
-
-
-    public boolean isAfterLast() throws CursorClosedException
-    {
-        checkClosed( "isAfterLast()" );
-        return false;
-    }
-
-
-    public boolean isBeforeFirst() throws CursorClosedException
-    {
-        checkClosed( "isBeforeFirst()" );
         return false;
     }
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java Tue Dec 25 07:49:25 2007
@@ -64,12 +64,6 @@
     }
 
 
-    public boolean relative( int relativePosition ) throws IOException
-    {
-        throw new UnsupportedOperationException( "Cannot advance to a relative position on the underlying Iterator." );
-    }
-
-
     public boolean first() throws IOException
     {
         throw new UnsupportedOperationException( "Cannot advance to first position on the underlying Iterator." );
@@ -79,30 +73,6 @@
     public boolean last() throws IOException
     {
         throw new UnsupportedOperationException( "Cannot advance to last position on the underlying Iterator." );
-    }
-
-
-    public boolean isFirst() throws IOException
-    {
-        throw new UnsupportedOperationException( "Cannot determine position on the underlying Iterator." );
-    }
-
-
-    public boolean isLast() throws IOException
-    {
-        throw new UnsupportedOperationException( "Cannot determine position on the underlying Iterator." );
-    }
-
-
-    public boolean isAfterLast() throws IOException
-    {
-        throw new UnsupportedOperationException( "Cannot determine position on the underlying Iterator." );
-    }
-
-
-    public boolean isBeforeFirst() throws IOException
-    {
-        throw new UnsupportedOperationException( "Cannot determine position on the underlying Iterator." );
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/ListCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/ListCursor.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/ListCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/ListCursor.java Tue Dec 25 07:49:25 2007
@@ -273,27 +273,6 @@
     }
 
 
-    public boolean relative( int index ) throws IOException
-    {
-        checkClosed( "relative()" );
-
-        if ( this.index + index < start )
-        {
-            this.index = -1;
-            return false;
-        }
-
-        if ( this.index + index >= end )
-        {
-            this.index = end;
-            return false;
-        }
-
-        this.index += index;
-        return true;
-    }
-
-
     public boolean first() throws IOException
     {
         checkClosed( "first()" );

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java Tue Dec 25 07:49:25 2007
@@ -115,40 +115,6 @@
     }
 
 
-    public boolean relative( int relativePosition ) throws IOException
-    {
-        checkClosed( "()" );
-
-        if ( relativePosition == 0 )
-        {
-            return true;
-        }
-
-        if ( ( relativePosition == -1 && afterLast ) ||
-             ( relativePosition == 1 && beforeFirst ) )
-        {
-            beforeFirst = false;
-            onSingleton = true;
-            afterLast = false;
-            return true;
-        }
-
-        if ( relativePosition > 1 )
-        {
-            beforeFirst = false;
-            onSingleton = false;
-            afterLast = true;
-            return false;
-        }
-
-        // below this then relativePosition < 1
-        beforeFirst = true;
-        onSingleton = false;
-        afterLast = false;
-        return false;
-    }
-
-
     public boolean first() throws IOException
     {
         checkClosed( "()" );

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/test/java/org/apache/directory/server/core/cursor/ListCursorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/test/java/org/apache/directory/server/core/cursor/ListCursorTest.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/test/java/org/apache/directory/server/core/cursor/ListCursorTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-cursor/src/test/java/org/apache/directory/server/core/cursor/ListCursorTest.java Tue Dec 25 07:49:25 2007
@@ -41,9 +41,6 @@
     {
         ListCursor<String> cursor = new ListCursor<String>();
 
-        assertFirstLastOnNewCursor( cursor, 0, 0, 0 );
-        assertRelative( cursor, 0, 0, 0 );
-
         // close test
         cursor.close();
         assertClosed( cursor, "cursor.isCloased() should return true after closing the cursor", true );
@@ -53,8 +50,6 @@
     public void testSingleElementList() throws IOException
     {
         ListCursor<String> cursor = new ListCursor<String>( Collections.singletonList( "singleton" ) );
-        assertFirstLastOnNewCursor( cursor, 1, 0, 1 );
-        assertRelative( cursor, 1, 0, 1 );
         cursor.close();
 
         // close test
@@ -146,20 +141,14 @@
 
         // test with bounds of the list itself
         ListCursor<String> cursor = new ListCursor<String>( list );
-        assertFirstLastOnNewCursor( cursor, 5, 0, 5 );
-        assertRelative( cursor, 5, 0, 5 );
         cursor.close();
 
         // test with nonzero lower bound
         cursor = new ListCursor<String>( 1, list );
-        assertFirstLastOnNewCursor( cursor, 5, 1, 5 );
-        assertRelative( cursor, 5, 1, 5 );
         cursor.close();
 
         // test with nonzero lower bound and upper bound
         cursor = new ListCursor<String>( 1, list, 4 );
-        assertFirstLastOnNewCursor( cursor, 5, 1, 4 );
-        assertRelative( cursor, 5, 1, 4 );
 
         // close test
         cursor.close();
@@ -239,158 +228,6 @@
     }
 
 
-    @SuppressWarnings ( { "ConstantConditions" } )
-    protected void assertFirstLastOnNewCursor( Cursor cursor, int listSize, int lowerBound, int upperBound )
-            throws IOException
-    {
-        assertNotNull( cursor );
-
-        String prefix = "[size, " + listSize + "] [lower, " + lowerBound + "] [upper, " + upperBound + "]: ";
-
-        assertFalse( prefix + "new cursor should not be positioned after last", cursor.isAfterLast() );
-        assertTrue( prefix + "new cursor should be positioned before first", cursor.isBeforeFirst() );
-        assertFalse( prefix + "new cursor should not be closed", cursor.isClosed() );
-        assertFalse( prefix + "new cursor should not be positioned at first", cursor.isFirst() );
-        assertFalse( prefix + "new cursor should not be positioned at last", cursor.isLast() );
-
-        // beforeFirst and afterLast tests
-        cursor.afterLast();
-        assertTrue( prefix + "cursor.afterLast() should return true on isAfterLast()", cursor.isAfterLast() );
-        assertFalse( prefix + "cursor.afterLast() should return false on isBeforeFirst()", cursor.isBeforeFirst() );
-        assertFalse( prefix + "cursor.afterLast() should return false on isFirst()", cursor.isFirst() );
-        assertFalse( prefix + "cursor.afterLast() should return false on isLast()", cursor.isLast() );
-
-        cursor.beforeFirst();
-        assertTrue( prefix + "cursor.beforeFirst() should return true on isBeforeFirst()", cursor.isBeforeFirst() );
-        assertFalse( prefix + "cursor.beforeFirst() should return false on isAfterLast()", cursor.isAfterLast() );
-        assertFalse( prefix + "cursor.beforeFirst() should return false on isFirst()", cursor.isFirst() );
-        assertFalse( prefix + "cursor.beforeFirst() should return false on isLast()", cursor.isLast() );
-
-        // first() tests
-        cursor.afterLast();
-        if ( listSize <= 0 )
-        {
-            assertFalse( "cursor.first() on empty cursor should return false", cursor.first() );
-            assertFalse( "cursor.first() on empty cursor should return false on isFirst()", cursor.isFirst() );
-            assertFalse( "cursor.first() on empty cursor should should change position state", cursor.isBeforeFirst() );
-            assertTrue( "cursor.first() on empty cursor should should change position state", cursor.isAfterLast() );
-        }
-        else
-        {
-            assertTrue( prefix + "cursor.first() should return true", cursor.first() );
-            assertTrue( prefix + "cursor.first() should return true on isFirst()", cursor.isFirst() );
-            assertFalse( prefix + "cursor.first() should change position", cursor.isBeforeFirst() );
-            assertFalse( prefix + "cursor.first() should change position", cursor.isAfterLast() );
-        }
-
-        // last() tests
-        cursor.beforeFirst();
-        if ( listSize <= 0 )
-        {
-            assertFalse( "cursor.last() on empty cursor should return false", cursor.last() );
-            assertFalse( "cursor.last() on empty cursor should return false on isLast()", cursor.isLast() );
-            assertFalse( "cursor.last() on empty cursor should should change position state", cursor.isAfterLast() );
-            assertTrue( "cursor.last() on empty cursor should should change position state", cursor.isBeforeFirst() );
-        }
-        else
-        {
-            assertTrue( prefix + "cursor.last() should return true", cursor.last() );
-            assertTrue( prefix + "cursor.last() should return true on isLast()", cursor.isLast() );
-            assertFalse( prefix + "cursor.last() should not park position after last", cursor.isAfterLast() );
-            assertFalse( prefix + "cursor.last() should not park position before first", cursor.isBeforeFirst() );
-        }
-
-        // next() tests
-        cursor.beforeFirst();
-        if ( listSize <= 0 )
-        {
-            assertFalse( "empty cursor.next() should return false", cursor.next() );
-            assertTrue( "empty cursor.next() should change pos to after last", cursor.isAfterLast() );
-            assertFalse( "empty cursor.next() should change pos to after last", cursor.isBeforeFirst() );
-        }
-        else
-        {
-            assertTrue( prefix + "cursor.next() should return true", cursor.next() );
-            assertTrue( prefix + "cursor.next() should change pos to first element", cursor.isFirst() );
-            assertFalse( prefix + "cursor.next() should not change pos to after last", cursor.isAfterLast() );
-            assertFalse( prefix + "cursor.next() should not change pos to before first", cursor.isBeforeFirst() );
-
-            while( cursor.next() )
-            {
-                assertFalse( prefix + "cursor.next() should not change pos to before first", cursor.isBeforeFirst() );
-                assertFalse( prefix + "cursor.next() should not change pos to first after first advance forward",
-                        cursor.isFirst() );
-            }
-
-            assertTrue( prefix + "cursor.next() failure should put pos to after last", cursor.isAfterLast() );
-        }
-
-        // previous() tests
-        cursor.afterLast();
-        if ( listSize <= 0 )
-        {
-            assertFalse( "empty cursor.previous() should return false", cursor.previous() );
-            assertTrue( "empty cursor.previous() should change pos to before first", cursor.isBeforeFirst() );
-            assertFalse( "empty cursor.previous() should change pos to before first", cursor.isAfterLast() );
-        }
-        else
-        {
-            assertTrue( prefix + "cursor.previous() should return true", cursor.previous() );
-            assertTrue( prefix + "cursor.previous() should change pos to last element", cursor.isLast() );
-            assertFalse( prefix + "cursor.previous() should not change pos to before first", cursor.isBeforeFirst() );
-            assertFalse( prefix + "cursor.previous() should not change pos to after last", cursor.isAfterLast() );
-
-            while( cursor.previous() )
-            {
-                assertFalse( prefix + "cursor.previous() should not change pos to after last", cursor.isAfterLast() );
-                assertFalse( prefix + "cursor.previous() should not change pos to last after first advance backward",
-                        cursor.isLast() );
-            }
-
-            assertTrue( prefix + "cursor.previous() failure should put pos to before first", cursor.isBeforeFirst() );
-        }
-    }
-
-
-    protected void assertRelative( Cursor cursor, int listSize, int lowerBound, int upperBound )
-            throws IOException
-    {
-        String prefix = "[size, " + listSize + "] [lower, " + lowerBound + "] [upper, " + upperBound + "]: ";
-
-        // test relative() advance which changes position below lower bound
-        cursor.afterLast();
-        int relativePos = - ( upperBound - lowerBound + 1 );
-
-        assertFalse( prefix + "cursor.relative(" + relativePos +
-                ") should return false and change state to before first", cursor.relative( - ( upperBound + 1 ) ) );
-        assertTrue( prefix + "cursor.relative(" + relativePos +
-                ") should change pos to before first", cursor.isBeforeFirst() );
-        assertFalse( prefix + "cursor.relative(" + relativePos +
-                ") should --NOT-- change pos to after last", cursor.isAfterLast() );
-
-        // make sure relative(0) does not change pos if begin state is after last
-        cursor.afterLast();
-        assertFalse( prefix + "cursor.relative(0) should return false and have no effect on pos",
-                cursor.relative( 0 ) );
-        assertFalse( prefix + "cursor.relative(0) should have no effect on changing state", cursor.isBeforeFirst() );
-        assertTrue( prefix + "cursor.relative(0) should have no effect on changing state", cursor.isAfterLast() );
-
-        // make sure relative(0) does not change pos if begin state is before first
-        cursor.beforeFirst();
-        assertFalse( prefix + "cursor.relative(0) should return false and have no effect on pos",
-                cursor.relative( 0 ) );
-        assertTrue( prefix + "cursor.relative(0) should have no effect on changing state", cursor.isBeforeFirst() );
-        assertFalse( prefix + "cursor.relative(0) should have no effect on changing state", cursor.isAfterLast() );
-
-        // make relative() advance which changes position above upper bound
-        cursor.beforeFirst();
-        assertFalse( prefix + "cursor.relative(" + ( upperBound + 1 )
-                + ") should return false but change state to after last", cursor.relative( upperBound + 1 ) );
-        assertFalse( prefix + "cursor.relative(" + ( upperBound + 1 ) + ") should change pos to after last",
-                cursor.isBeforeFirst() );
-        assertTrue( prefix + "cursor.relative(" + ( upperBound + 1 ) + ") should change pos to after last",
-                cursor.isAfterLast() );
-    }
 
 
     protected void assertClosed( Cursor cursor, String msg, boolean expected )
@@ -456,46 +293,6 @@
 
         try
         {
-            cursor.isAfterLast();
-            fail( "cursor.isAfterLast() after closing the cursor should fail with an IOException" );
-        }
-        catch ( IOException e )
-        {
-            assertNotNull( e );
-        }
-
-        try
-        {
-            cursor.isBeforeFirst();
-            fail( "cursor.isBeforeFirst() after closing the cursor should fail with an IOException" );
-        }
-        catch ( IOException e )
-        {
-            assertNotNull( e );
-        }
-
-        try
-        {
-            cursor.isFirst();
-            fail( "cursor.isFirst() after closing the cursor should fail with an IOException" );
-        }
-        catch ( IOException e )
-        {
-            assertNotNull( e );
-        }
-
-        try
-        {
-            cursor.isLast();
-            fail( "cursor.isLast() after closing the cursor should fail with an IOException" );
-        }
-        catch ( IOException e )
-        {
-            assertNotNull( e );
-        }
-
-        try
-        {
             cursor.last();
             fail( "cursor.last() after closing the cursor should fail with an IOException" );
         }
@@ -518,16 +315,6 @@
         {
             cursor.previous();
             fail( "cursor.previous() after closing the cursor should fail with an IOException" );
-        }
-        catch ( IOException e )
-        {
-            assertNotNull( e );
-        }
-
-        try
-        {
-            cursor.relative( 1 );
-            fail( "cursor.relative() after closing the cursor should fail with an IOException" );
         }
         catch ( IOException e )
         {

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursor.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursor.java Tue Dec 25 07:49:25 2007
@@ -24,9 +24,6 @@
 import jdbm.helper.TupleBrowser;
 
 import org.apache.directory.server.core.cursor.AbstractCursor;
-import org.apache.directory.server.core.cursor.InconsistentCursorStateException;
-import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
-import org.apache.directory.server.core.cursor.CursorState;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,24 +43,8 @@
     private static final Logger LOG = LoggerFactory.getLogger( KeyCursor.class );
     private final Tuple tuple = new Tuple();
 
-    private final CursorState afterInner = new AfterInnerState( this );
-    private final CursorState afterLast = new AfterLastState( this );
-    private final CursorState beforeFirst = new BeforeFirstState( this );
-    private final CursorState beforeInner = new BeforeInnerState( this );
-    private final CursorState closed = new ClosedState();
-    private final CursorState opened = new OpenedState( this );
-    private final CursorState onFirst = new OnFirstState( this );
-    private final CursorState onInner = new OnInnerState( this );
-    private final CursorState onLast = new OnLastState( this );
-    private final CursorState empty = new EmptyCursorState( this );
-
-    private CursorState state = opened;
     private BTree btree;
     private TupleBrowser browser;
-    private int size;  // cache the size to prevent needless lookups
-
-    private E first;
-    private E last;
 
 
     /**
@@ -75,16 +56,12 @@
     KeyCursor( BTree btree ) throws IOException
     {
         this.btree = btree;
-        this.size = btree.size();
     }
 
 
     public void before( E element ) throws IOException
     {
         browser = btree.browse( element );
-        success = false;
-        afterLast = false;
-        beforeFirst = false;
         tuple.setKey( null );
         tuple.setValue( null );
     }
@@ -98,386 +75,48 @@
 
     public void beforeFirst() throws IOException
     {
-        if ( ! beforeFirst )
-        {
-            beforeFirst = true;
-            afterLast = false;
-            success = false;
-            size = btree.size();
-            browser = btree.browse();
-        }
+        throw new NotImplementedException();
     }
 
 
     public void afterLast() throws IOException
     {
-        if ( ! afterLast )
-        {
-            beforeFirst = false;
-            afterLast = true;
-            success = false;
-            size = btree.size();
-            browser = btree.browse( null );
-        }
-    }
-
-
-    public boolean relative( int relativePosition ) throws IOException
-    {
-        // -------------------------------------------------------------------
-        // Special cases under or above the valid range puts the cursor
-        // respectively before the first or after the last position
-        // -------------------------------------------------------------------
-
-//        if ( ( relativePosition + pos ) >= size )
-//        {
-//            afterLast();
-//            return false;
-//        }
-//
-//        if ( ( relativePosition + pos ) < 0 )
-//        {
-//            beforeFirst();
-//            return false;
-//        }
-
-        // -------------------------------------------------------------------
-        // Special case where position is valid and that's the new position
-        // -------------------------------------------------------------------
-
-        if ( relativePosition == 0 )
-        {
-            return success;
-        }
-
-        // -------------------------------------------------------------------
-        // Cases we have to walk the tree forward or backwards
-        // -------------------------------------------------------------------
-
-        if ( relativePosition > 0 )
-        {
-            for ( ; success && relativePosition > 0; relativePosition-- )
-            {
-                next();
-            }
-        }
-        else
-        {
-            for ( ; success && relativePosition < 0; relativePosition++ )
-            {
-                previous();
-            }
-        }
-
-        return success;
+        throw new NotImplementedException();
     }
 
 
     public boolean first() throws IOException
     {
-        if ( beforeFirst )
-        {
-            return next();
-        }
-
-//        if ( pos == 0 )
-//        {
-//            return success;
-//        }
-
-        beforeFirst();
-        return next();
-    }
-
-
-    public boolean last() throws IOException
-    {
-        if ( afterLast )
-        {
-            return previous();
-        }
-
-//        if ( pos == ( size - 1 ) )
-//        {
-//            return success;
-//        }
-
-        afterLast();
-        return previous();
-    }
-
-
-    public boolean isFirst() throws IOException
-    {
-//        return pos == 0;
         throw new NotImplementedException();
     }
 
 
-    public boolean isLast() throws IOException
+    public boolean last() throws IOException
     {
-//        return pos == ( size - 1 );
         throw new NotImplementedException();
     }
 
 
-    public boolean isAfterLast() throws IOException
-    {
-        return afterLast;
-    }
-
-
-    public boolean isBeforeFirst() throws IOException
-    {
-        return beforeFirst;
-    }
-
-
     public boolean previous() throws IOException
     {
-        if ( beforeFirst )
-        {
-            return false;
-        }
-
-        if ( afterLast )
-        {
-            success = browser.getPrevious( tuple );
-            if ( success )
-            {
-                afterLast = false;
-                beforeFirst = false;
-//                pos = size - 1;
-            }
-            return success;
-        }
-
-//        if ( pos == 0 )
-//        {
-//            success = false;
-//            afterLast = false;
-//            beforeFirst = true;
-//            pos = BEFORE_FIRST;
-//            return false;
-//        }
-
-        success = browser.getPrevious( tuple );
-        if ( success )
-        {
-//            pos--;
-        }
-        return success;
+        throw new NotImplementedException();
     }
 
 
     public boolean next() throws IOException
     {
-        if ( afterLast )
-        {
-            return false;
-        }
-
-        if ( beforeFirst )
-        {
-            success = browser.getNext( tuple );
-            if ( success )
-            {
-                afterLast = false;
-                beforeFirst = false;
-//                pos = 0;
-            }
-            return success;
-        }
-
-//        if ( pos == size - 1 )
-//        {
-//            success = false;
-//            afterLast = true;
-//            beforeFirst = false;
-//            pos = size;
-//            return false;
-//        }
-
-        success = browser.getNext( tuple );
-        if ( success )
-        {
-//            pos++;
-        }
-        return success;
-    }
-
-
-    private boolean inRangeOnValue()
-    {
-//        return pos > BEFORE_FIRST && pos < size;
         throw new NotImplementedException();
     }
 
 
-
     public E get() throws IOException
     {
-        if ( ! inRangeOnValue() )
-        {
-            throw new InvalidCursorPositionException();
-        }
-
-        if ( success )
-        {
-            //noinspection unchecked
-            return ( E ) tuple.getKey();
-        }
-        else
-        {
-            throw new InconsistentCursorStateException( "Seems like the position is in range however the " +
-                    "last operation failed to produce a successful result" );
-        }
+        throw new NotImplementedException();
     }
 
 
     public boolean isElementReused()
     {
         return false;
-    }
-
-
-    BTree getBtree()
-    {
-        return btree;
-    }
-
-
-    Tuple getTuple()
-    {
-        return tuple;
-    }
-
-
-    CursorState getState()
-    {
-        return state;
-    }
-
-
-    void setState( CursorState state )
-    {
-        this.state = state;
-    }
-
-
-    TupleBrowser getBrowser()
-    {
-        return browser;
-    }
-
-
-    void setBrowser( TupleBrowser browser )
-    {
-        this.browser = browser;
-    }
-
-
-    int size()
-    {
-        return size;
-    }
-
-
-    E getFirst() throws IOException
-    {
-        if ( size == 0 )
-        {
-            return null;
-        }
-
-        if ( first != null )
-        {
-            return first;
-        }
-
-        TupleBrowser browser = btree.browse();
-        Tuple tuple = new Tuple();
-        if ( browser.getNext( tuple ) )
-        {
-            return first = ( E ) tuple.getKey();
-        }
-
-        return first = null;
-    }
-
-
-    E getLast() throws IOException
-    {
-        if ( size == 0 )
-        {
-            return null;
-        }
-
-        if ( last != null )
-        {
-            return last;
-        }
-
-        TupleBrowser browser = btree.browse( null );
-        Tuple tuple = new Tuple();
-        if ( browser.getPrevious( tuple ) )
-        {
-            return last = ( E ) tuple.getKey();
-        }
-        return last = null;
-    }
-
-
-    public CursorState getAfterInner()
-    {
-        return afterInner;
-    }
-
-
-    public CursorState getAfterLast()
-    {
-        return afterLast;
-    }
-
-
-    public CursorState getBeforeFirst()
-    {
-        return beforeFirst;
-    }
-
-
-    public CursorState getBeforeInner()
-    {
-        return beforeInner;
-    }
-
-
-    public CursorState getClosed()
-    {
-        return closed;
-    }
-
-
-    public CursorState getOpened()
-    {
-        return opened;
-    }
-
-
-    public CursorState getOnFirst()
-    {
-        return onFirst;
-    }
-
-
-    public CursorState getOnInner()
-    {
-        return onInner;
-    }
-
-
-    public CursorState getOnLast()
-    {
-        return onLast;
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursorTest.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursorTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-cursor/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/cursor/keyonly/KeyCursorTest.java Tue Dec 25 07:49:25 2007
@@ -106,59 +106,6 @@
 
 
     @Test
-    @Ignore ( "Messed up now after removing absolute() method." )
-    public void testCursorAdvance() throws Exception
-    {
-        assertNotNull( cursor );
-
-        // test before changing newly created cursor
-        assertTrue( "New default Cursor should be before first element.", cursor.isBeforeFirst() );
-        assertFalse( "New default Cursor should NOT be at the first element", cursor.isFirst() );
-        assertFalse( "New default Cursor should NOT be after last element", cursor.isAfterLast() );
-        assertFalse( "New default Cursor should NOT be at the last element", cursor.isLast() );
-        assertInvalid( cursor );
-
-        // move to first position and test
-        assertTrue( "New default Cursor should be able to goto next position", cursor.next() );
-        assertEquals( "First value should be recovered", "0", cursor.get() );
-        assertTrue( "After cursor.next() we should be above the first element", cursor.isFirst() );
-        assertFalse( "After next() Cursor should be NOT before first element.", cursor.isBeforeFirst() );
-        assertTrue( "After first next() Cursor should be at the first element", cursor.isFirst() );
-        assertFalse( "After first next() Cursor should NOT be after last element", cursor.isAfterLast() );
-        assertFalse( "After first next() Cursor should NOT be at the last element", cursor.isLast() );
-
-        // move forward to 5th position over the "5"
-        assertTrue( "Cursor advance to index 5 should work.", cursor.relative( 4 ) );
-        assertEquals( "Cursor advance to index 5 should be \"5\"", "5", cursor.get() );
-        assertFalse( "Cursor @5th pos should NOT be before first element.", cursor.isBeforeFirst() );
-        assertFalse( "Cursor @5th pos should NOT be at the first element", cursor.isFirst() );
-        assertFalse( "Cursor @5th pos should NOT be after last element", cursor.isAfterLast() );
-        assertFalse( "Cursor @5th pos should NOT be at the last element", cursor.isLast() );
-
-        // move backwards to 2nd position over the "2"
-        assertTrue( "Cursor advance to index 2 should work.", cursor.relative( 2 ) );
-        assertEquals( "Element at index 2 value should be \"2\"", "2", cursor.get() );
-        assertFalse( "Cursor @2nd pos should NOT be before first element.", cursor.isBeforeFirst() );
-        assertFalse( "Cursor @2nd pos should NOT be at the first element", cursor.isFirst() );
-        assertFalse( "Cursor @2nd pos should NOT be after last element", cursor.isAfterLast() );
-        assertFalse( "Cursor @2nd pos should NOT be at the last element", cursor.isLast() );
-
-        // move backwards to 2nd position over the "9"
-        assertTrue( "Cursor advance to index 2 should work.", cursor.relative( 2 ) );
-        assertEquals( "Element at index 2 value should be \"2\"", "2", cursor.get() );
-        assertFalse( "Cursor @2nd pos should NOT be before first element.", cursor.isBeforeFirst() );
-        assertFalse( "Cursor @2nd pos should NOT be at the first element", cursor.isFirst() );
-        assertFalse( "Cursor @2nd pos should NOT be after last element", cursor.isAfterLast() );
-        assertFalse( "Cursor @2nd pos should NOT be at the last element", cursor.isLast() );
-
-        while ( cursor.next() )
-        {
-            System.out.println( cursor.get() );
-        }
-    }
-
-
-    @Test
     public void testJdbmBehaviorBrowse() throws Exception
     {
         bt.remove( "0" );
@@ -212,49 +159,6 @@
         assertNull( tuple.getKey() );
         browser.getNext( tuple );
         assertEquals( "1", tuple.getKey() );
-    }
-
-
-    @Test
-    @Ignore ( "This is a performance test and takes a while to run." )
-    public void testCostOfAdvances() throws Exception
-    {
-        final int capacity = 100000;
-        long startTime = System.nanoTime();
-        long startTimeMs = System.currentTimeMillis();
-
-        // fill up the BTree with a lot of data
-        for ( int ii = 10; ii < capacity; ii++ )
-        {
-            bt.insert( String.valueOf( ii ), EMPTY_BYTES, true );
-        }
-
-        long insertTime = System.nanoTime() - startTime;
-        long insertTimeMs = System.currentTimeMillis() - startTimeMs;
-        LOG.debug( "insertion of {} btree records took {} nano seconds", capacity, insertTime );
-        LOG.debug( "insertion of {} btree records took {} milli seconds", capacity, insertTimeMs );
-
-        cursor = new KeyCursor<String>( bt );
-        startTime = System.nanoTime();
-        startTimeMs = System.currentTimeMillis();
-        int advanceTo = capacity - 3;
-        assertTrue( cursor.relative( advanceTo ) );
-        long advanceTime = System.nanoTime() - startTime;
-        long advanceTimeMs = System.currentTimeMillis() - startTimeMs;
-        LOG.debug( "advance from before first to {}th record took {} nano seconds", advanceTo, advanceTime );
-        LOG.debug( "advance from before first to {}th record took {} milli seconds", advanceTo, advanceTimeMs );
-        assertEquals( String.valueOf( advanceTo ), cursor.get() );
-
-        startTime = System.nanoTime();
-        startTimeMs = System.currentTimeMillis();
-        TupleBrowser browser = bt.browse( String.valueOf( advanceTo ) );
-        Tuple tuple = new Tuple();
-        browser.getNext( tuple );
-        long byKeyTime = System.nanoTime() - startTime;
-        long byKeyTimeMs = System.currentTimeMillis() - startTimeMs;
-        LOG.debug( "advance by key to {}th record took {} nano seconds", advanceTo, byKeyTime );
-        LOG.debug( "advance by key to {}th record took {} milli seconds", advanceTo, byKeyTimeMs );
-        assertEquals( String.valueOf( advanceTo ), tuple.getKey() );
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeCursor.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/BTreeCursor.java?rev=606795&r1=606794&r2=606795&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeCursor.java Tue Dec 25 07:49:25 2007
@@ -42,8 +42,6 @@
 
     private BTree btree;
     private TupleBrowser browser;
-    private int pos = BEFORE_FIRST;
-    private int size;  // cache the size to prevent needless lookups
     private boolean afterLast;
     private boolean beforeFirst;
     private boolean success;
@@ -62,7 +60,7 @@
     }
 
 
-    public boolean after( Object element ) throws IOException
+    public void after( Object element ) throws IOException
     {
         throw new NotImplementedException();
     }
@@ -75,8 +73,6 @@
             beforeFirst = true;
             afterLast = false;
             success = false;
-            size = btree.size();
-            pos = BEFORE_FIRST;
             browser = btree.browse();
         }
     }
@@ -89,129 +85,11 @@
             beforeFirst = false;
             afterLast = true;
             success = false;
-            size = btree.size();
-            pos = size;
             browser = btree.browse( null );
         }
     }
 
 
-    public boolean absolute( int absolutePosition ) throws IOException
-    {
-        // -------------------------------------------------------------------
-        // Special cases under or above the valid range puts the cursor
-        // respectively before the first or after the last position
-        // -------------------------------------------------------------------
-
-        if ( absolutePosition >= size )
-        {
-            afterLast();
-            return false;
-        }
-
-        if ( absolutePosition < 0 )
-        {
-            beforeFirst();
-            return false;
-        }
-
-        // -------------------------------------------------------------------
-        // Special case where position is valid and that's the new position
-        // -------------------------------------------------------------------
-
-        if ( absolutePosition == pos )
-        {
-            return success;
-        }
-
-        // -------------------------------------------------------------------
-        // Special easy to get to cases where we don't have to walk the tree
-        // -------------------------------------------------------------------
-
-        if ( absolutePosition == 0 && beforeFirst )
-        {
-            return next();
-        }
-
-        if ( ( absolutePosition == size - 1  ) && afterLast )
-        {
-            return previous();
-        }
-
-        // -------------------------------------------------------------------
-        // Cases we have to walk the tree forward or backwards to get to target
-        // -------------------------------------------------------------------
-
-        if ( absolutePosition > pos )
-        {
-            while ( success && pos < absolutePosition )
-            {
-                next();
-            }
-        }
-        else
-        {
-            while ( success && pos > absolutePosition )
-            {
-                previous();
-            }
-        }
-
-        return success;
-    }
-
-
-    public boolean relative( int relativePosition ) throws IOException
-    {
-        // -------------------------------------------------------------------
-        // Special cases under or above the valid range puts the cursor
-        // respectively before the first or after the last position
-        // -------------------------------------------------------------------
-
-        if ( ( relativePosition + pos ) >= size )
-        {
-            afterLast();
-            return false;
-        }
-
-        if ( ( relativePosition + pos ) < 0 )
-        {
-            beforeFirst();
-            return false;
-        }
-
-        // -------------------------------------------------------------------
-        // Special case where position is valid and that's the new position
-        // -------------------------------------------------------------------
-
-        if ( relativePosition == 0 )
-        {
-            return success;
-        }
-
-        // -------------------------------------------------------------------
-        // Cases we have to walk the tree forward or backwards
-        // -------------------------------------------------------------------
-
-        if ( relativePosition > 0 )
-        {
-            for ( ; success && relativePosition > 0; relativePosition-- )
-            {
-                next();
-            }
-        }
-        else
-        {
-            for ( ; success && relativePosition < 0; relativePosition++ )
-            {
-                previous();
-            }
-        }
-
-        return success;
-    }
-
-
     public boolean first() throws IOException
     {
         if ( beforeFirst )
@@ -219,11 +97,6 @@
             return next();
         }
 
-        if ( pos == 0 )
-        {
-            return success;
-        }
-
         beforeFirst();
         return next();
     }
@@ -236,117 +109,26 @@
             return previous();
         }
 
-        if ( pos == ( size - 1 ) )
-        {
-            return success;
-        }
-
         afterLast();
         return previous();
     }
 
 
-    public boolean isFirst() throws IOException
-    {
-        return pos == 0;
-    }
-
-
-    public boolean isLast() throws IOException
-    {
-        return pos == ( size - 1 );
-    }
-
-
-    public boolean isAfterLast() throws IOException
-    {
-        return afterLast;
-    }
-
-
-    public boolean isBeforeFirst() throws IOException
-    {
-        return beforeFirst;
-    }
-
-
     public boolean previous() throws IOException
     {
-        if ( beforeFirst )
-        {
-            return false;
-        }
-
-        if ( afterLast )
-        {
-            success = browser.getPrevious( jdbmTuple );
-            if ( success )
-            {
-                afterLast = false;
-                beforeFirst = false;
-                pos = size - 1;
-            }
-            return success;
-        }
-
-        if ( pos == 0 )
-        {
-            success = false;
-            afterLast = false;
-            beforeFirst = true;
-            pos = BEFORE_FIRST;
-            return false;
-        }
-
-        success = browser.getPrevious( jdbmTuple );
-        if ( success )
-        {
-            pos--;
-        }
-        return success;
+        throw new NotImplementedException();
     }
 
 
     public boolean next() throws IOException
     {
-        if ( afterLast )
-        {
-            return false;
-        }
-
-        if ( beforeFirst )
-        {
-            success = browser.getNext( jdbmTuple );
-            if ( success )
-            {
-                afterLast = false;
-                beforeFirst = false;
-                pos = 0;
-            }
-            return success;
-        }
-
-        if ( pos == size - 1 )
-        {
-            success = false;
-            afterLast = true;
-            beforeFirst = false;
-            pos = size;
-            return false;
-        }
-
-        success = browser.getNext( jdbmTuple );
-        if ( success )
-        {
-            pos++;
-        }
-        return success;
+        throw new NotImplementedException();
     }
 
 
     private boolean inRangeOnValue()
     {
-        return pos > BEFORE_FIRST && pos < size;
+        throw new NotImplementedException();
     }
 
 



Mime
View raw message