directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1141053 [1/2] - in /directory/apacheds/branches/apacheds-no-reverse-index: jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition/src/test/java/org/apache/directory/server/core/partition/imp...
Date Wed, 29 Jun 2011 11:39:27 GMT
Author: elecharny
Date: Wed Jun 29 11:39:26 2011
New Revision: 1141053

URL: http://svn.apache.org/viewvc?rev=1141053&view=rev
Log:
First commit after reverse table removal. The code contains compilation errors, it's just committed for the sake of sharing it.

Modified:
    directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
    directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
    directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
    directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndex.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndex.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/Evaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/GenericIndexTest.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/StoreUtils.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java

Modified: directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Wed Jun 29 11:39:26 2011
@@ -77,13 +77,6 @@ public class JdbmIndex<K, O> extends Abs
     protected JdbmTable<K, Long> forward;
 
     /**
-     * the reverse btree where the btree key is the entry id of the entry containing a
-     * value for the indexed attribute, and the btree value is the value of the indexed
-     * attribute
-     */
-    protected JdbmTable<Long, K> reverse;
-
-    /**
      * the JDBM record manager for the file containing this index
      */
     protected RecordManager recMan;
@@ -229,23 +222,6 @@ public class JdbmIndex<K, O> extends Abs
 
         forward = new JdbmTable<K, Long>( schemaManager, attributeType.getOid() + FORWARD_BTREE, numDupLimit, recMan,
             comp, LongComparator.INSTANCE, null, LongSerializer.INSTANCE );
-
-        /*
-         * Now the reverse map stores the primary key into the master table as
-         * the key and the values of attributes as the value.  If an attribute
-         * is single valued according to its specification based on a schema 
-         * then duplicate keys should not be allowed within the reverse table.
-         */
-        if ( attributeType.isSingleValued() )
-        {
-            reverse = new JdbmTable<Long, K>( schemaManager, attributeType.getOid() + REVERSE_BTREE, recMan,
-                LongComparator.INSTANCE, LongSerializer.INSTANCE, null );
-        }
-        else
-        {
-            reverse = new JdbmTable<Long, K>( schemaManager, attributeType.getOid() + REVERSE_BTREE, numDupLimit, recMan,
-                LongComparator.INSTANCE, comp, LongSerializer.INSTANCE, null );
-        }
     }
 
 
@@ -352,15 +328,6 @@ public class JdbmIndex<K, O> extends Abs
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public K reverseLookup( Long id ) throws Exception
-    {
-        return reverse.get( id );
-    }
-
-
     // ------------------------------------------------------------------------
     // Add/Drop Methods
     // ------------------------------------------------------------------------
@@ -374,7 +341,6 @@ public class JdbmIndex<K, O> extends Abs
 
         // The pair to be removed must exists
         forward.put( normalizedValue, id );
-        reverse.put( id, normalizedValue );
     }
 
 
