directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r656019 [1/2] - in /directory/apacheds/branches/bigbang: btree-base/src/main/java/org/apache/directory/server/xdbm/ btree-base/src/main/java/org/apache/directory/server/xdbm/search/ jdbm-store/src/main/java/org/apache/directory/server/core/...
Date Tue, 13 May 2008 21:28:48 GMT
Author: akarasulu
Date: Tue May 13 14:28:47 2008
New Revision: 656019

URL: http://svn.apache.org/viewvc?rev=656019&view=rev
Log:
refining cursors in xdbm search ...

 o added new TupleCursor and IndexCursor interfaces which extend the Cursor
   interface specifically for Tuple and IndexEntry elements but introduces 
   specific positioning methods that make it so we do not have to use an 
   unnecessary Tuple() or IndexEntry() object creation
 o fixed NestedFilterTest to compile and need to fix all the tests there in
   everything breaks because of flaws with generics basis to search classes
 o converted most xdbm-search Cursors to implement IndexCursor
 o fixed CursorBuilder and EvaluatorBuilder interfaces
 o added abstract versions of IndexCursor and TupleCursor
 o fixed tests broken by changes 
 o renamed IndexCursor class to IndexCursorAdapter which adapts TupleCursors to
   IndexCursors - this was done so we can use IndexCursor for the name of the 
   new interface
 o fixed Index cursor creations methods to return IndexCursors instead of simple
   simple cursors
 o modified SearchEngine interface to return IndexCursors


Added:
    directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java
    directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractTupleCursor.java
    directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/IndexCursor.java
    directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/TupleCursor.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java
      - copied, changed from r655574, directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursor.java
Removed:
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursor.java
Modified:
    directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java
    directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsCursor.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleBTreeCursor.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java
    directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
    directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
    directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
    directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
    directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java

Added: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java?rev=656019&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java (added)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractIndexCursor.java Tue May 13 14:28:47 2008
@@ -0,0 +1,65 @@
+/*
+ *  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.xdbm;
+
+
+import org.apache.directory.server.core.cursor.CursorClosedException;
+import org.apache.directory.server.core.cursor.CursorIterator;
+
+import java.util.Iterator;
+
+
+/**
+ * An abstract TupleCursor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public abstract class AbstractIndexCursor<K, E> implements IndexCursor<K, E>
+{
+    private boolean closed;
+
+
+    protected void checkClosed( String operation ) throws CursorClosedException
+    {
+        if ( isClosed() )
+        {
+            throw new CursorClosedException( "Attempting " + operation + " operation on a closed Cursor." );
+        }
+    }
+
+
+    public boolean isClosed()
+    {
+        return closed;
+    }
+
+
+    public void close() throws Exception
+    {
+        closed = true;
+    }
+
+
+    public Iterator<IndexEntry<K, E>> iterator()
+    {
+        return new CursorIterator<IndexEntry<K, E>>( this );
+    }
+}
\ No newline at end of file

Added: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractTupleCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractTupleCursor.java?rev=656019&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractTupleCursor.java (added)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/AbstractTupleCursor.java Tue May 13 14:28:47 2008
@@ -0,0 +1,65 @@
+/*
+ *  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.xdbm;
+
+
+import org.apache.directory.server.core.cursor.CursorClosedException;
+import org.apache.directory.server.core.cursor.CursorIterator;
+
+import java.util.Iterator;
+
+
+/**
+ * An abstract TupleCursor.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $$Rev$$
+ */
+public abstract class AbstractTupleCursor<K,V> implements TupleCursor<K,V>
+{
+    private boolean closed;
+
+
+    protected void checkClosed( String operation ) throws CursorClosedException
+    {
+        if ( isClosed() )
+        {
+            throw new CursorClosedException( "Attempting " + operation + " operation on a closed Cursor." );
+        }
+    }
+
+
+    public boolean isClosed()
+    {
+        return closed;
+    }
+
+
+    public void close() throws Exception
+    {
+        closed = true;
+    }
+
+
+    public Iterator<Tuple<K,V>> iterator()
+    {
+        return new CursorIterator<Tuple<K,V>>( this );
+    }
+}

Modified: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java (original)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Index.java Tue May 13 14:28:47 2008
@@ -174,16 +174,16 @@
     void drop( K attrVal, Long id ) throws Exception;
 
 
-    Cursor<IndexEntry<K, O>> reverseCursor() throws Exception;
+    IndexCursor<K, O> reverseCursor() throws Exception;
 
 
-    Cursor<IndexEntry<K, O>> forwardCursor() throws Exception;
+    IndexCursor<K, O> forwardCursor() throws Exception;
 
 
-    Cursor<IndexEntry<K, O>> reverseCursor( Long id ) throws Exception;
+    IndexCursor<K, O> reverseCursor( Long id ) throws Exception;
 
 
-    Cursor<IndexEntry<K, O>> forwardCursor( K key ) throws Exception;
+    IndexCursor<K, O> forwardCursor( K key ) throws Exception;
 
 
     Cursor<K> reverseValueCursor( Long id ) throws Exception;

Added: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/IndexCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/IndexCursor.java?rev=656019&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/IndexCursor.java (added)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/IndexCursor.java Tue May 13 14:28:47 2008
@@ -0,0 +1,59 @@
+/*
+ *  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.xdbm;
+
+
+import org.apache.directory.server.core.cursor.Cursor;
+
+
+/**
+ * A Cursor introducing new advance methods designed to reduce some
+ * inefficiencies encountered when scanning over Tuples.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface IndexCursor<V,E> extends Cursor<IndexEntry<V,E>>
+{
+    /**
+     * An alternative to calling before(IndexEntry) which often may require
+     * wrapping an id and value in a newly created IndexEntry object that may
+     * be an unnecessary object creation.  Some implementations may not
+     * support this operation and may throw an UnsupportedOperationEception.
+     *
+     * @param id the Long id for the entry
+     * @param indexValue the value to advance just before
+     * @throws Exception if there are faults peforming this operation
+     */
+    void beforeValue( Long id, V indexValue ) throws Exception;
+
+
+    /**
+     * An alternative to calling after(IndexEntry) which often may require
+     * wrapping an id and value in a newly created IndexEntry object that may
+     * be an unnecessary object creation.  Some implementations may not
+     * support this operation and may throw an UnsupportedOperationEception.
+     *
+     * @param id the Long id for the entry
+     * @param indexValue the value to advance just after the last value
+     * @throws Exception if there are faults peforming this operation
+     */
+    void afterValue( Long id, V indexValue ) throws Exception;
+}
\ No newline at end of file

