You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/12/15 01:58:49 UTC

svn commit: r604361 [2/4] - in /directory/sandbox/akarasulu/bigbang: apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ apacheds/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/core-integ/...

Added: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/CursorClosedException.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/CursorClosedException.java?rev=604361&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/CursorClosedException.java (added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/CursorClosedException.java Fri Dec 14 16:58:40 2007
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.cursor;
+
+
+import java.io.IOException;
+
+
+/**
+ * A specific form of IOException to note that an operation is being
+ * attempted on a closed Cursor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CursorClosedException extends IOException
+{
+    public CursorClosedException()
+    {
+    }
+
+
+    public CursorClosedException( String s )
+    {
+        super( s );
+    }
+}

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/CursorClosedException.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java?rev=604361&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java (added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java Fri Dec 14 16:58:40 2007
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.cursor;
+
+
+import java.io.IOException;
+
+
+/**
+ * An empty Cursor implementation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EmptyCursor<E> extends AbstractCursor
+{
+    public void beforeFirst() throws CursorClosedException
+    {
+        checkClosed( "beforeFirst()" );
+    }
+
+
+    public void afterLast() throws CursorClosedException
+    {
+        checkClosed( "afterLast()" );
+    }
+
+
+    @SuppressWarnings ( { "UnusedDeclaration" } )
+    public boolean absolute( int absolutePosition ) throws CursorClosedException
+    {
+        checkClosed( "absolute()" );
+        return false;
+    }
+
+
+    @SuppressWarnings ( { "UnusedDeclaration" } )
+    public boolean relative( int relativePosition ) throws CursorClosedException
+    {
+        checkClosed( "relative()" );
+        return false;
+    }
+
+
+    public boolean first() throws CursorClosedException
+    {
+        checkClosed( "first()" );
+        return false;
+    }
+
+
+    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;
+    }
+
+
+    public boolean previous() throws CursorClosedException
+    {
+        checkClosed( "previous()" );
+        return false;
+    }
+
+
+    public boolean next() throws CursorClosedException
+    {
+        checkClosed( "next()" );
+        return false;
+    }
+
+
+    public E get() throws IOException
+    {
+        checkClosed( "get()" );
+        throw new InvalidCursorPositionException( "This cursor is empty and cannot return elements!" );
+    }
+
+
+    public boolean isElementReused()
+    {
+        return false;
+    }
+}

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/EmptyCursor.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InconsistentCursorStateException.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InconsistentCursorStateException.java?rev=604361&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InconsistentCursorStateException.java (added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InconsistentCursorStateException.java Fri Dec 14 16:58:40 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.cursor;
+
+
+import java.io.IOException;
+
+
+/**
+ * Thrown to indicate a condition in the Cursor where the state seems
+ * inconsistent based on internal accounting.  This may indicate the
+ * underlying structure has changed after the Cursor has been created.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InconsistentCursorStateException extends IOException
+{
+    public InconsistentCursorStateException()
+    {
+    }
+
+
+    public InconsistentCursorStateException( String s )
+    {
+        super( s );
+    }
+}
\ No newline at end of file

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InconsistentCursorStateException.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InvalidCursorPositionException.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InvalidCursorPositionException.java?rev=604361&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InvalidCursorPositionException.java (added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InvalidCursorPositionException.java Fri Dec 14 16:58:40 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.cursor;
+
+import java.io.IOException;
+
+
+/**
+ * Thrown to indicate an illegal position state for a Cursor when a call to
+ * get is made.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InvalidCursorPositionException extends IOException
+{
+    public InvalidCursorPositionException ()
+    {
+    }
+
+
+    public InvalidCursorPositionException ( String s )
+    {
+        super( s );
+    }
+}

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/InvalidCursorPositionException.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java?rev=604361&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java (added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java Fri Dec 14 16:58:40 2007
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.cursor;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+
+/**
+ * A limited Cursor over an Iterator of elements.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class IteratorCursor<E> extends AbstractCursor
+{
+    private final Iterator<E> values;
+    private Object current;
+
+
+    public IteratorCursor( Iterator<E> values )
+    {
+        this.values = values;
+    }
+
+
+    public void beforeFirst() throws IOException
+    {
+        throw new UnsupportedOperationException( "Cannot advance before first on the underlying Iterator." );
+    }
+
+
+    public void afterLast() throws IOException
+    {
+        throw new UnsupportedOperationException( "Cannot adanvce after last on the underlying Iterator." );
+    }
+
+
+    public boolean absolute( int absolutePosition ) throws IOException
+    {
+        throw new UnsupportedOperationException( "Cannot advance to an absolute postion on the underlying Iterator." );
+    }
+
+
+    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." );
+    }
+
+
+    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." );
+    }
+
+
+    public boolean previous() throws IOException
+    {
+        throw new UnsupportedOperationException( "Cannot back up on the underlying Iterator." );
+    }
+
+
+    public boolean next() throws IOException
+    {
+        checkClosed( "next()" );
+        if ( values.hasNext() )
+        {
+            current = values.next();
+            return true;
+        }
+
+        return false;
+    }
+
+
+    public Object get() throws IOException
+    {
+        checkClosed( "get()" );
+        return current;
+    }
+
+
+    public boolean isElementReused()
+    {
+        return false;
+    }
+}

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/IteratorCursor.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/ListCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/ListCursor.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/ListCursor.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/ListCursor.java Fri Dec 14 16:58:40 2007
@@ -31,12 +31,11 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ListCursor<E> implements Cursor<E>
+public class ListCursor<E> extends AbstractCursor
 {
     private final List<E> list;
     private final int start;
     private final int end;
-    private boolean closed;
     private int index = -1;
 
 
@@ -138,15 +137,6 @@
     }
 
 
-    protected void checkClosed( String operation ) throws IOException
-    {
-        if ( closed )
-        {
-            throw new IOException( "Attempting " + operation + " operation on a closed Cursor." );
-        }
-    }
-
-
     public void beforeFirst() throws IOException
     {
         checkClosed( "beforeFirst()" );
@@ -260,12 +250,6 @@
     }
 
 
-    public boolean isClosed()
-    {
-        return closed;
-    }
-
-
     public boolean previous() throws IOException
     {
         checkClosed( "previous()" );
@@ -348,11 +332,5 @@
     public boolean isElementReused()
     {
         return true;
-    }
-
-
-    public void close()
-    {
-        closed = true;
     }
 }

Added: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java?rev=604361&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java (added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java Fri Dec 14 16:58:40 2007
@@ -0,0 +1,243 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.cursor;
+
+
+import java.io.IOException;
+
+
+/**
+ * A Cursor on a single element.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SingletonCursor<E> extends AbstractCursor
+{
+    private boolean beforeFirst = true;
+    private boolean afterLast;
+    private boolean onSingleton;
+    private final E singleton;
+
+
+    public SingletonCursor( E singleton )
+    {
+        this.singleton = singleton;
+    }
+
+
+    public void beforeFirst() throws IOException
+    {
+        checkClosed( "()" );
+        beforeFirst = true;
+        afterLast = false;
+        onSingleton = false;
+    }
+
+
+    public void afterLast() throws IOException
+    {
+        checkClosed( "()" );
+        beforeFirst = false;
+        afterLast = true;
+        onSingleton = false;
+    }
+
+
+    public boolean absolute( int absolutePosition ) throws IOException
+    {
+        checkClosed( "()" );
+        if ( absolutePosition == 0 )
+        {
+            beforeFirst = false;
+            onSingleton = true;
+            afterLast = false;
+            return true;
+        }
+        else if ( absolutePosition > 0 )
+        {
+            beforeFirst = false;
+            onSingleton = false;
+            afterLast = true;
+            return false;
+        }
+        else
+        {
+            beforeFirst = true;
+            onSingleton = false;
+            afterLast = false;
+            return false;
+        }
+    }
+
+
+    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( "()" );
+        beforeFirst = false;
+        onSingleton = true;
+        afterLast = false;
+        return true;
+    }
+
+
+    public boolean last() throws IOException
+    {
+        checkClosed( "()" );
+        beforeFirst = false;
+        onSingleton = true;
+        afterLast = false;
+        return true;
+    }
+
+
+    public boolean isFirst() throws IOException
+    {
+        checkClosed( "()" );
+        return onSingleton;
+    }
+
+
+    public boolean isLast() throws IOException
+    {
+        checkClosed( "()" );
+        return onSingleton;
+    }
+
+
+    public boolean isAfterLast() throws IOException
+    {
+        checkClosed( "()" );
+        return afterLast;
+    }
+
+
+    public boolean isBeforeFirst() throws IOException
+    {
+        checkClosed( "()" );
+        return beforeFirst;
+    }
+
+
+    public boolean previous() throws IOException
+    {
+        checkClosed( "()" );
+        if ( beforeFirst )
+        {
+            return false;
+        }
+
+        if ( afterLast )
+        {
+            beforeFirst = false;
+            onSingleton = true;
+            afterLast = false;
+            return true;
+        }
+
+        // must be on the singleton
+        beforeFirst = true;
+        onSingleton = false;
+        afterLast = false;
+        return false;
+    }
+
+
+    public boolean next() throws IOException
+    {
+        checkClosed( "()" );
+        if ( beforeFirst )
+        {
+            beforeFirst = false;
+            onSingleton = true;
+            afterLast = false;
+            return true;
+        }
+
+        if ( afterLast )
+        {
+            return false;
+        }
+
+        // must be on the singleton
+        beforeFirst = false;
+        onSingleton = false;
+        afterLast = true;
+        return false;
+    }
+
+
+    public E get() throws IOException
+    {
+        checkClosed( "()" );
+        if ( onSingleton )
+        {
+            return singleton;
+        }
+
+        if ( beforeFirst )
+        {
+            throw new InvalidCursorPositionException( "Cannot access element if positioned before first." );
+        }
+        else
+        {
+            throw new InvalidCursorPositionException( "Cannot access element if positioned after last." );
+        }
+    }
+
+
+    public boolean isElementReused()
+    {
+        return true;
+    }
+}

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/core-shared/src/main/java/org/apache/directory/server/core/cursor/SingletonCursor.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java Fri Dec 14 16:58:40 2007
@@ -256,7 +256,14 @@
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
             Index idx = db.getUserIndex( node.getAttribute() );
-            return Long.valueOf( idx.count( node.getValue() ) );
+            try
+            {
+                return Long.valueOf( idx.count( node.getValue() ) );
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
 
         // count for non-indexed attribute is unknown so we presume da worst
@@ -278,7 +285,14 @@
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
             Index idx = db.getUserIndex( node.getAttribute() );
-            int count = idx.count( node.getValue(), isGreaterThan );
+            try
+            {
+                int count = idx.count( node.getValue(), isGreaterThan );
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
             return Long.valueOf( count );
         }
 
@@ -301,7 +315,14 @@
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
             Index idx = db.getUserIndex( node.getAttribute() );
-            int count = idx.count();
+            try
+            {
+                int count = idx.count();
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
             return Long.valueOf( count );
         }
 
@@ -322,7 +343,14 @@
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
             Index idx = db.getExistanceIndex();
-            int count = idx.count( node.getAttribute() );
+            try
+            {
+                int count = idx.count( node.getAttribute() );
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
             return Long.valueOf( count );
         }
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultSearchEngine.java Fri Dec 14 16:58:40 2007
@@ -90,7 +90,14 @@
     {
         Name effectiveBase;
         Long baseId = db.getEntryId( base.toString() );
-        String aliasedBase = ( String ) db.getAliasIndex().reverseLookup( baseId );
+        try
+        {
+            String aliasedBase = ( String ) db.getAliasIndex().reverseLookup( baseId );
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         // --------------------------------------------------------------------
         // Determine the eective base with aliases

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEnumerator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEnumerator.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEnumerator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ExpressionEnumerator.java Fri Dec 14 16:58:40 2007
@@ -194,8 +194,15 @@
     {
     	NamingEnumeration<IndexRecord> baseEnumeration = null;
     	NamingEnumeration<IndexRecord> enumeration = null;
-        
-        baseEnumeration = db.getNdnIndex().listIndices();
+
+        try
+        {
+            baseEnumeration = db.getNdnIndex().listIndices();
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         IndexAssertion assertion = new IndexAssertion()
         {
@@ -290,7 +297,14 @@
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
             Index idx = db.getExistanceIndex();
-            return idx.listIndices( node.getAttribute() );
+            try
+            {
+                return idx.listIndices( node.getAttribute() );
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
 
         return nonIndexedScan( node );
@@ -312,7 +326,14 @@
         {
             Index idx = db.getUserIndex( node.getAttribute() );
 
-            return idx.listIndices( node.getValue(), isGreaterOrLesser );
+            try
+            {
+                return idx.listIndices( node.getValue(), isGreaterOrLesser );
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
 
         return nonIndexedScan( node );
@@ -332,7 +353,14 @@
         if ( db.hasUserIndexOn( node.getAttribute() ) )
         {
             Index idx = db.getUserIndex( node.getAttribute() );
-            return idx.listIndices( node.getValue() );
+            try
+            {
+                return idx.listIndices( node.getValue() );
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
 
         return nonIndexedScan( node );
@@ -349,8 +377,15 @@
      */
     private NamingEnumeration<IndexRecord> nonIndexedScan( final LeafNode node ) throws NamingException
     {
-    	NamingEnumeration<IndexRecord> underlying = db.getNdnIndex().listIndices();
-    	
+        try
+        {
+            NamingEnumeration<IndexRecord> underlying = db.getNdnIndex().listIndices();
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+
         IndexAssertion assertion = new IndexAssertion()
         {
             public boolean assertCandidate( IndexRecord record ) throws NamingException

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java Fri Dec 14 16:58:40 2007
@@ -124,7 +124,7 @@
      * @throws NamingException
      */
     private boolean matchValue( SimpleNode node, Attribute attr, AttributeType type, Normalizer normalizer,
-        Comparator comparator ) throws NamingException
+        Comparator<Object> comparator ) throws NamingException
     {
         // get the normalized AVA filter value
         Object filterValue = node.getValue();
@@ -251,16 +251,30 @@
 
             if ( isGreaterOrLesser = SimpleNode.EVAL_GREATER )
             {
-                if ( idx.hasValue( node.getValue(), id, SimpleNode.EVAL_GREATER ) )
+                try
                 {
-                    return true;
+                    if ( idx.hasValue( node.getValue(), id, SimpleNode.EVAL_GREATER ) )
+                    {
+                        return true;
+                    }
+                }
+                catch ( java.io.IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                 }
             }
             else
             {
-                if ( idx.hasValue( node.getValue(), id, SimpleNode.EVAL_LESSER ) )
+                try
                 {
-                    return true;
+                    if ( idx.hasValue( node.getValue(), id, SimpleNode.EVAL_LESSER ) )
+                    {
+                        return true;
+                    }
+                }
+                catch ( java.io.IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                 }
             }
         }
@@ -286,7 +300,7 @@
          * and use the comparator to determine if a match exists.
          */
         Normalizer normalizer = getNormalizer( attrId, ORDERING_MATCH );
-        Comparator comparator = getComparator( attrId, ORDERING_MATCH );
+        Comparator<Object> comparator = getComparator( attrId, ORDERING_MATCH );
         Object filterValue = node.getValue();
         NamingEnumeration list = attr.getAll();
 
@@ -345,9 +359,16 @@
             // We have a fast find if the entry contains 
             // this attribute type : as the AT was indexed, we
             // have a direct access to the entry.
-            if ( idx.hasValue( attrId, rec.getEntryId() ) )
+            try
             {
-                return true;
+                if ( idx.hasValue( attrId, rec.getEntryId() ) )
+                {
+                    return true;
+                }
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
             }
 
             // Fallthrough : we may have some descendant 
@@ -425,20 +446,27 @@
             // from the index.
             Index idx = db.getUserIndex( filterAttr );
 
-            if ( idx.hasValue( filterValue, rec.getEntryId() ) )
+            try
             {
-                return true;
+                if ( idx.hasValue( filterValue, rec.getEntryId() ) )
+                {
+                    return true;
+                }
+                else
+                {
+                    // FallThrough : we may have some descendant attributes
+                    // which values are equal to the filter value.
+                }
             }
-            else
+            catch ( java.io.IOException e )
             {
-                // FallThrough : we may have some descendant attributes
-                // which values are equal to the filter value.
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
             }
         }
 
         // Get the normalizer and comparator for this attributeType
         Normalizer normalizer = getNormalizer( filterAttr, EQUALITY_MATCH );
-        Comparator<?> comparator = getComparator( filterAttr, EQUALITY_MATCH );
+        Comparator<Object> comparator = getComparator( filterAttr, EQUALITY_MATCH );
 
         /*
          * Get the attribute and if it is not set in rec then resusitate it
@@ -530,7 +558,7 @@
      * @throws NamingException if there is a failure
      */
     @SuppressWarnings("unchecked")
-    private Comparator<?> getComparator( String attrId, int matchType ) throws NamingException
+    private Comparator<Object> getComparator( String attrId, int matchType ) throws NamingException
     {
         MatchingRule mrule = getMatchingRule( attrId, matchType );
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ScopeEnumerator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ScopeEnumerator.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ScopeEnumerator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ScopeEnumerator.java Fri Dec 14 16:58:40 2007
@@ -99,7 +99,14 @@
     {
         Index idx = db.getHierarchyIndex();
         final Long id = db.getEntryId( dn );
-        final NamingEnumeration<IndexRecord> children = idx.listIndices( id );
+        try
+        {
+            final NamingEnumeration<IndexRecord> children = idx.listIndices( id );
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         /*
          * If alias dereferencing is not enabled while searching then we just
@@ -123,7 +130,14 @@
 
         // List all entries brought into one level scope at base by aliases
         idx = db.getOneAliasIndex();
-        NamingEnumeration aliasIntroduced = idx.listIndices( id );
+        try
+        {
+            NamingEnumeration aliasIntroduced = idx.listIndices( id );
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         // Still need to use assertion enum to weed out aliases
         NamingEnumeration nonAliasChildren = new IndexAssertionEnumeration( children, new AssertNotAlias() );
@@ -157,7 +171,14 @@
         {
             // Gets a NamingEnumeration over all elements
             idx = db.getNdnIndex();
-            NamingEnumeration<IndexRecord> underlying = idx.listIndices();
+            try
+            {
+                NamingEnumeration<IndexRecord> underlying = idx.listIndices();
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
             return new IndexAssertionEnumeration( underlying, new AssertDescendant( node ) );
         }
 
@@ -172,7 +193,14 @@
 
         // Gets a NamingEnumeration over all elements
         idx = db.getNdnIndex();
-        NamingEnumeration<IndexRecord> underlying = idx.listIndices();
+        try
+        {
+            NamingEnumeration<IndexRecord> underlying = idx.listIndices();
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
         return new IndexAssertionEnumeration( underlying, assertion );
     }
 
@@ -223,9 +251,16 @@
         {
             Index aliasIdx = db.getAliasIndex();
 
-            if ( null == aliasIdx.reverseLookup( record.getEntryId() ) )
+            try
+            {
+                if ( null == aliasIdx.reverseLookup( record.getEntryId() ) )
+                {
+                    return true;
+                }
+            }
+            catch ( java.io.IOException e )
             {
-                return true;
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
             }
 
             return false;

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ScopeEvaluator.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ScopeEvaluator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ScopeEvaluator.java Fri Dec 14 16:58:40 2007
@@ -110,9 +110,16 @@
          */
         Index idx = db.getAliasIndex();
 
-        if ( null != idx.reverseLookup( id ) )
+        try
         {
-            return false;
+            if ( null != idx.reverseLookup( id ) )
+            {
+                return false;
+            }
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }
 
         /*
@@ -138,8 +145,15 @@
          * candidate is rejected with a false return because it is not in scope.
          */
         idx = db.getSubAliasIndex();
-        
-        return idx.hasValue( baseId, id );
+
+        try
+        {
+            return idx.hasValue( baseId, id );
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
@@ -158,7 +172,14 @@
         AliasDerefMode mode = node.getDerefAliases();
         Object baseId = db.getEntryId( node.getBaseDn() );
         Index idx = db.getHierarchyIndex();
-        boolean isChild = idx.hasValue( baseId, id );
+        try
+        {
+            boolean isChild = idx.hasValue( baseId, id );
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         /*
          * The candidate id could be any entry in the db.  If search 
@@ -176,10 +197,17 @@
          * not be returned.
          */
         idx = db.getAliasIndex();
-        
-        if ( null != idx.reverseLookup( id ) )
+
+        try
         {
-            return false;
+            if ( null != idx.reverseLookup( id ) )
+            {
+                return false;
+            }
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }
 
         /*
@@ -202,7 +230,14 @@
          * candidate is rejected with a false return because it is not in scope.
          */
         idx = db.getOneAliasIndex();
-        
-        return idx.hasValue( baseId, id );
+
+        try
+        {
+            return idx.hasValue( baseId, id );
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 }

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEnumerator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEnumerator.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEnumerator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEnumerator.java Fri Dec 14 16:58:40 2007
@@ -115,11 +115,25 @@
             idx = db.getUserIndex( snode.getAttribute() );
             if ( null == snode.getInitial() )
             {
-                return idx.listIndices( regex );
+                try
+                {
+                    return idx.listIndices( regex );
+                }
+                catch ( java.io.IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
             }
             else
             {
-                return idx.listIndices( regex, snode.getInitial() );
+                try
+                {
+                    return idx.listIndices( regex, snode.getInitial() );
+                }
+                catch ( java.io.IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
             }
         }
 
@@ -132,8 +146,15 @@
          * underlying enumeration.  An evaluator in an assertion is used to 
          * constrain the result set.
          */
-        NamingEnumeration<IndexRecord> underlying = db.getNdnIndex().listIndices();
-        
+        try
+        {
+            NamingEnumeration<IndexRecord> underlying = db.getNdnIndex().listIndices();
+        }
+        catch ( java.io.IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+
         IndexAssertion assertion = new IndexAssertion()
         {
             public boolean assertCandidate( final IndexRecord record ) throws NamingException

Modified: directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEvaluator.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEvaluator.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/SubstringEvaluator.java Fri Dec 14 16:58:40 2007
@@ -105,7 +105,14 @@
              * no reverse lookups.
              */
 
-            NamingEnumeration entries = idx.listReverseIndices( record.getEntryId() );
+            try
+            {
+                NamingEnumeration entries = idx.listReverseIndices( record.getEntryId() );
+            }
+            catch ( java.io.IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
 
             // compile the regular expression to search for a matching attribute
             try

Added: 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=604361&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeCursor.java (added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeCursor.java Fri Dec 14 16:58:40 2007
@@ -0,0 +1,364 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.partition.impl.btree.jdbm;
+
+
+import jdbm.btree.BTree;
+import jdbm.helper.Tuple;
+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 java.io.IOException;
+
+
+/**
+ * @TODO you better test me man!!!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BTreeCursor extends AbstractCursor
+{
+    private final jdbm.helper.Tuple jdbmTuple = new Tuple();
+
+    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;
+
+
+    BTreeCursor( BTree btree ) throws IOException
+    {
+        this.btree = btree;
+        beforeFirst();
+    }
+
+
+    public void beforeFirst() throws IOException
+    {
+        if ( ! beforeFirst )
+        {
+            beforeFirst = true;
+            afterLast = false;
+            success = false;
+            size = btree.size();
+            pos = BEFORE_FIRST;
+            browser = btree.browse();
+        }
+    }
+
+
+    public void afterLast() throws IOException
+    {
+        if ( ! afterLast )
+        {
+            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 )
+        {
+            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;
+    }
+
+
+    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;
+    }
+
+
+    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;
+    }
+
+
+    private boolean inRangeOnValue()
+    {
+        return pos > BEFORE_FIRST && pos < size;
+    }
+
+
+
+    public Object get() throws IOException
+    {
+        if ( ! inRangeOnValue() )
+        {
+            throw new InvalidCursorPositionException();
+        }
+
+        if ( success )
+        {
+            return jdbmTuple.getKey();
+        }
+        else
+        {
+            throw new InconsistentCursorStateException( "Seems like the position is in range however the " +
+                    "last operation failed to produce a successful result" );
+        }
+    }
+
+
+    public boolean isElementReused()
+    {
+        return false;
+    }
+}

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeCursor.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeEnumeration.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/BTreeEnumeration.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeEnumeration.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeEnumeration.java Fri Dec 14 16:58:40 2007
@@ -46,7 +46,7 @@
 {
     private final jdbm.helper.Tuple jdbmTuple = new jdbm.helper.Tuple();
     private TupleBrowser browser;
-    private boolean success = false;
+    private boolean success;
     
     
     BTreeEnumeration( BTree tree ) throws NamingException 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeTupleEnumeration.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/BTreeTupleEnumeration.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeTupleEnumeration.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeTupleEnumeration.java Fri Dec 14 16:58:40 2007
@@ -66,7 +66,7 @@
     {
         this.key = key;
         stepForward = isGreaterThan;
-        
+                                                                     
         try
         {
             browser = tree.browse( val );

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.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/JdbmIndex.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Fri Dec 14 16:58:40 2007
@@ -24,10 +24,8 @@
 import jdbm.helper.MRU;
 import jdbm.recman.BaseRecordManager;
 import jdbm.recman.CacheRecordManager;
-import org.apache.directory.server.core.partition.impl.btree.Index;
-import org.apache.directory.server.core.partition.impl.btree.IndexComparator;
-import org.apache.directory.server.core.partition.impl.btree.IndexEnumeration;
-import org.apache.directory.server.core.partition.impl.btree.Tuple;
+import org.apache.directory.server.core.partition.impl.btree.*;
+import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.schema.SerializableComparator;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
@@ -349,7 +347,7 @@
     /**
      * @see Index#count()
      */
-    public int count() throws NamingException
+    public int count() throws IOException
     {
         return forward.count();
     }
@@ -358,7 +356,7 @@
     /**
      * @see Index#count(java.lang.Object)
      */
-    public int count( Object attrVal ) throws NamingException
+    public int count( Object attrVal ) throws IOException
     {
         return forward.count( getNormalized( attrVal ) );
     }
@@ -367,7 +365,7 @@
     /**
      * @see org.apache.directory.server.core.partition.impl.btree.Index#count(java.lang.Object, boolean)
      */
-    public int count( Object attrVal, boolean isGreaterThan ) throws NamingException
+    public int count( Object attrVal, boolean isGreaterThan ) throws IOException
     {
         return forward.count( getNormalized( attrVal ), isGreaterThan );
     }
@@ -381,7 +379,7 @@
     /**
      * @see Index#forwardLookup(java.lang.Object)
      */
-    public Long forwardLookup( Object attrVal ) throws NamingException
+    public Long forwardLookup( Object attrVal ) throws IOException
     {
         return ( Long ) forward.get( getNormalized( attrVal ) );
     }
@@ -390,7 +388,7 @@
     /**
      * @see Index#reverseLookup(Object)
      */
-    public Object reverseLookup( Object id ) throws NamingException
+    public Object reverseLookup( Object id ) throws IOException
     {
         return reverse.get( id );
     }
@@ -404,7 +402,7 @@
     /**
      * @see Index#add(Object,Object)
      */
-    public synchronized void add( Object attrVal, Object id ) throws NamingException
+    public synchronized void add( Object attrVal, Object id ) throws IOException
     {
         forward.put( getNormalized( attrVal ), id );
         reverse.put( id, getNormalized( attrVal ) );
@@ -414,7 +412,7 @@
     /**
      * @see Index#add(Attribute, Object)
      */
-    public synchronized void add( Attribute attr, Object id ) throws NamingException
+    public synchronized void add( Attribute attr, Object id ) throws IOException
     {
         // Can efficiently batch add to the reverse table 
         NamingEnumeration values = attr.getAll();
@@ -432,7 +430,7 @@
     /**
      * @see Index#add(Attributes, Object)
      */
-    public synchronized void add( Attributes attrs, Object id ) throws NamingException
+    public synchronized void add( Attributes attrs, Object id ) throws IOException
     {
         add( AttributeUtils.getAttribute( attrs, attribute ), id );
     }
@@ -441,7 +439,7 @@
     /**
      * @see Index#drop(Object,Object)
      */
-    public synchronized void drop( Object attrVal, Object id ) throws NamingException
+    public synchronized void drop( Object attrVal, Object id ) throws IOException
     {
         forward.remove( getNormalized( attrVal ), id );
         reverse.remove( id, getNormalized( attrVal ) );
@@ -451,7 +449,7 @@
     /**
      * @see Index#drop(Object)
      */
-    public void drop( Object entryId ) throws NamingException
+    public void drop( Object entryId ) throws IOException
     {
         NamingEnumeration<Object> values = reverse.listValues( entryId );
 
@@ -467,7 +465,7 @@
     /**
      * @see Index#drop(Attribute, Object)
      */
-    public void drop( Attribute attr, Object id ) throws NamingException
+    public void drop( Attribute attr, Object id ) throws IOException
     {
         // Can efficiently batch remove from the reverse table 
         NamingEnumeration values = attr.getAll();
@@ -493,7 +491,7 @@
     /**
      * @see Index#drop(Attributes, Object)
      */
-    public void drop( Attributes attrs, Object id ) throws NamingException
+    public void drop( Attributes attrs, Object id ) throws IOException
     {
         drop( AttributeUtils.getAttribute( attrs, attribute ), id );
     }
@@ -507,7 +505,7 @@
     /**
      * @see Index#listReverseIndices(Object)
      */
-    public IndexEnumeration listReverseIndices( Object id ) throws NamingException
+    public Cursor<IndexRecord> listReverseIndices( Object id ) throws IOException
     {
         return new IndexEnumeration<Tuple>( reverse.listTuples( id ), true );
     }
@@ -516,7 +514,7 @@
     /**
      * @see Index#listIndices()
      */
-    public IndexEnumeration listIndices() throws NamingException
+    public Cursor<IndexRecord> listIndices() throws IOException
     {
         return new IndexEnumeration<Tuple>( forward.listTuples() );
     }
@@ -525,7 +523,7 @@
     /**
      * @see Index#listIndices(Object)
      */
-    public IndexEnumeration listIndices( Object attrVal ) throws NamingException
+    public Cursor<IndexRecord> listIndices( Object attrVal ) throws IOException
     {
         return new IndexEnumeration<Tuple>( forward.listTuples( getNormalized( attrVal ) ) );
     }
@@ -534,7 +532,7 @@
     /**
      * @see Index#listIndices(Object,boolean)
      */
-    public IndexEnumeration<Tuple> listIndices( Object attrVal, boolean isGreaterThan ) throws NamingException
+    public Cursor<IndexRecord> listIndices( Object attrVal, boolean isGreaterThan ) throws IOException
     {
         return new IndexEnumeration<Tuple>( forward.listTuples( getNormalized( attrVal ), isGreaterThan ) );
     }
@@ -543,7 +541,7 @@
     /**
      * @see Index#listIndices(Pattern)
      */
-    public IndexEnumeration<Tuple> listIndices( Pattern regex ) throws NamingException
+    public Cursor<IndexRecord> listIndices( Pattern regex ) throws IOException
     {
         return new IndexEnumeration<Tuple>( forward.listTuples(), false, regex );
     }
@@ -552,7 +550,7 @@
     /**
      * @see Index#listIndices(Pattern,String)
      */
-    public IndexEnumeration<Tuple> listIndices( Pattern regex, String prefix ) throws NamingException
+    public Cursor<IndexRecord> listIndices( Pattern regex, String prefix ) throws IOException
     {
         return new IndexEnumeration<Tuple>( forward.listTuples( getNormalized( prefix ), true ), false, regex );
     }
@@ -567,7 +565,7 @@
      * @see Index#hasValue(java.lang.Object,
      * Object)
      */
-    public boolean hasValue( Object attrVal, Object id ) throws NamingException
+    public boolean hasValue( Object attrVal, Object id ) throws IOException
     {
         return forward.has( getNormalized( attrVal ), id );
     }
@@ -577,7 +575,7 @@
      * @see Index#hasValue(java.lang.Object,
      * Object, boolean)
      */
-    public boolean hasValue( Object attrVal, Object id, boolean isGreaterThan ) throws NamingException
+    public boolean hasValue( Object attrVal, Object id, boolean isGreaterThan ) throws IOException
     {
         return forward.has( getNormalized( attrVal ), id, isGreaterThan );
     }
@@ -586,7 +584,7 @@
     /**
      * @see Index#hasValue(Pattern,Object)
      */
-    public boolean hasValue( Pattern regex, Object id ) throws NamingException
+    public boolean hasValue( Pattern regex, Object id ) throws IOException
     {
         IndexEnumeration<Tuple> list = new IndexEnumeration<Tuple>( reverse.listTuples( id ), true, regex );
         boolean hasValue = list.hasMore();
@@ -603,41 +601,21 @@
     /**
      * @see Index#close()
      */
-    public synchronized void close() throws NamingException
+    public synchronized void close() throws IOException
     {
-        try
-        {
-            forward.close();
-            reverse.close();
-            recMan.commit();
-            recMan.close();
-        }
-        catch ( IOException e )
-        {
-            NamingException ne = new NamingException( "Exception while closing backend index file for attribute "
-                + attribute.getName() );
-            ne.setRootCause( e );
-            throw ne;
-        }
+        forward.close();
+        reverse.close();
+        recMan.commit();
+        recMan.close();
     }
 
 
     /**
      * @see Index#sync()
      */
-    public synchronized void sync() throws NamingException
+    public synchronized void sync() throws IOException
     {
-        try
-        {
-            recMan.commit();
-        }
-        catch ( IOException e )
-        {
-            NamingException ne = new NamingException( "Exception while syncing backend index file for attribute "
-                + attribute.getName() );
-            ne.setRootCause( e );
-            throw ne;
-        }
+        recMan.commit();
     }
 
 
@@ -645,7 +623,7 @@
      * TODO I don't think the keyCache is required anymore since the normalizer
      * will cache values for us.
      */
-    public Object getNormalized( Object attrVal ) throws NamingException
+    public Object getNormalized( Object attrVal ) throws IOException
     {
         if ( attrVal instanceof Long )
         {
@@ -656,7 +634,14 @@
 
         if ( null == normalized )
         {
-            normalized = attribute.getEquality().getNormalizer().normalize( attrVal );
+            try
+            {
+                normalized = attribute.getEquality().getNormalizer().normalize( attrVal );
+            }
+            catch ( NamingException e )
+            {
+                throw new IOException ( "Failed to normalized the original value: " + attrVal, e );
+            }
 
             // Double map it so if we use an already normalized
             // value we can get back the same normalized value.

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.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/JdbmMasterTable.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java Fri Dec 14 16:58:40 2007
@@ -29,6 +29,8 @@
 import org.apache.directory.server.core.partition.impl.btree.MasterTable;
 import org.apache.directory.server.schema.SerializableComparator;
 
+import java.io.IOException;
+
 
 /**
  * The master table used to store the Attributes of entries.
@@ -93,11 +95,25 @@
     {
         super( DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, new AttributesSerializer() );
         adminTbl = new JdbmTable( "admin", recMan, STRING_COMPARATOR, null, null );
-        String seqValue = ( String ) adminTbl.get( SEQPROP_KEY );
+        try
+        {
+            String seqValue = ( String ) adminTbl.get( SEQPROP_KEY );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         if ( null == seqValue )
         {
-            adminTbl.put( SEQPROP_KEY, "0" );
+            try
+            {
+                adminTbl.put( SEQPROP_KEY, "0" );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
     }
 
@@ -109,7 +125,7 @@
      * @return the Attributes of the entry with operational attributes and all.
      * @throws NamingException if there is a read error on the underlying Db.
      */
-    public Attributes get( Object id ) throws NamingException
+    public Attributes get( Object id ) throws IOException
     {
         return ( Attributes ) super.get( id );
     }
@@ -158,12 +174,26 @@
 
         synchronized ( adminTbl )
         {
-            id = new Long( ( String ) adminTbl.get( SEQPROP_KEY ) );
+            try
+            {
+                id = new Long( ( String ) adminTbl.get( SEQPROP_KEY ) );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
 
             //noinspection ConstantConditions
             if ( null == id )
             {
-                adminTbl.put( SEQPROP_KEY, "0" );
+                try
+                {
+                    adminTbl.put( SEQPROP_KEY, "0" );
+                }
+                catch ( IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
                 id = 0L;
             }
         }
@@ -189,17 +219,38 @@
 
         synchronized ( adminTbl )
         {
-            lastVal = new Long( ( String ) adminTbl.get( SEQPROP_KEY ) );
+            try
+            {
+                lastVal = new Long( ( String ) adminTbl.get( SEQPROP_KEY ) );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
 
             //noinspection ConstantConditions
             if ( null == lastVal )
             {
-                adminTbl.put( SEQPROP_KEY, "1" );
+                try
+                {
+                    adminTbl.put( SEQPROP_KEY, "1" );
+                }
+                catch ( IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
                 return 1L;
             } else
             {
                 nextVal = lastVal + 1L;
-                adminTbl.put( SEQPROP_KEY, nextVal.toString() );
+                try
+                {
+                    adminTbl.put( SEQPROP_KEY, nextVal.toString() );
+                }
+                catch ( IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
             }
         }
 
@@ -218,7 +269,14 @@
     {
         synchronized ( adminTbl )
         {
-            return ( String ) adminTbl.get( property );
+            try
+            {
+                return ( String ) adminTbl.get( property );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
     }
 
@@ -234,7 +292,14 @@
     {
         synchronized ( adminTbl )
         {
-            adminTbl.put( property, value );
+            try
+            {
+                adminTbl.put( property, value );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
     }