@@ -389,28 +355,7 @@ public class JdbmIndex<K, O> extends Abs
         if ( forward.has( normalizedValue, id ) )
         {
             forward.remove( normalizedValue, id );
-            reverse.remove( id, normalizedValue );
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void drop( Long entryId ) throws Exception
-    {
-        // Build a cursor to iterate on all the keys referencing
-        // this entryId
-        Cursor<Tuple<Long, K>> values = reverse.cursor( entryId );
-
-        while ( values.next() )
-        {
-            // Remove the Key -> entryId from the index
-            forward.remove( values.get().getValue(), entryId );
         }
-
-        // Remove the id -> key from the reverse index
-        reverse.remove( entryId );
     }
 
 
@@ -418,13 +363,6 @@ public class JdbmIndex<K, O> extends Abs
     // Index Cursor Operations
     // ------------------------------------------------------------------------
     @SuppressWarnings("unchecked")
-    public IndexCursor<K, O, Long> reverseCursor() throws Exception
-    {
-        return new IndexCursorAdaptor<K, O, Long>( ( Cursor ) reverse.cursor(), false );
-    }
-
-
-    @SuppressWarnings("unchecked")
     public IndexCursor<K, O, Long> forwardCursor() throws Exception
     {
         return new IndexCursorAdaptor<K, O, Long>( ( Cursor ) forward.cursor(), true );
@@ -432,25 +370,12 @@ public class JdbmIndex<K, O> extends Abs
 
 
     @SuppressWarnings("unchecked")
-    public IndexCursor<K, O, Long> reverseCursor( Long id ) throws Exception
-    {
-        return new IndexCursorAdaptor<K, O, Long>( (Cursor) reverse.cursor( id ), false );
-    }
-
-
-    @SuppressWarnings("unchecked")
     public IndexCursor<K, O, Long> forwardCursor( K key ) throws Exception
     {
         return new IndexCursorAdaptor<K, O, Long>( ( Cursor ) forward.cursor( key ), true );
     }
 
 
-    public Cursor<K> reverseValueCursor( Long id ) throws Exception
-    {
-        return reverse.valueCursor( id );
-    }
-
-
     public Cursor<Long> forwardValueCursor( K key ) throws Exception
     {
         return forward.valueCursor( key );
@@ -481,15 +406,6 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean reverse( Long id ) throws Exception
-    {
-        return reverse.has( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public boolean reverse( Long id, K attrVal ) throws Exception
     {
         return forward.has( getNormalized( attrVal ), id );
@@ -532,42 +448,6 @@ public class JdbmIndex<K, O> extends Abs
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseGreaterOrEq( Long id ) throws Exception
-    {
-        return reverse.hasGreaterOrEqual( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseGreaterOrEq( Long id, K attrVal ) throws Exception
-    {
-        return reverse.hasGreaterOrEqual( id, getNormalized( attrVal ) );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseLessOrEq( Long id ) throws Exception
-    {
-        return reverse.hasLessOrEqual( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseLessOrEq( Long id, K attrVal ) throws Exception
-    {
-        return reverse.hasLessOrEqual( id, getNormalized( attrVal ) );
-    }
-
-
     // ------------------------------------------------------------------------
     // Maintenance Methods 
     // ------------------------------------------------------------------------
@@ -581,11 +461,6 @@ public class JdbmIndex<K, O> extends Abs
             forward.close();
         }
 
-        if ( reverse != null )
-        {
-            reverse.close();
-        }
-
         recMan.commit();
         recMan.close();
     }
@@ -635,15 +510,6 @@ public class JdbmIndex<K, O> extends Abs
 
         return normalized;
     }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isDupsEnabled()
-    {
-        return reverse.isDupsEnabled();
-    }
     
     
     /**

Modified: directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java Wed Jun 29 11:39:26 2011
@@ -141,33 +141,22 @@ public class JdbmRdnIndex<E> extends Jdb
 
         forward = new JdbmTable<ParentIdAndRdn<Long>, Long>( schemaManager, attributeType.getOid() + FORWARD_BTREE,
             recMan, comp, null, LongSerializer.INSTANCE );
-        reverse = new JdbmTable<Long, ParentIdAndRdn<Long>>( schemaManager, attributeType.getOid() + REVERSE_BTREE,
-            recMan, LongComparator.INSTANCE, LongSerializer.INSTANCE, null );
     }
 
 
     public void add( ParentIdAndRdn<Long> rdn, Long entryId ) throws Exception
     {
         forward.put( rdn, entryId );
-        reverse.put( entryId, rdn );
-    }
-
-
-    public void drop( Long entryId ) throws Exception
-    {
-        ParentIdAndRdn<Long> rdn = reverse.get( entryId );
-        forward.remove( rdn );
-        reverse.remove( entryId );
     }
 
 
     public void drop( ParentIdAndRdn<Long> rdn, Long id ) throws Exception
     {
         long val = forward.get( rdn );
+        
         if ( val == id )
         {
             forward.remove( rdn );
-            reverse.remove( val );
         }
     }
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java Wed Jun 29 11:39:26 2011
@@ -359,7 +359,6 @@ public class JdbmIndexTest
         initIndex();
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
         assertFalse( idx.forwardGreaterOrEq( "foo", 0L ) );
         assertFalse( idx.forwardGreaterOrEq( "foo", -24L ) );
         assertFalse( idx.forwardGreaterOrEq( "foo", 24L ) );
@@ -369,7 +368,6 @@ public class JdbmIndexTest
 
         idx.add( "foo", 0L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
         assertTrue( idx.forward( "foo", 0L ) );
         assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
         assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
@@ -380,8 +378,6 @@ public class JdbmIndexTest
 
         idx.add( "foo", 1L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
         assertTrue( idx.forward( "foo", 0L ) );
         assertTrue( idx.forward( "foo", 1L ) );
         assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
@@ -395,7 +391,6 @@ public class JdbmIndexTest
 
         idx.add( "bar", 0L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
-        assertEquals( "bar", idx.reverseLookup( 0L ) ); // reverse lookup returns first val
         assertTrue( idx.forward( "bar", 0L ) );
         assertTrue( idx.forward( "foo", 0L ) );
         assertTrue( idx.forward( "foo", 1L ) );
@@ -420,17 +415,13 @@ public class JdbmIndexTest
         initIndex();
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
-        assertNull( idx.reverseLookup( 1L ) );
 
         // test add/drop without adding any duplicates
         idx.add( "foo", 0L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
 
-        idx.drop( 0L );
+        idx.drop( "foo", 0L );
         assertNull( idx.forwardLookup( "foo" ) );
-        assertNull( idx.reverseLookup( 0L ) );
 
         // test add/drop with duplicates in bulk
         idx.add( "foo", 0L );
@@ -438,19 +429,15 @@ public class JdbmIndexTest
         idx.add( "bar", 0L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
         assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
-        assertEquals( "bar", idx.reverseLookup( 0L ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
 
-        idx.drop( 0L );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
+        idx.drop( "foo", 0L );
+        idx.drop( "bar", 0L );
         assertFalse( idx.forward( "bar", 0L ) );
         assertFalse( idx.forward( "foo", 0L ) );
 
-        idx.drop( 1L );
+        idx.drop( "foo", 1L );
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
-        assertNull( idx.reverseLookup( 1L ) );
         assertEquals( 0, idx.count() );
     }
 
@@ -461,17 +448,13 @@ public class JdbmIndexTest
         initIndex();
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
-        assertNull( idx.reverseLookup( 1L ) );
 
         // test add/drop without adding any duplicates
         idx.add( "foo", 0L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
 
         idx.drop( "foo", 0L );
         assertNull( idx.forwardLookup( "foo" ) );
-        assertNull( idx.reverseLookup( 0L ) );
 
         // test add/drop with duplicates but one at a time
         idx.add( "foo", 0L );
@@ -479,25 +462,18 @@ public class JdbmIndexTest
         idx.add( "bar", 0L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
         assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
-        assertEquals( "bar", idx.reverseLookup( 0L ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
 
         idx.drop( "bar", 0L );
         assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
         assertFalse( idx.forward( "bar", 0L ) );
 
         idx.drop( "foo", 0L );
         assertEquals( 1L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
         assertFalse( idx.forward( "foo", 0L ) );
 
         idx.drop( "foo", 1L );
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
-        assertNull( idx.reverseLookup( 1L ) );
         assertEquals( 0, idx.count() );
     }
 
@@ -539,25 +515,6 @@ public class JdbmIndexTest
         IndexEntry<String, Entry, Long> e3 = cursor.get();
         assertEquals( 1234L, ( long ) e3.getId() );
         assertEquals( "foo", e3.getValue() );
-
-        // use reverse index's cursor
-        cursor = idx.reverseCursor();
-        cursor.beforeFirst();
-
-        cursor.next();
-        e1 = cursor.get();
-        assertEquals( 333L, ( long ) e1.getId() );
-        assertEquals( "foo", e1.getValue() );
-
-        cursor.next();
-        e2 = cursor.get();
-        assertEquals( 555L, ( long ) e2.getId() );
-        assertEquals( "bar", e2.getValue() );
-
-        cursor.next();
-        e3 = cursor.get();
-        assertEquals( 1234L, ( long ) e3.getId() );
-        assertEquals( "foo", e3.getValue() );
     }
 
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java Wed Jun 29 11:39:26 2011
@@ -290,13 +290,11 @@ public class JdbmRdnIndexTest
 
         idx.add( key, 0l );
         assertEquals( 0, ( long ) idx.forwardLookup( key ) );
-        assertEquals( key, idx.reverseLookup( 0l ) );
         
         // check with the different case in UP name, this ensures that the custom
         // key comparator is used
         key = new ParentIdAndRdn<Long>( 0L, new Rdn( schemaManager, "cn=KEY" ) );
         assertEquals( 0, ( long ) idx.forwardLookup( key ) );
-        assertEquals( key, idx.reverseLookup( 0l ) );
     }
 
 
@@ -315,7 +313,6 @@ public class JdbmRdnIndexTest
         
         idx.drop( key, 0l );
         assertNull( idx.forwardLookup( key ) );
-        assertNull( idx.reverseLookup( 0l ) );
     }
 
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Wed Jun 29 11:39:26 2011
@@ -549,7 +549,7 @@ public class JdbmStoreTest
 
         assertFalse( cursor.next() );
 
-        idx.drop( 5L );
+        idx.drop( ( long ) cursor.get().getId(), 5L );
 
         cursor = idx.forwardCursor( 2L );
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndex.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndex.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndex.java Wed Jun 29 11:39:26 2011
@@ -92,7 +92,7 @@ public abstract class AbstractIndex<K, O
      */
     public boolean isDupsEnabled()
     {
-        return false;
+        return !attributeType.isSingleValued();
     }
     
     

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java Wed Jun 29 11:39:26 2011
@@ -400,8 +400,9 @@ public abstract class AbstractStore<E, I
      */
     protected ID getSuffixId() throws Exception
     {
-        // TODO: optimize
-        return getEntryId( getSuffixDn() );
+        ParentIdAndRdn<ID> key = new ParentIdAndRdn<ID>( getRootId(), suffixDn.getRdns() );
+        
+        return rdnIdx.forwardLookup( key );
     }
 
 
@@ -763,20 +764,22 @@ public abstract class AbstractStore<E, I
         int dnSize = dn.size();
         int i = suffixDn.size();
 
-        ParentIdAndRdn<ID> key = new ParentIdAndRdn<ID>( getRootId(), suffixDn.getRdns() );
+        ParentIdAndRdn<ID> currentRdn = new ParentIdAndRdn<ID>( getRootId(), suffixDn.getRdns() );
 
         // Check into the Rdn index
-        ID curEntryId = rdnIdx.forwardLookup( key );
+        ID curEntryId = rdnIdx.forwardLookup( currentRdn );
 
-        for ( ; i < dnSize; i++ )
+        while ( i < dnSize )
         {
-            key = new ParentIdAndRdn<ID>( curEntryId, dn.getRdn( dnSize - 1 - i ) );
-            curEntryId = rdnIdx.forwardLookup( key );
+            currentRdn = new ParentIdAndRdn<ID>( curEntryId, dn.getRdn( dnSize - 1 - i ) );
+            curEntryId = rdnIdx.forwardLookup( currentRdn );
 
             if ( curEntryId == null )
             {
                 break;
             }
+            
+            i++;
         }
 
         return curEntryId;
@@ -786,6 +789,58 @@ public abstract class AbstractStore<E, I
     /**
      * {@inheritDoc}
      */
+    public List<ID> getParentIds( Dn dn ) throws Exception
+    {
+        // Just to be sure that the Dn is normalized
+        if ( !dn.isSchemaAware() )
+        {
+            dn.apply( schemaManager );
+        }
+
+        int dnSize = dn.size();
+        int i = suffixDn.size();
+        List<ID> result = new ArrayList<ID>();
+        ID rootId = getRootId();
+
+        ParentIdAndRdn<ID> currentRdn = new ParentIdAndRdn<ID>( rootId, suffixDn.getRdns() );
+        result.add( rootId );
+
+        // Check into the Rdn index
+        ID curEntryId = rdnIdx.forwardLookup( currentRdn );
+        result.add( curEntryId );
+
+        while ( i < dnSize )
+        {
+            currentRdn = new ParentIdAndRdn<ID>( curEntryId, dn.getRdn( dnSize - 1 - i ) );
+            curEntryId = rdnIdx.forwardLookup( currentRdn );
+
+            if ( curEntryId == null )
+            {
+                break;
+            }
+            
+            result.add( curEntryId );
+            
+            i++;
+        }
+
+        return result;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    private boolean hasEntryId( ParentIdAndRdn<ID> key ) throws Exception
+    {
+        // Check into the Rdn index
+        return rdnIdx.forwardLookup( key ) != null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public Dn getEntryDn( ID id ) throws Exception
     {
         return buildEntryDn( id );
@@ -794,7 +849,7 @@ public abstract class AbstractStore<E, I
 
     /**
      * {@inheritDoc}
-     */
+     *
     public ID getParentId( ID childId ) throws Exception
     {
         ParentIdAndRdn<ID> key = rdnIdx.reverseLookup( childId );
@@ -847,6 +902,14 @@ public abstract class AbstractStore<E, I
      * TODO : We should be able to revert all the changes made to index
      * if something went wrong. Also the index should auto-repair : if
      * an entry does not exist in the Master table, then the index must be updated to reflect this.
+     * 
+     * We have four cases :
+     * 1) the entry already exists
+     * 2) the entry has no parent
+     * 3) the entry is a context entry
+     * 4) the entry has a parent
+     * 
+     * Case (1) and (2) are errors. We have to detect them.
      */
     @SuppressWarnings("unchecked")
     public synchronized void add( Entry entry ) throws Exception
@@ -857,119 +920,95 @@ public abstract class AbstractStore<E, I
         }
 
         Dn entryDn = entry.getDn();
-
-        if ( checkHasEntryDuringAdd )
+        ID parentId;
+        ParentIdAndRdn<ID> key = null;
+        Dn parentDn = null;
+        
+        if ( !entryDn.isSchemaAware() )
         {
-            // check if the entry already exists
-            if ( getEntryId( entryDn ) != null )
-            {
-                LdapEntryAlreadyExistsException ne = new LdapEntryAlreadyExistsException(
-                    I18n.err( I18n.ERR_250_ENTRY_ALREADY_EXISTS, entryDn.getName() ) );
-                throw ne;
-            }
+            entryDn.apply( schemaManager );
         }
 
-        ID parentId;
-        ID id = master.getNextId( entry );
-
-        //
-        // Suffix entry cannot have a parent since it is the root so it is
-        // capped off using the zero value which no entry can have since
-        // entry sequences start at 1.
-        //
-        Dn parentDn = null;
-        ParentIdAndRdn<ID> key = null;
+        // Compute some IDs now
+        ID rootId = getRootId();
+        List<ID> parentIds = getParentIds( entryDn );
 
+        // First, get the ParentId and create the key to be added in the rdnIdx
         if ( entryDn.equals( suffixDn ) )
         {
-            parentId = getRootId();
+            // We are adding a new context entry
+            parentId = rootId;
             key = new ParentIdAndRdn<ID>( parentId, suffixDn.getRdns() );
         }
         else
         {
+            // This is a normal entry : it *must* have a parent
             parentDn = entryDn.getParent();
-            parentId = getEntryId( parentDn );
+            parentId = parentIds.get( parentIds.size() - 1 );
             
             if ( parentId == null )
             {
-                parentId = getEntryId( parentDn );
+                // don't keep going if we cannot find the parent Id
+                throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_216, parentDn ) );
             }
             
             key = new ParentIdAndRdn<ID>( parentId, entryDn.getRdn() );
         }
-
-        // don't keep going if we cannot find the parent Id
-        if ( parentId == null )
+        
+        // Then, check that the entry does not already exists in the master table
+        if ( hasEntryId( key ) )
         {
-            throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_216, parentDn ) );
+            LdapEntryAlreadyExistsException ne = new LdapEntryAlreadyExistsException(
+                I18n.err( I18n.ERR_250_ENTRY_ALREADY_EXISTS, entryDn.getName() ) );
+            throw ne;
         }
 
-        rdnIdx.add( key, id );
-
-        Attribute objectClass = entry.get( OBJECT_CLASS_AT );
+        // Get a new unique ID for the entry we are adding
+        ID newId = master.getNextId( entry );
 
-        if ( objectClass == null )
-        {
-            String msg = I18n.err( I18n.ERR_217, entryDn.getName(), entry );
-            ResultCodeEnum rc = ResultCodeEnum.OBJECT_CLASS_VIOLATION;
-            LdapSchemaViolationException e = new LdapSchemaViolationException( rc, msg );
-            //e.setResolvedName( entryDn );
-            throw e;
-        }
+        rdnIdx.add( key, newId );
 
         // Start adding the system userIndices
-        // Why bother doing a lookup if this is not an alias.
         // First, the ObjectClass index
+        Attribute objectClass = entry.get( OBJECT_CLASS_AT );
+
         for ( Value<?> value : objectClass )
         {
-            objectClassIdx.add( value.getString(), id );
+            objectClassIdx.add( value.getString(), newId );
         }
 
         if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
         {
             Attribute aliasAttr = entry.get( ALIASED_OBJECT_NAME_AT );
-            addAliasIndices( id, entryDn, aliasAttr.getString() );
+            addAliasIndices( newId, entryDn, aliasAttr.getString() );
         }
 
-        if ( !Character.isDigit( entryDn.getNormName().charAt( 0 ) ) )
+        // The oneLevel index
+        oneLevelIdx.add( parentId, newId );
+        
+        // The subLevel index : we must link all the hierarchy to the added entry
+        for ( ID id : parentIds )
         {
-            throw new IllegalStateException( I18n.err( I18n.ERR_218, entryDn.getNormName() ) );
+            if ( id.equals( rootId ) )
+            {
+                // Skip the rootDSE
+                continue;
+            }
+            
+            // Add the <ancestor, newId> tuple
+            subLevelIdx.add( id, newId );
         }
 
-        oneLevelIdx.add( parentId, id );
+        // making entry an ancestor/descendent of itself in sublevel index
+        subLevelIdx.add( newId, newId );
 
-        // Update the EntryCsn index
+        // The entryCSN index
         Attribute entryCsn = entry.get( ENTRY_CSN_AT );
-
-        if ( entryCsn == null )
-        {
-            String msg = I18n.err( I18n.ERR_219, entryDn.getName(), entry );
-            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, msg );
-        }
-
-        entryCsnIdx.add( entryCsn.getString(), id );
-
-        // Update the EntryUuid index
+        entryCsnIdx.add( entryCsn.getString(), newId );
+        
+        // The entryUuid index
         Attribute entryUuid = entry.get( ENTRY_UUID_AT );
-
-        if ( entryUuid == null )
-        {
-            String msg = I18n.err( I18n.ERR_220, entryDn.getName(), entry );
-            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, msg );
-        }
-
-        entryUuidIdx.add( entryUuid.getString(), id );
-
-        ID tempId = parentId;
-
-        while ( ( tempId != null ) && ( !tempId.equals( getRootId() ) ) && ( !tempId.equals( getSuffixId() ) ) )
-        {
-            subLevelIdx.add( tempId, id );
-            tempId = getParentId( tempId );
-        }
-
-        // making entry an ancestor/descendent of itself in sublevel index
-        subLevelIdx.add( id, id );
+        entryUuidIdx.add( entryUuid.getString(), newId );
 
         // Now work on the user defined userIndices
         for ( Attribute attribute : entry )
@@ -985,17 +1024,17 @@ public abstract class AbstractStore<E, I
 
                 for ( Value<?> value : attribute )
                 {
-                    idx.add( value.getValue(), id );
+                    idx.add( value.getValue(), newId );
                 }
 
                 // Adds only those attributes that are indexed
-                presenceIdx.add( attributeOid, id );
+                presenceIdx.add( attributeOid, newId );
             }
         }
 
         entry.put( SchemaConstants.ENTRY_PARENT_ID_AT, parentId.toString() );
         