Added: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/TupleCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/TupleCursor.java?rev=656019&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/TupleCursor.java (added)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/TupleCursor.java Tue May 13 14:28:47 2008
@@ -0,0 +1,90 @@
+/*
+ *  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.xdbm;
+
+
+import org.apache.directory.server.core.cursor.Cursor;
+
+
+/**
+ * A Cursor introducing new advance methods designed to reduce some
+ * inefficiencies encountered when scanning over Tuples.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $$Rev$$
+ */
+public interface TupleCursor<K,V> extends Cursor<Tuple<K,V>>
+{
+    /**
+     * An alternative to calling before(Tuple) which often may require
+     * wrapping a key in a newly created Tuple object that may be unnecessary.
+     * This method behaves just like before(Tuple) except it advances to just
+     * before the first value of the key.
+     *
+     * @param key the key to advance just before
+     * @throws Exception if there are faults peforming this operation
+     */
+    void beforeKey( K key ) throws Exception;
+
+
+    /**
+     * An alternative to calling after(Tuple) which often may require
+     * wrapping a key in a newly created Tuple object that may be unnecessary.
+     * This method behaves just like after(Tuple) except it advances to just
+     * after the last value of the key.
+     *
+     * @param key the key to advance just after the last value
+     * @throws Exception if there are faults peforming this operation
+     */
+    void afterKey( K key ) throws Exception;
+
+
+    /**
+     * An alternative to calling before(Tuple) which often may require
+     * wrapping a key and a value in a newly created Tuple object that may be
+     * unnecessary.  This method behaves just like before(Tuple) except it
+     * advances to just before the value of the key which may still be of the
+     * same key.  This method will not be supported if duplicate keys are not
+     * supported.  In this case an UnsupportedOperationException will be
+     * thrown.
+     *
+     * @param key the key of the value to advance just before
+     * @param value the value to advance just before
+     * @throws UnsupportedOperationException if duplicate keys not supporrted
+     * @throws Exception if there are faults peforming this operation
+     */
+    void beforeValue( K key, V value ) throws Exception;
+
+
+    /**
+     * An alternative to calling after(Tuple) which often may require
+     * wrapping a key and a value in a newly created Tuple object that may be
+     * unnecessary.  This method behaves just like after(Tuple) except it
+     * advances to just after the value with the specified key.  This method
+     * will not be supported if duplicate keys are not supported.  In this
+     * case an UnsupportedOperationException will be thrown.
+     *
+     * @param key the key of the value to advance just after
+     * @param value the value to advance just after
+     * @throws UnsupportedOperationException if duplicate keys not supporrted
+     * @throws Exception if there are faults peforming this operation
+     */
+    void afterValue( K key, V value ) throws Exception;
+}

Modified: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java (original)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/search/SearchEngine.java Tue May 13 14:28:47 2008
@@ -25,6 +25,7 @@
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.ServerEntry;
 
@@ -85,10 +86,10 @@
      * @return enumeration over SearchResults
      * @throws Exception if the search fails
      */
-    Cursor<IndexEntry<?,E>> cursor( LdapDN base,
-                                    AliasDerefMode aliasDerefMode,
-                                    ExprNode filter,
-                                    SearchControls searchCtls ) throws Exception;
+    IndexCursor<?,E> cursor( LdapDN base,
+                             AliasDerefMode aliasDerefMode,
+                             ExprNode filter,
+                             SearchControls searchCtls ) throws Exception;
 
 
     /**

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursor.java Tue May 13 14:28:47 2008
@@ -21,8 +21,8 @@
 
 
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
-import org.apache.directory.server.core.cursor.AbstractCursor;
 import org.apache.directory.server.xdbm.Tuple;
+import org.apache.directory.server.xdbm.AbstractTupleCursor;
 import jdbm.helper.TupleBrowser;
 
 import java.io.IOException;
@@ -35,7 +35,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $$Rev$$
  */
-public class DupsContainerCursor<K,V> extends AbstractCursor<Tuple<K, DupsContainer<V>>>
+public class DupsContainerCursor<K,V> extends AbstractTupleCursor<K, DupsContainer<V>>
 {
     private final JdbmTable<K,V> table;
 
@@ -80,23 +80,17 @@
     }
 
 
-    /**
-     * Positions this Cursor before the key of the supplied tuple.
-     *
-     * @param element the tuple who's key is used to position this Cursor
-     * @throws IOException if there are failures to position the Cursor
-     */
-    public void before( Tuple<K,DupsContainer<V>> element ) throws IOException
+    public void beforeKey( K key ) throws Exception
     {
-        browser = table.getBTree().browse( element.getKey() );
+        browser = table.getBTree().browse( key );
         forwardDirection = null;
         clearValue();
     }
 
 