-        master.put( id, entry );
+        master.put( newId, entry );
 
         if ( isSyncOnWrite.get() )
         {
@@ -1016,6 +1055,7 @@ public abstract class AbstractStore<E, I
 
         ID id = getEntryId( dn );
         Entry entry = master.get( id );
+        String oldCsn = entry.get( SchemaConstants.ENTRY_CSN_AT ).getString();
 
         for ( AttributeType attributeType : mods.getAttributeTypes() )
         {
@@ -1041,7 +1081,9 @@ public abstract class AbstractStore<E, I
             }
         }
 
-        updateCsnIndex( entry, id );
+        String newCsn = entry.get( SchemaConstants.ENTRY_CSN_AT ).getString();
+
+        updateCsnIndex( oldCsn, newCsn, id );
         master.put( id, entry );
 
         if ( isSyncOnWrite.get() )
@@ -1059,6 +1101,8 @@ public abstract class AbstractStore<E, I
         ID id = getEntryId( dn );
         Entry entry = master.get( id );
 
+        String oldCsn = entry.get( SchemaConstants.ENTRY_CSN_AT ).getString();
+
         for ( Modification mod : mods )
         {
             Attribute attrMods = mod.getAttribute();
@@ -1081,8 +1125,10 @@ public abstract class AbstractStore<E, I
                     throw new LdapException( I18n.err( I18n.ERR_221 ) );
             }
         }