-    public void after( Tuple<K,DupsContainer<V>> element ) throws IOException
+    public void afterKey( K key ) throws Exception
     {
-        browser = table.getBTree().browse( element.getKey() );
+        browser = table.getBTree().browse( key );
         forwardDirection = null;
 
         /*
@@ -111,7 +105,7 @@
             //noinspection unchecked
             K next = ( K ) jdbmTuple.getKey();
 
-            int nextCompared = table.getKeyComparator().compare( next, element.getKey() );
+            int nextCompared = table.getKeyComparator().compare( next, key );
 
             if ( nextCompared > 0 )
             {
@@ -131,6 +125,38 @@
     }
 
 
+    @SuppressWarnings( { "UnusedDeclaration" } )
+    public void beforeValue( K key, DupsContainer<V> value ) throws Exception
+    {
+        throw new UnsupportedOperationException( "Value based advances not supported." );
+    }
+
+
+    @SuppressWarnings( { "UnusedDeclaration" } )
+    public void afterValue( K key, DupsContainer<V> value ) throws Exception
+    {
+        throw new UnsupportedOperationException( "Value based advances not supported." );
+    }
+
+
+    /**
+     * Positions this Cursor before the key of the supplied tuple.
+     *
+     * @param element the tuple who's key is used to position this Cursor
+     * @throws IOException if there are failures to position the Cursor
+     */
+    public void before( Tuple<K,DupsContainer<V>> element ) throws Exception
+    {
+        beforeKey( element.getKey() );
+    }
+
+
+    public void after( Tuple<K,DupsContainer<V>> element ) throws Exception
+    {
+        afterKey( element.getKey() );
+    }
+
+
     public void beforeFirst() throws IOException
     {
         browser = table.getBTree().browse();

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsCursor.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsCursor.java Tue May 13 14:28:47 2008
@@ -5,10 +5,10 @@
 
 import org.apache.directory.server.core.avltree.AvlTree;
 import org.apache.directory.server.core.avltree.AvlTreeCursor;
-import org.apache.directory.server.core.cursor.AbstractCursor;
 import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.xdbm.Tuple;
+import org.apache.directory.server.xdbm.AbstractTupleCursor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -19,7 +19,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-class DupsCursor<K,V> extends AbstractCursor<Tuple<K,V>>
+class DupsCursor<K,V> extends AbstractTupleCursor<K,V>
 {
     private static final Logger LOG = LoggerFactory.getLogger( DupsCursor.class.getSimpleName() );
     
@@ -77,10 +77,16 @@
     }
 
 
-    public void before( Tuple<K,V> element ) throws Exception
+    public void beforeKey( K key ) throws Exception
+    {
+        beforeValue( key, null );
+    }
+
+
+    public void beforeValue( K key, V value ) throws Exception
     {
-        containerCursor.before( new Tuple<K,DupsContainer<V>>( element.getKey(), null ) );
-        
+        containerCursor.before( new Tuple<K,DupsContainer<V>>( key, null ) );
+
         if ( containerCursor.next() )
         {
             containerTuple.setBoth( containerCursor.get() );
@@ -97,15 +103,15 @@
                 dupsCursor = new KeyBTreeCursor<V>( tree, table.getValueComparator() );
             }
 
-            if ( element.getValue() == null )
+            if ( value == null )
             {
                 return;
             }
 
             // advance the dupsCursor only if we're on same key
-            if ( table.getKeyComparator().compare( containerTuple.getKey(), element.getKey() ) == 0 )
+            if ( table.getKeyComparator().compare( containerTuple.getKey(), key ) == 0 )
             {
-                dupsCursor.before( element.getValue() );
+                dupsCursor.before( value );
             }
 
             return;
@@ -117,7 +123,13 @@
     }
 
 
-    public void after( Tuple<K,V> element ) throws Exception
+    public void afterKey( K key ) throws Exception
+    {
+        afterValue( key, null );
+    }
+
+
+    public void afterValue( K key, V value ) throws Exception
     {
         /*
          * There is a subtle difference between after and before handling
@@ -140,13 +152,13 @@
          * go right before this key instead of after it.
          */
 
-        if ( element.getValue() == null )
+        if ( value == null )
         {
-            containerCursor.after( new Tuple<K,DupsContainer<V>>( element.getKey(), null ) );
+            containerCursor.after( new Tuple<K,DupsContainer<V>>( key, null ) );
         }
         else
         {
-            containerCursor.before( new Tuple<K,DupsContainer<V>>( element.getKey(), null ) );
+            containerCursor.before( new Tuple<K,DupsContainer<V>>( key, null ) );
         }
 
         if ( containerCursor.next() )
@@ -165,15 +177,15 @@
                 dupsCursor = new KeyBTreeCursor<V>( tree, table.getValueComparator() );
             }
 
-            if ( element.getValue() == null )
+            if ( value == null )
             {
                 return;
             }
 
             // only advance the dupsCursor if we're on same key
-            if ( table.getKeyComparator().compare( containerTuple.getKey(), element.getKey() ) == 0 )
+            if ( table.getKeyComparator().compare( containerTuple.getKey(), key ) == 0 )
             {
-                dupsCursor.after( element.getValue() );
+                dupsCursor.after( value );
             }
 
             return;
@@ -185,6 +197,18 @@
     }
 
 
+    public void before( Tuple<K,V> element ) throws Exception
+    {
+        beforeValue( element.getKey(), element.getValue() );
+    }
+
+
+    public void after( Tuple<K,V> element ) throws Exception
+    {
+        afterValue( element.getKey(), element.getValue() );
+    }
+
+
     public void beforeFirst() throws Exception
     {
         clearValue();

Copied: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java (from r655574, directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursor.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java?p2=directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java&p1=directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursor.java&r1=655574&r2=656019&rev=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursor.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/IndexCursorAdaptor.java Tue May 13 14:28:47 2008
@@ -34,9 +34,9 @@
  * IndexEntry objects rather than tuples.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $$Rev$$
+ * @version $Rev$
  */
-public class IndexCursor<K,O> implements Cursor<IndexEntry<K,O>>
+public class IndexCursorAdaptor<K,O> implements IndexCursor<K,O>
 {
     final Cursor<Tuple> wrappedCursor;
     final ForwardIndexEntry<K, O> forwardEntry;
@@ -44,14 +44,14 @@
 
 
     /**
-     * Creates an IndexCursor which wraps and adapts a Cursor from a table to
+     * Creates an IndexCursorAdaptor which wraps and adapts a Cursor from a table to
      * one which returns an IndexEntry.
      *
      * @param wrappedCursor the Cursor being adapted
      * @param forwardIndex true for a cursor over a forward index, false for
      * one over a reverse index
      */
-    public IndexCursor( Cursor<Tuple> wrappedCursor, boolean forwardIndex )
+    public IndexCursorAdaptor( Cursor<Tuple> wrappedCursor, boolean forwardIndex )
     {
         this.wrappedCursor = wrappedCursor;
         if ( forwardIndex )
@@ -73,6 +73,20 @@
     }
 
 
+    public void beforeValue( Long id, K key ) throws Exception
+    {
+        //noinspection unchecked
+        ( ( TupleCursor ) wrappedCursor ).beforeKey( key );
+    }
+
+
+    public void afterValue( Long id, K key ) throws Exception
+    {
+        //noinspection unchecked
+        ( ( TupleCursor ) wrappedCursor ).afterKey( key );
+    }
+
+
     public void before( IndexEntry<K, O> element ) throws Exception
     {
         wrappedCursor.before( element.getTuple() );

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Tue May 13 14:28:47 2008
@@ -28,8 +28,8 @@
 import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.schema.SerializableComparator;
 import org.apache.directory.server.xdbm.Index;
-import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Tuple;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.SynchronizedLRUMap;
 
@@ -459,31 +459,31 @@
     // ------------------------------------------------------------------------
 
 
-    public Cursor<IndexEntry<K, O>> reverseCursor() throws Exception
+    public IndexCursor<K, O> reverseCursor() throws Exception
     {
         //noinspection unchecked
-        return new IndexCursor<K, O>( ( Cursor ) reverse.cursor(), false );
+        return new IndexCursorAdaptor<K, O>( ( Cursor ) reverse.cursor(), false );
     }
 
 
-    public Cursor<IndexEntry<K, O>> forwardCursor() throws Exception
+    public IndexCursor<K, O> forwardCursor() throws Exception
     {
         //noinspection unchecked
-        return new IndexCursor<K, O>( ( Cursor ) forward.cursor(), true );
+        return new IndexCursorAdaptor<K, O>( ( Cursor ) forward.cursor(), true );
     }
 
 
-    public Cursor<IndexEntry<K, O>> reverseCursor( Long id ) throws Exception
+    public IndexCursor<K, O> reverseCursor( Long id ) throws Exception
     {
         //noinspection unchecked
-        return new IndexCursor<K, O>( ( Cursor ) reverse.cursor( id ), false );
+        return new IndexCursorAdaptor<K, O>( ( Cursor ) reverse.cursor( id ), false );
     }
 
 
-    public Cursor<IndexEntry<K, O>> forwardCursor( K key ) throws Exception
+    public IndexCursor<K, O> forwardCursor( K key ) throws Exception
     {
         //noinspection unchecked
-        return new IndexCursor<K, O>( ( Cursor ) forward.cursor( key ), true );
+        return new IndexCursorAdaptor<K, O>( ( Cursor ) forward.cursor( key ), true );
     }
 
 

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleAvlCursor.java Tue May 13 14:28:47 2008
@@ -19,9 +19,9 @@
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
 
-import org.apache.directory.server.core.cursor.AbstractCursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.xdbm.Tuple;
+import org.apache.directory.server.xdbm.AbstractTupleCursor;
 import org.apache.directory.server.core.avltree.AvlTree;
 import org.apache.directory.server.core.avltree.AvlTreeCursor;
 
@@ -34,7 +34,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class KeyTupleAvlCursor<K,V> extends AbstractCursor<Tuple<K,V>>
+public class KeyTupleAvlCursor<K,V> extends AbstractTupleCursor<K,V>
 {
     private final AvlTreeCursor<V> wrapped;
     private final K key;
@@ -70,6 +70,42 @@
     }
 
 
+    public void beforeKey( K key ) throws Exception
+    {
+        throw new UnsupportedOperationException( "This cursor locks down the key so keywise advances are not allowed." );
+    }
+
+
+    public void afterKey( K key ) throws Exception
+    {
+        throw new UnsupportedOperationException( "This cursor locks down the key so keywise advances are not allowed." );
+    }
+
+
+    public void beforeValue( K key, V value ) throws Exception
+    {
+        if ( key != null && ! key.equals( this.key ) )
+        {
+            throw new UnsupportedOperationException( "This cursor locks down the key so keywise advances are not allowed." );
+        }
+
+        wrapped.before( value );
+        clearValue();
+    }
+
+
+    public void afterValue( K key, V value ) throws Exception
+    {
+        if ( key != null && ! key.equals( this.key ) )
+        {
+            throw new UnsupportedOperationException( "This cursor locks down the key so keywise advances are not allowed." );
+        }
+
+        wrapped.after( value );
+        clearValue();
+    }
+
+
     /**
      * Positions this Cursor over the same keys before the value of the
      * supplied element Tuple.  The supplied element Tuple's key is not

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleBTreeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleBTreeCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleBTreeCursor.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/KeyTupleBTreeCursor.java Tue May 13 14:28:47 2008
@@ -19,9 +19,9 @@
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
 
-import org.apache.directory.server.core.cursor.AbstractCursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.xdbm.Tuple;
+import org.apache.directory.server.xdbm.AbstractTupleCursor;
 
 import java.util.Comparator;
 
@@ -37,7 +37,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class KeyTupleBTreeCursor<K,V> extends AbstractCursor<Tuple<K,V>>
+public class KeyTupleBTreeCursor<K,V> extends AbstractTupleCursor<K,V>
 {
     private final Comparator<V> comparator;
     private final BTree btree;
@@ -80,24 +80,38 @@
     }
 
 
-    /**
-     * Positions this Cursor over the same keys before the value of the
-     * supplied valueTuple.  The supplied element Tuple's key is not considered at
-     * all.
-     *
-     * @param element the valueTuple who's value is used to position this Cursor
-     * @throws Exception if there are failures to position the Cursor
-     */
-    public void before( Tuple<K,V> element ) throws Exception
+    public void beforeKey( K key ) throws Exception
     {
-        browser = btree.browse( element.getValue() );
+        throw new UnsupportedOperationException( "This cursor locks down the key so keywise advances are not allowed." );
+    }
+
+
+    public void afterKey( K key ) throws Exception
+    {
+        throw new UnsupportedOperationException( "This cursor locks down the key so keywise advances are not allowed." );
+    }
+
+
+    public void beforeValue( K key, V value ) throws Exception
+    {
+        if ( key != null && ! key.equals( this.key ) )
+        {
+            throw new UnsupportedOperationException( "This cursor locks down the key so keywise advances are not allowed." );
+        }
+
+        browser = btree.browse( value );
         clearValue();
     }
 
 
-    public void after( Tuple<K,V> element ) throws Exception
+    public void afterValue( K key, V value ) throws Exception
     {
-        browser = btree.browse( element.getValue() );
+        if ( key != null && ! key.equals( this.key ) )
+        {
+            throw new UnsupportedOperationException( "This cursor locks down the key so keywise advances are not allowed." );
+        }
+
+        browser = btree.browse( value );
 
         /*
          * While the next value is less than or equal to the element keep
@@ -112,7 +126,7 @@
             V next = ( V ) valueTuple.getKey();
 
             //noinspection unchecked
-            int nextCompared = comparator.compare( next, element.getValue() );
+            int nextCompared = comparator.compare( next, value );
 
             if ( nextCompared <= 0 )
             {
@@ -131,7 +145,7 @@
                 }
                 else
                 {
-                    browser = btree.browse( element.getKey() );
+                    browser = btree.browse( this.key );
                 }
 
                 clearValue();
@@ -140,7 +154,27 @@
         }
 
         clearValue();
-        // just return
+    }
+
+
+    /**
+     * Positions this Cursor over the same keys before the value of the
+     * supplied valueTuple.  The supplied element Tuple's key is not considered at
+     * all.
+     *
+     * @param element the valueTuple who's value is used to position this Cursor
+     * @throws Exception if there are failures to position the Cursor
+     */
+    public void before( Tuple<K,V> element ) throws Exception
+    {
+        browser = btree.browse( element.getValue() );
+        clearValue();
+    }
+
+
+    public void after( Tuple<K,V> element ) throws Exception
+    {
+        afterValue( key, element.getValue() );
     }
 
 
@@ -176,12 +210,14 @@
         if ( browser.getPrevious( valueTuple ) )
         {
             // work around to fix direction change problem with jdbm browser
+            //noinspection unchecked
             if ( returnedTuple.getValue() != null &&
                 comparator.compare( ( V ) valueTuple.getKey(), returnedTuple.getValue() ) == 0 )
             {
                 browser.getPrevious( valueTuple ) ;
             }
             returnedTuple.setKey( key );
+            //noinspection unchecked
             returnedTuple.setValue( ( V ) valueTuple.getKey() );
             return valueAvailable = true;
         }
@@ -198,12 +234,14 @@
         if ( browser.getNext( valueTuple ) )
         {
             // work around to fix direction change problem with jdbm browser
+            //noinspection unchecked
             if ( returnedTuple.getValue() != null &&
                  comparator.compare( ( V ) valueTuple.getKey(), returnedTuple.getValue() ) == 0 )
             {
                 browser.getNext( valueTuple ) ;
             }
             returnedTuple.setKey( key );
+            //noinspection unchecked
             returnedTuple.setValue( ( V ) valueTuple.getKey() );
             return valueAvailable = true;
         }

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/NoDupsCursor.java Tue May 13 14:28:47 2008
@@ -22,6 +22,7 @@
 import org.apache.directory.server.core.cursor.AbstractCursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.xdbm.Tuple;
+import org.apache.directory.server.xdbm.AbstractTupleCursor;
 
 import java.io.IOException;
 
@@ -37,7 +38,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-class NoDupsCursor<K,V> extends AbstractCursor<Tuple<K,V>>
+class NoDupsCursor<K,V> extends AbstractTupleCursor<K,V>
 {
     private final JdbmTable<K,V> table;
 
@@ -75,22 +76,16 @@
     }
 
 
-    /**
-     * Positions this Cursor before the key of the supplied tuple.
-     *
-     * @param element the tuple who's key is used to position this Cursor
-     * @throws IOException if there are failures to position the Cursor
-     */
-    public void before( Tuple<K,V> element ) throws IOException
+    public void beforeKey( K key ) throws Exception
     {
-        browser = table.getBTree().browse( element.getKey() );
+        browser = table.getBTree().browse( key );
         clearValue();
     }
 
 
-    public void after( Tuple<K,V> element ) throws IOException
+    public void afterKey( K key ) throws Exception
     {
-        browser = table.getBTree().browse( element.getKey() );
+        browser = table.getBTree().browse( key );
 
         /*
          * While the next value is less than or equal to the element keep
@@ -104,7 +99,7 @@
             //noinspection unchecked
             K next = ( K ) jdbmTuple.getKey();
 
-            int nextCompared = table.getKeyComparator().compare( next, element.getKey() );
+            int nextCompared = table.getKeyComparator().compare( next, key );
 
             if ( nextCompared > 0 )
             {
@@ -118,6 +113,36 @@
     }
 
 
+    public void beforeValue( K key, V value ) throws Exception
+    {
+        throw new UnsupportedOperationException( "This Cursor does not support duplicate keys." );
+    }
+
+
+    public void afterValue( K key, V value ) throws Exception
+    {
+        throw new UnsupportedOperationException( "This Cursor does not support duplicate keys." );
+    }
+
+
+    /**
+     * Positions this Cursor before the key of the supplied tuple.
+     *
+     * @param element the tuple who's key is used to position this Cursor
+     * @throws IOException if there are failures to position the Cursor
+     */
+    public void before( Tuple<K,V> element ) throws Exception
+    {
+        beforeKey( element.getKey() );
+    }
+
+
+    public void after( Tuple<K,V> element ) throws Exception
+    {
+        afterKey( element.getKey() );
+    }
+
+
     public void beforeFirst() throws IOException
     {
         browser = table.getBTree().browse();

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Tue May 13 14:28:47 2008
@@ -35,6 +35,7 @@
 import org.apache.directory.server.xdbm.IndexNotFoundException;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Index;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
 import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.ServerEntry;
@@ -479,12 +480,12 @@
 
             public void drop( Object attrVal, Long id ) throws Exception { }
 
-            public Cursor forwardCursor() throws Exception
+            public IndexCursor forwardCursor() throws Exception
             {
                 return null;
             }
 
-            public Cursor forwardCursor( Object key ) throws Exception
+            public IndexCursor forwardCursor( Object key ) throws Exception
             {
                 return null;
             }
@@ -612,12 +613,12 @@
                 return 0;
             }
 
-            public Cursor reverseCursor() throws Exception
+            public IndexCursor reverseCursor() throws Exception
             {
                 return null;
             }
 
-            public Cursor reverseCursor( Long id ) throws Exception
+            public IndexCursor reverseCursor( Long id ) throws Exception
             {
                 return null;
             }

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/AndCursor.java Tue May 13 14:28:47 2008
@@ -21,9 +21,9 @@
 
 
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.AbstractIndexCursor;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.search.Evaluator;
-import org.apache.directory.server.core.cursor.AbstractCursor;
-import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -37,16 +37,16 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class AndCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
+public class AndCursor<V> extends AbstractIndexCursor<V, ServerEntry>
 {
     private static final String UNSUPPORTED_MSG =
         "AndCursors are not ordered and do not support positioning by element.";
-    private final Cursor<IndexEntry<?,ServerEntry>> wrapped;
+    private final IndexCursor<V,ServerEntry> wrapped;
     private final List<Evaluator<? extends ExprNode, ServerEntry>> evaluators;
     private boolean available = false;
 
 
-    public AndCursor( Cursor<IndexEntry<?, ServerEntry>> wrapped,
+    public AndCursor( IndexCursor<V, ServerEntry> wrapped,
                       List<Evaluator<? extends ExprNode, ServerEntry>> evaluators )
     {
         this.wrapped = wrapped;
@@ -60,13 +60,25 @@
     }
 
 
-    public void before( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void beforeValue( Long id, V value )
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void after( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void afterValue( Long id, V value )
+    {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+
+    public void before( IndexEntry<V, ServerEntry> element ) throws Exception
+    {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+
+    public void after( IndexEntry<V, ServerEntry> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
@@ -130,7 +142,7 @@
     }
 
 
-    public IndexEntry<?, ServerEntry> get() throws Exception
+    public IndexEntry<V, ServerEntry> get() throws Exception
     {
         if ( available )
         {

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateCursor.java Tue May 13 14:28:47 2008
@@ -22,8 +22,8 @@
 
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
-import org.apache.directory.server.core.cursor.AbstractCursor;
-import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.xdbm.AbstractIndexCursor;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.core.entry.ServerEntry;
 
@@ -40,7 +40,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $$Rev$$
  */
-public class ApproximateCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
+public class ApproximateCursor<V> extends AbstractIndexCursor<V, ServerEntry>
 {
     private static final String UNSUPPORTED_MSG =
         "ApproximateCursors only support positioning by element when a user index exists on the asserted attribute.";
@@ -49,10 +49,10 @@
     private final ApproximateEvaluator approximateEvaluator;
 
     /** Cursor over attribute entry matching filter: set when index present */
-    private final Cursor<IndexEntry<?,ServerEntry>> userIdxCursor;
+    private final IndexCursor<V,ServerEntry> userIdxCursor;
 
     /** NDN Cursor on all entries in  (set when no index on user attribute) */
-    private final Cursor<IndexEntry<String,ServerEntry>> ndnIdxCursor;
+    private final IndexCursor<String,ServerEntry> ndnIdxCursor;
 
     /** used only when ndnIdxCursor is used (no index on attribute) */
     private boolean available = false;
@@ -89,7 +89,33 @@
     }
 
 
-    public void before( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void beforeValue( Long id, V value ) throws Exception
+    {
+        if ( userIdxCursor != null )
+        {
+            userIdxCursor.beforeValue( id, value );
+        }
+        else
+        {
+            throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+        }
+    }
+
+
+    public void afterValue( Long id, V value ) throws Exception
+    {
+        if ( userIdxCursor != null )
+        {
+            userIdxCursor.afterValue( id, value );
+        }
+        else
+        {
+            throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+        }
+    }
+
+
+    public void before( IndexEntry<V, ServerEntry> element ) throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -102,7 +128,7 @@
     }
 
 
-    public void after( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void after( IndexEntry<V, ServerEntry> element ) throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -197,7 +223,7 @@
     }
 
 
-    public IndexEntry<?, ServerEntry> get() throws Exception
+    public IndexEntry<V, ServerEntry> get() throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -206,7 +232,8 @@
 
         if ( available )
         {
-            return ndnIdxCursor.get();
+            //noinspection unchecked
+            return ( IndexEntry<V, ServerEntry> ) ndnIdxCursor.get();
         }
 
         throw new InvalidCursorPositionException( "Cursor has not been positioned yet." );

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java Tue May 13 14:28:47 2008
@@ -25,10 +25,9 @@
 
 import javax.naming.directory.SearchControls;
 
-import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.search.Evaluator;
-import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.filter.*;
@@ -62,7 +61,7 @@
     }
 
 
-    public Cursor<IndexEntry<?,ServerEntry>> build( ExprNode node ) throws Exception
+    public IndexCursor<?,ServerEntry> build( ExprNode node ) throws Exception
     {
         switch ( node.getAssertionType() )
         {
@@ -118,10 +117,10 @@
      * @return Cursor over candidates satisfying disjunction expression
      * @throws Exception on db access failures
      */
-    private Cursor<IndexEntry<?,ServerEntry>> buildOrCursor( OrNode node ) throws Exception
+    private IndexCursor<?,ServerEntry> buildOrCursor( OrNode node ) throws Exception
     {
         List<ExprNode> children = node.getChildren();
-        List<Cursor<IndexEntry<?,ServerEntry>>> childCursors = new ArrayList<Cursor<IndexEntry<?,ServerEntry>>>(children.size());
+        List<IndexCursor<?,ServerEntry>> childCursors = new ArrayList<IndexCursor<?,ServerEntry>>( children.size() );
         List<Evaluator<? extends ExprNode, ServerEntry>> childEvaluators
             = new ArrayList<Evaluator<? extends ExprNode, ServerEntry>>( children.size() );
 
@@ -144,7 +143,7 @@
      * @return Cursor over the conjunction expression
      * @throws Exception on db access failures
      */
-    private Cursor<IndexEntry<?,ServerEntry>> buildAndCursor( AndNode node ) throws Exception
+    private IndexCursor<?,ServerEntry> buildAndCursor( AndNode node ) throws Exception
     {
         int minIndex = 0;
         long minValue = Long.MAX_VALUE;
@@ -190,7 +189,7 @@
         }
 
         // Do recursive call to build min child Cursor then create AndCursor
-        Cursor<IndexEntry<?,ServerEntry>> childCursor = build( minChild );
+        IndexCursor<?,ServerEntry> childCursor = build( minChild );
         return new AndCursor( childCursor, childEvaluators );
     }
 }

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java Tue May 13 14:28:47 2008
@@ -32,7 +32,6 @@
 import org.apache.directory.server.xdbm.search.Optimizer;
 import org.apache.directory.server.xdbm.search.SearchEngine;
 import org.apache.directory.server.xdbm.search.Evaluator;
-import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.ServerEntry;
 
 
@@ -92,7 +91,7 @@
     /**
      * @see SearchEngine#cursor(LdapDN, AliasDerefMode, ExprNode, SearchControls)
      */
-    public Cursor<IndexEntry<?,ServerEntry>> cursor( LdapDN base, AliasDerefMode aliasDerefMode, ExprNode filter,
+    public IndexCursor<?,ServerEntry> cursor( LdapDN base, AliasDerefMode aliasDerefMode, ExprNode filter,
                                                      SearchControls searchCtls ) throws Exception
     {
         LdapDN effectiveBase;

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityCursor.java Tue May 13 14:28:47 2008
@@ -22,8 +22,8 @@
 
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
-import org.apache.directory.server.core.cursor.AbstractCursor;
-import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.xdbm.AbstractIndexCursor;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.core.entry.ServerEntry;
 
@@ -38,7 +38,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $$Rev$$
  */
-public class EqualityCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
+public class EqualityCursor<V> extends AbstractIndexCursor<V, ServerEntry>
 {
     private static final String UNSUPPORTED_MSG =
         "EqualityCursors only support positioning by element when a user index exists on the asserted attribute.";
@@ -47,10 +47,10 @@
     private final EqualityEvaluator equalityEvaluator;
 
     /** Cursor over attribute entry matching filter: set when index present */
-    private final Cursor<IndexEntry<?,ServerEntry>> userIdxCursor;
+    private final IndexCursor<V,ServerEntry> userIdxCursor;
 
     /** NDN Cursor on all entries in  (set when no index on user attribute) */
-    private final Cursor<IndexEntry<String,ServerEntry>> ndnIdxCursor;
+    private final IndexCursor<String,ServerEntry> ndnIdxCursor;
 
     /** used only when ndnIdxCursor is used (no index on attribute) */
     private boolean available = false;
@@ -87,7 +87,20 @@
     }
 
 
-    public void before( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void beforeValue( Long id, V value ) throws Exception
+    {
+        if ( userIdxCursor != null )
+        {
+            userIdxCursor.beforeValue( id, value );
+        }
+        else
+        {
+            throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+        }
+    }
+
+
+    public void before( IndexEntry<V, ServerEntry> element ) throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -100,7 +113,20 @@
     }
 
 
-    public void after( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void afterValue( Long id, V key ) throws Exception
+    {
+        if ( userIdxCursor != null )
+        {
+            userIdxCursor.afterValue( id, key );
+        }
+        else
+        {
+            throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+        }
+    }
+
+
+    public void after( IndexEntry<V, ServerEntry> element ) throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -195,7 +221,7 @@
     }
 
 
-    public IndexEntry<?, ServerEntry> get() throws Exception
+    public IndexEntry<V, ServerEntry> get() throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -204,7 +230,8 @@
 
         if ( available )
         {
-            return ndnIdxCursor.get();
+            //noinspection unchecked
+            return ( IndexEntry<V, ServerEntry> )ndnIdxCursor.get();
         }
 
         throw new InvalidCursorPositionException( "Cursor has not been positioned yet." );

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqCursor.java Tue May 13 14:28:47 2008
@@ -20,11 +20,7 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import org.apache.directory.server.xdbm.IndexEntry;
-import org.apache.directory.server.xdbm.Store;
-import org.apache.directory.server.xdbm.ForwardIndexEntry;
-import org.apache.directory.server.core.cursor.AbstractCursor;
-import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.xdbm.*;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.core.entry.ServerEntry;
 
@@ -37,9 +33,9 @@
  * of these cases where the other remains null.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $$Rev$$
+ * @version $Rev$
  */
-public class GreaterEqCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
+public class GreaterEqCursor<V> extends AbstractIndexCursor<V, ServerEntry>
 {
     private static final String UNSUPPORTED_MSG =
         "GreaterEqCursors only support positioning by element when a user index exists on the asserted attribute.";
@@ -48,10 +44,10 @@
     private final GreaterEqEvaluator greaterEqEvaluator;
 
     /** Cursor over attribute entry matching filter: set when index present */
-    private final Cursor<IndexEntry<?,ServerEntry>> userIdxCursor;
+    private final IndexCursor<V,ServerEntry> userIdxCursor;
 
     /** NDN Cursor on all entries in  (set when no index on user attribute) */
-    private final Cursor<IndexEntry<String,ServerEntry>> ndnIdxCursor;
+    private final IndexCursor<String,ServerEntry> ndnIdxCursor;
 
     /**
      * Used to store indexEntry from ndnCandidate so it can be saved after
@@ -89,7 +85,7 @@
     }
 
 
-    public void before( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void beforeValue( Long id, V value ) throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -98,7 +94,76 @@
              * bounds as mandated by the assertion node.  To do so we compare
              * it's value with the value of the node.  If it is smaller or
              * equal to this lower bound then we simply position the
-             * userIdxCursor before the first node.  Otherwise we let the
+             * userIdxCursor before the first element.  Otherwise we let the
+             * underlying userIdx Cursor position the element.
+             */
+            //noinspection unchecked
+            if ( greaterEqEvaluator.getComparator().compare( value,
+                 greaterEqEvaluator.getExpression().getValue().get() ) <= 0 )
+            {
+                beforeFirst();
+                return;
+            }
+
+            userIdxCursor.beforeValue( id, value );
+            available = false;
+        }
+        else
+        {
+            throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+        }
+    }
+
+
+    public void afterValue( Long id, V value ) throws Exception
+    {
+        if ( userIdxCursor != null )
+        {
+            //noinspection unchecked
+            int comparedValue = greaterEqEvaluator.getComparator().compare( value,
+                 greaterEqEvaluator.getExpression().getValue().get() );
+
+            /*
+             * First we need to check and make sure this element is within
+             * bounds as mandated by the assertion node.  To do so we compare
+             * it's value with the value of the node.  If it is equal to this
+             * lower bound then we simply position the userIdxCursor after
+             * this first node.  If it is less than this value then we
+             * position the Cursor before the first entry.
+             */
+            if ( comparedValue == 0 )
+            {
+                userIdxCursor.afterValue( id, value );
+                available = false;
+                return;
+            }
+            else if ( comparedValue < 0 )
+            {
+                beforeFirst();
+                return;
+            }
+
+            // Element is in the valid range as specified by assertion
+            userIdxCursor.afterValue( id, value );
+            available = false;
+        }
+        else
+        {
+            throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+        }
+    }
+
+
+    public void before( IndexEntry<V, ServerEntry> element ) throws Exception
+    {
+        if ( userIdxCursor != null )
+        {
+            /*
+             * First we need to check and make sure this element is within
+             * bounds as mandated by the assertion node.  To do so we compare
+             * it's value with the value of the node.  If it is smaller or
+             * equal to this lower bound then we simply position the
+             * userIdxCursor before the first element.  Otherwise we let the
              * underlying userIdx Cursor position the element.
              */
             //noinspection unchecked
@@ -119,7 +184,7 @@
     }
 
 
-    public void after( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void after( IndexEntry<V, ServerEntry> element ) throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -162,8 +227,9 @@
     {
         if ( userIdxCursor != null )
         {
-            IndexEntry<Object,ServerEntry> advanceTo = new ForwardIndexEntry<Object,ServerEntry>();
-            advanceTo.setValue( greaterEqEvaluator.getExpression().getValue().get() );
+            IndexEntry<V,ServerEntry> advanceTo = new ForwardIndexEntry<V,ServerEntry>();
+            //noinspection unchecked
+            advanceTo.setValue( ( V ) greaterEqEvaluator.getExpression().getValue().get() );
             userIdxCursor.before( advanceTo );
         }
         else
@@ -264,7 +330,7 @@
     }
 
 
-    public IndexEntry<?, ServerEntry> get() throws Exception
+    public IndexEntry<V, ServerEntry> get() throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -278,7 +344,8 @@
 
         if ( available )
         {
-            return ndnCandidate;
+            //noinspection unchecked
+            return ( IndexEntry<V, ServerEntry> ) ndnCandidate;
         }
 
         throw new InvalidCursorPositionException( "Cursor has not been positioned yet." );

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqCursor.java Tue May 13 14:28:47 2008
@@ -20,11 +20,7 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import org.apache.directory.server.xdbm.IndexEntry;
-import org.apache.directory.server.xdbm.Store;
-import org.apache.directory.server.xdbm.ForwardIndexEntry;
-import org.apache.directory.server.core.cursor.AbstractCursor;
-import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.xdbm.*;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.core.entry.ServerEntry;
 
@@ -39,7 +35,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $$Rev$$
  */
-public class LessEqCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
+public class LessEqCursor<V> extends AbstractIndexCursor<V, ServerEntry>
 {
     private static final String UNSUPPORTED_MSG =
         "LessEqCursors only support positioning by element when a user index exists on the asserted attribute.";
@@ -48,17 +44,17 @@
     private final LessEqEvaluator lessEqEvaluator;
 
     /** Cursor over attribute entry matching filter: set when index present */
-    private final Cursor<IndexEntry<?,ServerEntry>> userIdxCursor;
+    private final IndexCursor<V,ServerEntry> userIdxCursor;
 
     /** NDN Cursor on all entries in  (set when no index on user attribute) */
-    private final Cursor<IndexEntry<String,ServerEntry>> ndnIdxCursor;
+    private final IndexCursor<V,ServerEntry> ndnIdxCursor;
 
     /**
      * Used to store indexEntry from ndnCandidate so it can be saved after
      * call to evaluate() which changes the value so it's not referring to
      * the NDN but to the value of the attribute instead.
      */
-    IndexEntry<String, ServerEntry> ndnCandidate;
+    IndexEntry<V, ServerEntry> ndnCandidate;
 
     /** used in both modes */
     private boolean available = false;
@@ -77,7 +73,8 @@
         }
         else
         {
-            ndnIdxCursor = db.getNdnIndex().forwardCursor();
+            //noinspection unchecked
+            ndnIdxCursor = ( IndexCursor<V,ServerEntry> ) db.getNdnIndex().forwardCursor();
             userIdxCursor = null;
         }
     }
@@ -89,7 +86,51 @@
     }
 
 
-    public void before( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void beforeValue( Long id, V value ) throws Exception
+    {
+        if ( userIdxCursor != null )
+        {
+            /*
+             * First we need to check and make sure this element is within
+             * bounds as mandated by the assertion node.  To do so we compare
+             * it's value with the value of the expression node.  If the
+             * element's value is greater than this upper bound then we
+             * position the userIdxCursor after the last node.
+             *
+             * If the element's value is equal to this upper bound then we
+             * position the userIdxCursor right before the last node.
+             *
+             * If the element's value is smaller, then we delegate to the
+             * before() method of the userIdxCursor.
+             */
+            //noinspection unchecked
+            int compareValue = lessEqEvaluator.getComparator().compare( value,
+                 lessEqEvaluator.getExpression().getValue().get() );
+
+            if ( compareValue > 0 )
+            {
+                afterLast();
+                return;
+            }
+            else if ( compareValue == 0 )
+            {
+                last();
+                previous();
+                available = false;
+                return;
+            }
+
+            userIdxCursor.beforeValue( id, value );
+            available = false;
+        }
+        else
+        {
+            throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+        }
+    }
+
+
+    public void before( IndexEntry<V, ServerEntry> element ) throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -133,7 +174,43 @@
     }
 
 
-    public void after( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void afterValue( Long id, V value ) throws Exception
+    {
+        if ( userIdxCursor != null )
+        {
+            //noinspection unchecked
+            int comparedValue = lessEqEvaluator.getComparator().compare( value,
+                 lessEqEvaluator.getExpression().getValue().get() );
+
+            /*
+             * First we need to check and make sure this element is within
+             * bounds as mandated by the assertion node.  To do so we compare
+             * it's value with the value of the expression node.
+             *
+             * If the element's value is equal to or greater than this upper
+             * bound then we position the userIdxCursor after the last node.
+             *
+             * If the element's value is smaller, then we delegate to the
+             * after() method of the userIdxCursor.
+             */
+            if ( comparedValue >= 0 )
+            {
+                afterLast();
+                return;
+            }
+
+            // Element is in the valid range as specified by assertion
+            userIdxCursor.afterValue( id, value );
+            available = false;
+        }
+        else
+        {
+            throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+        }
+    }
+
+
+    public void after( IndexEntry<V, ServerEntry> element ) throws Exception
     {
         if ( userIdxCursor != null )
         {
@@ -189,8 +266,9 @@
     {
         if ( userIdxCursor != null )
         {
-            IndexEntry<Object,ServerEntry> advanceTo = new ForwardIndexEntry<Object,ServerEntry>();
-            advanceTo.setValue( lessEqEvaluator.getExpression().getValue().get() );
+            IndexEntry<V,ServerEntry> advanceTo = new ForwardIndexEntry<V,ServerEntry>();
+            //noinspection unchecked
+            advanceTo.setValue( ( V ) lessEqEvaluator.getExpression().getValue().get() );
             userIdxCursor.after( advanceTo );
         }
         else
@@ -287,7 +365,7 @@
     }
 
 
-    public IndexEntry<?, ServerEntry> get() throws Exception
+    public IndexEntry<V, ServerEntry> get() throws Exception
     {
         if ( userIdxCursor != null )
         {

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/NotCursor.java Tue May 13 14:28:47 2008
@@ -22,9 +22,9 @@
 
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.AbstractIndexCursor;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.search.Evaluator;
-import org.apache.directory.server.core.cursor.AbstractCursor;
-import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -36,11 +36,11 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $$Rev$$
  */
-public class NotCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
+public class NotCursor<V> extends AbstractIndexCursor<V, ServerEntry>
 {
     private static final String UNSUPPORTED_MSG =
         "NotCursors are not ordered and do not support positioning by element.";
-    private final Cursor<IndexEntry<String,ServerEntry>> ndnCursor;
+    private final IndexCursor<V,ServerEntry> ndnCursor;
     private final Evaluator<? extends ExprNode, ServerEntry> childEvaluator;
     private boolean available = false;
 
@@ -49,7 +49,8 @@
                       Evaluator<? extends ExprNode, ServerEntry> childEvaluator ) throws Exception
     {
         this.childEvaluator = childEvaluator;
-        this.ndnCursor = db.getNdnIndex().forwardCursor();
+        //noinspection unchecked
+        this.ndnCursor = ( IndexCursor<V,ServerEntry> ) db.getNdnIndex().forwardCursor();
     }
 
 
@@ -59,13 +60,25 @@
     }
 
 
-    public void before( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void beforeValue( Long id, V value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void after( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void before( IndexEntry<V, ServerEntry> element ) throws Exception
+    {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+
+    public void after( IndexEntry<V, ServerEntry> element ) throws Exception
+    {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+
+    public void afterValue( Long id, V value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
@@ -129,7 +142,7 @@
     }
 
 
-    public IndexEntry<?, ServerEntry> get() throws Exception
+    public IndexEntry<V, ServerEntry> get() throws Exception
     {
         if ( available )
         {

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java Tue May 13 14:28:47 2008
@@ -20,12 +20,13 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import org.apache.directory.server.core.cursor.AbstractCursor;
 import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.AbstractIndexCursor;
+import org.apache.directory.server.xdbm.IndexCursor;
 
 
 /**
@@ -35,7 +36,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class OneLevelScopeCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
+public class OneLevelScopeCursor extends AbstractIndexCursor<Long, ServerEntry>
 {
     /** Error message for unsupported operations */
     private static final String UNSUPPORTED_MSG =
@@ -48,7 +49,7 @@
     private final OneLevelScopeEvaluator evaluator;
 
     /** A Cursor over the entries in the scope of the search base */
-    private final Cursor<IndexEntry<Long,ServerEntry>> scopeCursor;
+    private final IndexCursor<Long,ServerEntry> scopeCursor;
 
     /** A Cursor over entries brought into scope by alias dereferencing */
     private final Cursor<IndexEntry<Long,ServerEntry>> dereferencedCursor;
@@ -90,13 +91,25 @@
     }
 
 
-    public void before( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void beforeValue( Long id, Long value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void after( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void afterValue( Long id, Long value ) throws Exception
+    {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+
+    public void before( IndexEntry<Long, ServerEntry> element ) throws Exception
+    {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+
+    public void after( IndexEntry<Long, ServerEntry> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java?rev=656019&r1=656018&r2=656019&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OrCursor.java Tue May 13 14:28:47 2008
@@ -21,10 +21,11 @@
 
 
 import org.apache.directory.server.core.cursor.Cursor;
-import org.apache.directory.server.core.cursor.AbstractCursor;
 import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.AbstractIndexCursor;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.search.Evaluator;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 
@@ -35,13 +36,13 @@
  * A Cursor returning candidates satisfying a logical disjunction expression.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $$Rev$$
+ * @version $Rev$
  */
-public class OrCursor extends AbstractCursor<IndexEntry<?, ServerEntry>>
+public class OrCursor<V> extends AbstractIndexCursor<V, ServerEntry>
 {
     private static final String UNSUPPORTED_MSG =
         "OrCursors are not ordered and do not support positioning by element.";
-    private final List<Cursor<IndexEntry<?,ServerEntry>>> cursors;
+    private final List<IndexCursor<V,ServerEntry>> cursors;
     private final List<Evaluator<? extends ExprNode,ServerEntry>> evaluators;
     private final List<Set<Long>> blacklists;
     private int cursorIndex = -1;
@@ -49,7 +50,7 @@
 
 
     // TODO - do same evaluator fail fast optimization that we do in AndCursor
-    public OrCursor( List<Cursor<IndexEntry<?, ServerEntry>>> cursors, List<Evaluator<? extends ExprNode,ServerEntry>> evaluators )
+    public OrCursor( List<IndexCursor<V, ServerEntry>> cursors, List<Evaluator<? extends ExprNode,ServerEntry>> evaluators )
     {
         if ( cursors.size() <= 1 )
         {
@@ -75,13 +76,25 @@
     }
 
 
-    public void before( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void before( IndexEntry<V, ServerEntry> element ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
 
 
-    public void after( IndexEntry<?, ServerEntry> element ) throws Exception
+    public void after( IndexEntry<V, ServerEntry> element ) throws Exception
+    {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+
+    public void beforeValue( Long id, V value ) throws Exception
+    {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+
+    public void afterValue( Long id, V value ) throws Exception
     {
         throw new UnsupportedOperationException( UNSUPPORTED_MSG );
     }
@@ -212,7 +225,7 @@
     }
 
 
-    public IndexEntry<?, ServerEntry> get() throws Exception
+    public IndexEntry<V, ServerEntry> get() throws Exception
     {
         if ( available )
         {



Mime
View raw message