+        
+        String newCsn = entry.get( SchemaConstants.ENTRY_CSN_AT ).getString();
 
-        updateCsnIndex( entry, id );
+        updateCsnIndex( oldCsn, newCsn, id );
         master.put( id, entry );
 
         if ( isSyncOnWrite.get() )
@@ -1113,12 +1159,15 @@ public abstract class AbstractStore<E, I
         {
             objectClassIdx.drop( value.getString(), id );
         }
+        
+        ParentIdAndRdn<ID> key = new ParentIdAndRdn<ID>( getParentId( id ), entry.getDn().getRdn() );
 
-        rdnIdx.drop( id );
+
+        rdnIdx.drop( key, id );
         oneLevelIdx.drop( id );
         subLevelIdx.drop( id );
-        entryCsnIdx.drop( id );
-        entryUuidIdx.drop( id );
+        entryCsnIdx.drop( entry.get( SchemaConstants.ENTRY_CSN_AT ).getString(), id );
+        entryUuidIdx.drop( entry.get( SchemaConstants.ENTRY_UUID_AT ).getString(), id );
 
         for ( Attribute attribute : entry )
         {
@@ -2142,10 +2191,10 @@ public abstract class AbstractStore<E, I
      * @param id ID of the entry
      * @throws Exception
      */
-    private void updateCsnIndex( Entry entry, ID id ) throws Exception
+    private void updateCsnIndex( String oldCsn, String newCsn, ID id ) throws Exception
     {
-        entryCsnIdx.drop( id );
-        entryCsnIdx.add( entry.get( SchemaConstants.ENTRY_CSN_AT ).getString(), id );
+        entryCsnIdx.drop( oldCsn, id );
+        entryCsnIdx.add( newCsn, id );
     }
 
     

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java Wed Jun 29 11:39:26 2011
@@ -100,12 +100,6 @@ public class GenericIndex<K, O, ID> exte
     }
 
 
-    public void drop( ID id ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
     public void drop( K attrVal, ID id ) throws Exception
     {
         throw new UnsupportedOperationException();
@@ -148,18 +142,6 @@ public class GenericIndex<K, O, ID> exte
     }
 
 
-    public boolean reverse( ID id ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
-    public boolean reverse( ID id, K attrVal ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
     public boolean forwardGreaterOrEq( K attrVal ) throws Exception
     {
         throw new UnsupportedOperationException();
@@ -172,18 +154,6 @@ public class GenericIndex<K, O, ID> exte
     }
 
 
-    public boolean reverseGreaterOrEq( ID id ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
-    public boolean reverseGreaterOrEq( ID id, K attrVal ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
     public boolean forwardLessOrEq( K attrVal ) throws Exception
     {
         throw new UnsupportedOperationException();
@@ -196,18 +166,6 @@ public class GenericIndex<K, O, ID> exte
     }
 
 
-    public boolean reverseLessOrEq( ID id ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
-    public boolean reverseLessOrEq( ID id, K attrVal ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
     public AttributeType getAttribute()
     {
         throw new UnsupportedOperationException();
@@ -238,30 +196,6 @@ public class GenericIndex<K, O, ID> exte
     }
 
 
-    public IndexCursor<K, O, ID> reverseCursor() throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
-    public IndexCursor<K, O, ID> reverseCursor( ID id ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
-    public K reverseLookup( ID id ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
-    public Cursor<K> reverseValueCursor( ID id ) throws Exception
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
     public void setWkDirPath( URI wkDirPath )
     {
         this.wkDirPath = wkDirPath;
@@ -272,13 +206,4 @@ public class GenericIndex<K, O, ID> exte
     {
         throw new UnsupportedOperationException();
     }
-
-    
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isDupsEnabled()
-    {
-        return false;
-    }
 }

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Index.java Wed Jun 29 11:39:26 2011
@@ -151,9 +151,6 @@ public interface Index<K, O, ID>
     ID forwardLookup( K attrVal ) throws Exception;
 
 
-    K reverseLookup( ID id ) throws Exception;
-
-
     /**
      * Add an entry into the index, associated with the element ID. The added
      * value is the key to retrieve the element having the given ID.
@@ -166,36 +163,6 @@ public interface Index<K, O, ID>
 
 
     /**
-     * Remove all the reference to an entry from the index.
-     * <br/>
-     * As an entry might be referenced more than once in the forward index,
-     * depending on which index we are dealing with, we need to iterate 
-     * over all the values contained into the reverse index for this entryId.
-     * <br/>
-     * For instance, considering the ObjectClass index for an entry having
-     * three ObjectClasses (top, person, inetOrgPerson), then the reverse
-     * index will contain :
-     * <pre>
-     * [entryId, [top, person, inetOrgPerson]]
-     * </pre>
-     * and the forward index will contain many entries like :
-     * <pre>
-     * [top, [..., entryId, ...]]
-     * [person,  [..., entryId, ...]]
-     * [inetOrgPerson,  [..., entryId, ...]]
-     * </pre>
-     * So dropping the entryId means that we must first get all the values from
-     * the reverse index (and we will get [top, person, inetOrgPerson]) then to
-     * iterate through all those values to remove entryId from the associated 
-     * list of entryIds.
-     * 
-     * @param entryId The master table entry ID to remove
-     * @throws Exception
-     */
-    void drop( ID entryId ) throws Exception;
-
-
-    /**
      * Remove the pair <K,ID> from the index for the given value and id. 
      * 
      * @param attrVal The value we want to remove from the index
@@ -205,21 +172,12 @@ public interface Index<K, O, ID>
     void drop( K attrVal, ID id ) throws Exception;
 
 
-    IndexCursor<K, O, ID> reverseCursor() throws Exception;
-
-
     IndexCursor<K, O, ID> forwardCursor() throws Exception;
 
 
-    IndexCursor<K, O, ID> reverseCursor( ID id ) throws Exception;
-
-
     IndexCursor<K, O, ID> forwardCursor( K key ) throws Exception;
 
 
-    Cursor<K> reverseValueCursor( ID id ) throws Exception;
-
-
     Cursor<ID> forwardValueCursor( K key ) throws Exception;
 
 
@@ -229,36 +187,18 @@ public interface Index<K, O, ID>
     boolean forward( K attrVal, ID id ) throws Exception;
 
 
-    boolean reverse( ID id ) throws Exception;
-
-
-    boolean reverse( ID id, K attrVal ) throws Exception;
-
-
     boolean forwardGreaterOrEq( K attrVal ) throws Exception;
 
 
     boolean forwardGreaterOrEq( K attrVal, ID id ) throws Exception;
 
 
-    boolean reverseGreaterOrEq( ID id ) throws Exception;
-
-
-    boolean reverseGreaterOrEq( ID id, K attrVal ) throws Exception;
-
-
     boolean forwardLessOrEq( K attrVal ) throws Exception;
 
 
     boolean forwardLessOrEq( K attrVal, ID id ) throws Exception;
 
 
-    boolean reverseLessOrEq( ID id ) throws Exception;
-
-
-    boolean reverseLessOrEq( ID id, K attrVal ) throws Exception;
-
-
     void close() throws Exception;
 
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java Wed Jun 29 11:39:26 2011
@@ -150,7 +150,31 @@ public class ParentIdAndRdn<ID extends C
             return false;
         }
 
-        return compareTo( ( ParentIdAndRdn<ID> ) obj ) == 0;
+        ParentIdAndRdn<ID> that = (ParentIdAndRdn<ID>) obj;
+        
+        if ( rdns == null )
+        {
+            return that.rdns == null;
+        }
+        else if ( that.rdns != null )
+        {
+            return false;
+        }
+        
+        if ( rdns.length != that.rdns.length )
+        {
+            return false;
+        }
+        
+        for ( int i = 0; i < rdns.length; i++ )
+        {
+            if ( !rdns[i].equals( that.rdns[i] ) )
+            {
+                return false;
+            }
+        }
+        
+        return true;
     }
 
     

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java Wed Jun 29 11:39:26 2011
@@ -457,7 +457,7 @@ public interface Store<E, ID extends Com
      * Gets the normalized Dn of the entry identified by the given id.
      * @param id the entry's id
      * @return the normalized entry Dn
-     */
+     *
     Dn getEntryDn( ID id ) throws Exception;
 
 
@@ -469,7 +469,7 @@ public interface Store<E, ID extends Com
      * @return the id of the parent entry or zero if the suffix entry ID is used
      * @throws Exception on failures to access the underlying store
      */
-    ID getParentId( ID childId ) throws Exception;
+    List<ID> getParentIds( Dn dn ) throws Exception;
 
 
     /**
@@ -497,7 +497,7 @@ public interface Store<E, ID extends Com
      * @param id The Entry ID we want to get back
      * @return The found Entry, or null if not found
      * @throws Exception If the lookup failed for any reason (except a not found entry)
-     */
+     *
     Entry lookup( ID id ) throws Exception;
 
 
@@ -515,7 +515,7 @@ public interface Store<E, ID extends Com
      * @param id the id of the parent entry
      * @return an IndexEntry Cursor over the child entries
      * @throws Exception on failures to access the underlying store
-     */
+     *
     IndexCursor<ID, E, ID> list( ID id ) throws Exception;
 
 
@@ -525,7 +525,7 @@ public interface Store<E, ID extends Com
      * @param id the entry ID
      * @return the child count 
      * @throws Exception on failures to access the underlying store
-     */
+     *
     int getChildCount( ID id ) throws Exception;
 
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlIndex.java Wed Jun 29 11:39:26 2011
@@ -46,7 +46,6 @@ public class AvlIndex<K, O> extends Abst
 {
     protected Normalizer normalizer;
     protected AvlTable<K, Long> forward;
-    protected AvlTable<Long, K> reverse;
 
 
     public AvlIndex()
@@ -92,28 +91,12 @@ public class AvlIndex<K, O> extends Abst
          * different entries so the forward map can have more than one value.
          */
         forward = new AvlTable<K, Long>( attributeType.getName(), comp, LongComparator.INSTANCE, true );
-
-        /*
-         * Now the reverse map stores the primary key into the master table as
-         * the key and the values of attributes as the value.  If an attribute
-         * is single valued according to its specification based on a schema 
-         * then duplicate keys should not be allowed within the reverse table.
-         */
-        if ( attributeType.isSingleValued() )
-        {
-            reverse = new AvlTable<Long, K>( attributeType.getName(), LongComparator.INSTANCE, comp, false );
-        }
-        else
-        {
-            reverse = new AvlTable<Long, K>( attributeType.getName(), LongComparator.INSTANCE, comp, true );
-        }
     }
 
 
     public void add( K attrVal, Long id ) throws Exception
     {
         forward.put( getNormalized( attrVal ), id );
-        reverse.put( id, getNormalized( attrVal ) );
     }
 
 
@@ -126,11 +109,6 @@ public class AvlIndex<K, O> extends Abst
         {
             forward.close();
         }
-        
-        if ( reverse != null )
-        {
-            reverse.close();
-        }
     }
 
 
@@ -155,27 +133,9 @@ public class AvlIndex<K, O> extends Abst
     /**
      * {@inheritDoc}
      */
-    public void drop( Long id ) throws Exception
-    {
-        Cursor<Tuple<Long, K>> cursor = reverse.cursor( id );
-
-        while ( cursor.next() )
-        {
-            Tuple<Long, K> tuple = cursor.get();
-            forward.remove( tuple.getValue(), id );
-        }
-
-        reverse.remove( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public void drop( K attrVal, Long id ) throws Exception
     {
         forward.remove( getNormalized( attrVal ), id );
-        reverse.remove( id, getNormalized( attrVal ) );
     }
 
 
@@ -312,98 +272,6 @@ public class AvlIndex<K, O> extends Abst
 
 
     /**
-     * {@inheritDoc}
-     */
-    public boolean reverse( Long id ) throws Exception
-    {
-        return reverse.has( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverse( Long id, K attrVal ) throws Exception
-    {
-        return reverse.has( id, getNormalized( attrVal ) );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @SuppressWarnings("unchecked")
-    public IndexCursor<K, O, Long> reverseCursor() throws Exception
-    {
-        return new IndexCursorAdaptor( reverse.cursor(), false );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @SuppressWarnings("unchecked")
-    public IndexCursor<K, O, Long> reverseCursor( Long id ) throws Exception
-    {
-        return new IndexCursorAdaptor( reverse.cursor( id ), false );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseGreaterOrEq( Long id ) throws Exception
-    {
-        return reverse.hasGreaterOrEqual( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseGreaterOrEq( Long id, K attrVal ) throws Exception
-    {
-        return reverse.hasGreaterOrEqual( id, getNormalized( attrVal ) );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseLessOrEq( Long id ) throws Exception
-    {
-        return reverse.hasLessOrEqual( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseLessOrEq( Long id, K attrVal ) throws Exception
-    {
-        return reverse.hasLessOrEqual( id, getNormalized( attrVal ) );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public K reverseLookup( Long id ) throws Exception
-    {
-        return reverse.get( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Cursor<K> reverseValueCursor( Long id ) throws Exception
-    {
-        return reverse.valueCursor( id );
-    }
-
-
-    /**
      * throws UnsupportedOperationException cause it is a in-memory index
      */
     public void setWkDirPath( URI wkDirPath )
@@ -424,15 +292,6 @@ public class AvlIndex<K, O> extends Abst
     /**
      * {@inheritDoc}
      */
-    public boolean isDupsEnabled()
-    {
-        return reverse.isDupsEnabled();
-    }
-    
-    
-    /**
-     * {@inheritDoc}
-     */
     public void sync() throws Exception
     {
     }

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndex.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndex.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndex.java Wed Jun 29 11:39:26 2011
@@ -83,23 +83,12 @@ public class AvlRdnIndex<E> extends AvlI
          */
         forward = new AvlTable<ParentIdAndRdn<Long>, Long>( attributeType.getName(), comp, LongComparator.INSTANCE,
             false );
-        reverse = new AvlTable<Long, ParentIdAndRdn<Long>>( attributeType.getName(), LongComparator.INSTANCE, comp,
-            false );
     }
 
 
     public void add( ParentIdAndRdn<Long> rdn, Long entryId ) throws Exception
     {
         forward.put( rdn, entryId );
-        reverse.put( entryId, rdn );
-    }
-
-
-    public void drop( Long entryId ) throws Exception
-    {
-        ParentIdAndRdn<Long> rdn = reverse.get( entryId );
-        forward.remove( rdn );
-        reverse.remove( entryId );
     }
 
 
@@ -109,7 +98,6 @@ public class AvlRdnIndex<E> extends AvlI
         if ( val == id )
         {
             forward.remove( rdn );
-            reverse.remove( val );
         }
     }
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java Wed Jun 29 11:39:26 2011
@@ -173,5 +173,4 @@ public class AvlStore<E> extends Abstrac
     {
         return 0L;
     }
-    
 }

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/Evaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/Evaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/Evaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/Evaluator.java Wed Jun 29 11:39:26 2011
@@ -66,17 +66,6 @@ public interface Evaluator<N extends Exp
 
 
     /**
-     * Evaluates whether or not a candidate, specified by an id, satisfies the
-     * expression associated with this Evaluator .
-     *
-     * @param id the identifier for the candidate entry
-     * @return true if filter selects the candidate false otherwise
-     * @throws Exception if there are faults during evaluation
-     */
-    boolean evaluateId( ID id ) throws Exception;
-
-
-    /**
      * Evaluates whether or not a candidate, satisfies the expression
      * associated with this Evaluator .
      *

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AllEntriesCursor.java Wed Jun 29 11:39:26 2011
@@ -41,8 +41,7 @@ public class AllEntriesCursor<ID extends
 
     public AllEntriesCursor( Store<Entry, ID> db ) throws Exception
     {
-        // Get a reverse cursor because we want to sort by ID
-        wrapped = db.getNdnIndex().reverseCursor();
+        wrapped = db.getNdnIndex().forwardCursor();
     }
 
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/AndEvaluator.java Wed Jun 29 11:39:26 2011
@@ -102,20 +102,6 @@ public class AndEvaluator<ID> implements
     }
 
 
-    public boolean evaluateId( ID id ) throws Exception
-    {
-        for ( Evaluator<?, Entry, ID> evaluator : evaluators )
-        {
-            if ( !evaluator.evaluateId( id ) )
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-
     public boolean evaluateEntry( Entry entry ) throws Exception
     {
         for ( Evaluator<?, Entry, ID> evaluator : evaluators )

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/ApproximateEvaluator.java Wed Jun 29 11:39:26 2011
@@ -116,17 +116,6 @@ public class ApproximateEvaluator<T, ID 
     }
 
 
-    public boolean evaluateId( ID id ) throws Exception
-    {
-        if ( idx != null )
-        {
-            return idx.reverse( id );
-        }
-
-        return evaluateEntry( db.lookup( id ) );
-    }
-
-
     public boolean evaluate( IndexEntry<?, Entry, ID> indexEntry ) throws Exception
     {
         if ( idx != null )

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java Wed Jun 29 11:39:26 2011
@@ -151,6 +151,7 @@ public class DefaultSearchEngine<ID exte
         if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE )
         {
             ID effectiveBaseId = baseId;
+            
             if ( effectiveBase != base )
             {
                 effectiveBaseId = db.getEntryId( effectiveBase );

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java Wed Jun 29 11:39:26 2011
@@ -151,17 +151,6 @@ public class EqualityEvaluator<T, ID ext
     }
 
 
-    public boolean evaluateId( ID id ) throws Exception
-    {
-        if ( idx != null )
-        {
-            return idx.reverse( id );
-        }
-
-        return evaluateEntry( db.lookup( id ) );
-    }
-
-
     // TODO - determine if comparator and index entry should have the Value
     // wrapper or the raw normalized value
     private boolean evaluate( Attribute attribute ) throws Exception

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/GreaterEqEvaluator.java Wed Jun 29 11:39:26 2011
@@ -150,17 +150,6 @@ public class GreaterEqEvaluator<T, ID ex
     }
 
 
-    public boolean evaluateId( ID id ) throws Exception
-    {
-        if ( idx != null && idx.isDupsEnabled() )
-        {
-            return idx.reverseGreaterOrEq( id, node.getValue().getValue() );
-        }
-
-        return evaluateEntry( db.lookup( id ) );
-    }
-
-
     public boolean evaluateEntry( Entry entry ) throws Exception
     {
         // get the attribute

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java Wed Jun 29 11:39:26 2011
@@ -87,17 +87,6 @@ public class LessEqEvaluator<T, ID exten
     }
 
 
-    public boolean evaluateId( ID id ) throws Exception
-    {
-        if ( ( idx != null ) && idx.isDupsEnabled() )
-        {
-            return idx.reverseLessOrEq( id, node.getValue().getValue() );
-        }
-
-        return evaluateEntry( db.lookup( id ) );
-    }
-
-
     public boolean evaluate( IndexEntry<?, Entry, ID> indexEntry ) throws Exception
     {
         if ( ( idx != null ) && idx.isDupsEnabled() )

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/NotEvaluator.java Wed Jun 29 11:39:26 2011
@@ -48,12 +48,6 @@ public class NotEvaluator<ID> implements
     }
 
 
-    public boolean evaluateId( ID id ) throws Exception
-    {
-        return !childEvaluator.evaluateId( id );
-    }
-
-
     public boolean evaluateEntry( Entry entry ) throws Exception
     {
         return !childEvaluator.evaluateEntry( entry );

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeCursor.java Wed Jun 29 11:39:26 2011
@@ -181,7 +181,7 @@ public class OneLevelScopeCursor<ID exte
                     checkNotClosed( "previous()" );
                     available = cursor.previous();
 
-                    if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                    if ( available )
                     {
                         break;
                     }
@@ -214,7 +214,7 @@ public class OneLevelScopeCursor<ID exte
                 checkNotClosed( "previous()" );
                 available = cursor.previous();
 
-                if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                if ( available )
                 {
                     break;
                 }
@@ -249,7 +249,7 @@ public class OneLevelScopeCursor<ID exte
                 checkNotClosed( "next()" );
                 available = cursor.next();
 
-                if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                if ( available )
                 {
                     break;
                 }

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java Wed Jun 29 11:39:26 2011
@@ -74,62 +74,6 @@ public class OneLevelScopeEvaluator<E, I
      * Asserts whether or not a candidate has one level scope while taking
      * alias dereferencing into account.
      *
-     * @param candidate the candidate to assert
-     * @return true if the candidate is within one level scope
-     * @throws Exception if db lookups fail
-     * @see org.apache.directory.server.xdbm.search.Evaluator#evaluate(IndexEntry)
-     */
-    public boolean evaluateId( ID candidate ) throws Exception
-    {
-        boolean isChild = db.getOneLevelIndex().forward( baseId, candidate );
-
-        /*
-         * The candidate id could be any entry in the db.  If search
-         * dereferencing is not enabled then we return the results of the child
-         * test.
-         */
-        if ( !dereferencing )
-        {
-            return isChild;
-        }
-
-        /*
-         * From here down alias dereferencing is enabled.  We determine if the
-         * candidate id is an alias, if so we reject it since aliases should
-         * not be returned.
-         */
-        if ( null != db.getAliasIndex().reverseLookup( candidate ) )
-        {
-            return false;
-        }
-
-        /*
-         * The candidate is NOT an alias at this point.  So if it is a child we
-         * just return true since it is in normal one level scope.
-         */
-        if ( isChild )
-        {
-            return true;
-        }
-
-        /*
-         * At this point the candidate is not a child and it is not an alias.
-         * We need to check if the candidate is in extended one level scope by
-         * performing a lookup on the one level alias index.  This index stores
-         * a tuple mapping the baseId to the id of objects brought into the
-         * one level scope of the base by an alias: ( baseId, aliasedObjId )
-         * If the candidate id is an object brought into one level scope then
-         * the lookup returns true accepting the candidate.  Otherwise the
-         * candidate is rejected with a false return because it is not in scope.
-         */
-        return db.getOneAliasIndex().forward( baseId, candidate );
-    }
-
-
-    /**
-     * Asserts whether or not a candidate has one level scope while taking
-     * alias dereferencing into account.
-     *
      * TODO - terribly inefficient - would benefit from exposing the id of an
      * entry within the Entry
      *
@@ -165,16 +109,6 @@ public class OneLevelScopeEvaluator<E, I
         }
 
         /*
-         * From here down alias dereferencing is enabled.  We determine if the
-         * candidate id is an alias, if so we reject it since aliases should
-         * not be returned.
-         */
-        if ( null != db.getAliasIndex().reverseLookup( candidate.getId() ) )
-        {
-            return false;
-        }
-
-        /*
          * The candidate is NOT an alias at this point.  So if it is a child we
          * just return true since it is in normal one level scope.
          */

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/OrEvaluator.java Wed Jun 29 11:39:26 2011
@@ -116,20 +116,6 @@ public class OrEvaluator<ID> implements 
     }
 
 
-    public boolean evaluateId( ID id ) throws Exception
-    {
-        for ( Evaluator<?, Entry, ID> evaluator : evaluators )
-        {
-            if ( evaluator.evaluateId( id ) )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-
     public boolean evaluateEntry( Entry entry ) throws Exception
     {
         for ( Evaluator<?, Entry, ID> evaluator : evaluators )

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/PresenceEvaluator.java Wed Jun 29 11:39:26 2011
@@ -112,19 +112,6 @@ public class PresenceEvaluator<ID extend
 
     // TODO - determine if comaparator and index entry should have the Value
     // wrapper or the raw normalized value
-    public boolean evaluateId( ID id ) throws Exception
-    {
-        if ( idx != null )
-        {
-            return idx.forward( attributeType.getOid(), id );
-        }
-
-        return evaluateEntry( db.lookup( id ) );
-    }
-
-
-    // TODO - determine if comaparator and index entry should have the Value
-    // wrapper or the raw normalized value
     public boolean evaluateEntry( Entry entry ) throws Exception
     {
         if ( db.hasSystemIndexOn( attributeType ) )

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java Wed Jun 29 11:39:26 2011
@@ -139,20 +139,6 @@ public class SubstringEvaluator<ID exten
     }
 
 
-    public boolean evaluateId( ID id ) throws Exception
-    {
-
-        if ( idx == null )
-        {
-            return evaluateWithoutIndex( id );
-        }
-        else
-        {
-            return evaluateWithIndex( id );
-        }
-    }
-
-
     public boolean evaluateEntry( Entry entry ) throws Exception
     {
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java Wed Jun 29 11:39:26 2011
@@ -212,7 +212,8 @@ public class SubtreeScopeCursor<ID exten
                 {
                     checkNotClosed( "previous()" );
                     available = cursor.previous();
-                    if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                    
+                    if ( available )
                     {
                         break;
                     }
@@ -245,7 +246,7 @@ public class SubtreeScopeCursor<ID exten
                 checkNotClosed( "previous()" );
                 available = cursor.previous();
 
-                if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                if ( available )
                 {
                     break;
                 }
@@ -280,7 +281,7 @@ public class SubtreeScopeCursor<ID exten
                 checkNotClosed( "next()" );
                 available = cursor.next();
 
-                if ( available && db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                if ( available )
                 {
                     break;
                 }

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java Wed Jun 29 11:39:26 2011
@@ -124,7 +124,50 @@ public class SubtreeScopeEvaluator<E, ID
      */
     public boolean evaluate( IndexEntry<?, E, ID> candidate ) throws Exception
     {
-        return evaluateId( candidate.getId() );
+        ID id = candidate.getId();
+        
+        /*
+         * This condition catches situations where the candidate is equal to 
+         * the base entry and when the base entry is the context entry.  Note
+         * we do not store a mapping in the subtree index of the context entry
+         * to all it's subordinates since that would be the entire set of 
+         * entries in the db.
+         */        
+        boolean isDescendant = baseIsContextEntry || baseId.equals( id ) || db.getSubLevelIndex().forward( baseId, id );
+
+        /*
+         * The candidate id could be any entry in the db.  If search
+         * dereferencing is not enabled then we return the results of the
+         * descendant test.
+         */
+        if ( !isDereferencing() )
+        {
+            return isDescendant;
+        }
+
+        /*
+         * The candidate is NOT an alias at this point.  So if it is a
+         * descendant we just return true since it is in normal subtree scope.
+         */
+        if ( isDescendant )
+        {
+            return true;
+        }
+
+        /*
+         * At this point the candidate is not a descendant and it is not an
+         * alias.  We need to check if the candidate is in extended subtree
+         * scope by performing a lookup on the subtree alias index.  This index
+         * stores a tuple mapping the baseId to the ids of objects brought
+         * into subtree scope of the base by an alias:
+         *
+         * ( baseId, aliasedObjId )
+         *
+         * If the candidate id is an object brought into subtree scope then
+         * the lookup returns true accepting the candidate.  Otherwise the
+         * candidate is rejected with a false return because it is not in scope.
+         */
+        return db.getSubAliasIndex().forward( baseId, id );
     }
 
 
@@ -160,16 +203,6 @@ public class SubtreeScopeEvaluator<E, ID
         }
 
         /*
-         * From here down alias dereferencing is enabled.  We determine if the
-         * candidate id is an alias, if so we reject it since aliases should
-         * not be returned.
-         */
-        if ( null != db.getAliasIndex().reverseLookup( id ) )
-        {
-            return false;
-        }
-
-        /*
          * The candidate is NOT an alias at this point.  So if it is a
          * descendant we just return true since it is in normal subtree scope.
          */

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java?rev=1141053&r1=1141052&r2=1141053&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java (original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java Wed Jun 29 11:39:26 2011
@@ -257,7 +257,6 @@ public class AbstractStoreTest
 
         // after modification: no "sales" tuple in ou index
         assertFalse( store.getPresenceIndex().forward( SchemaConstants.OU_AT_OID, entryId ) );
-        assertFalse( ouIndex.reverse( entryId ) );
         assertFalse( ouIndex.forward( "sales", entryId ) );
         assertNull( lookedup.get( "ou" ) );
     }
@@ -315,14 +314,12 @@ public class AbstractStoreTest
         Entry lookedup = store.lookup( entryId );
 
         // before modification: expect "person" tuple in objectClass index
-        assertTrue( store.getObjectClassIndex().reverse( entryId ) );
         assertTrue( store.getObjectClassIndex().forward( "person", entryId ) );
         assertTrue( lookedup.get( "objectClass" ).contains( "person" ) );
 
         store.modify( dn, mods );
 
         // after modification: no tuple in objectClass index
-        assertFalse( store.getObjectClassIndex().reverse( entryId ) );
         assertFalse( store.getObjectClassIndex().forward( "person", entryId ) );
         assertNull( lookedup.get( "objectClass" ) );
     }
@@ -348,13 +345,11 @@ public class AbstractStoreTest
         Entry lookedup = store.lookup( entryId );
         
         assertNotSame( csn, lookedup.get( csnAt ).getString() );
-        assertNotSame( csn, store.getEntryCsnIndex().reverseLookup( entryId ) );
 
         store.modify( dn, mods );
         
         String updateCsn = lookedup.get( csnAt ).getString();
         assertEquals( csn, updateCsn );
-        assertEquals( csn, store.getEntryCsnIndex().reverseLookup( entryId ) );
         
         csn = csnF.newInstance().toString();
         
@@ -362,12 +357,10 @@ public class AbstractStoreTest
         modEntry.add( csnAt, csn );
         
         assertNotSame( csn, updateCsn );
-        assertNotSame( csn, store.getEntryCsnIndex().reverseLookup( entryId ) );
         
         store.modify( dn, ModificationOperation.REPLACE_ATTRIBUTE, modEntry );
         
         assertEquals( csn, lookedup.get( csnAt ).getString() );
-        assertEquals( csn, store.getEntryCsnIndex().reverseLookup( entryId ) );
     }
     
     



Mime
View raw message