directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r649879 - in /directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src: main/java/org/apache/directory/server/xdbm/search/impl/ test/java/org/apache/directory/server/xdbm/search/impl/
Date Sun, 20 Apr 2008 03:40:57 GMT
Author: akarasulu
Date: Sat Apr 19 20:40:56 2008
New Revision: 649879

URL: http://svn.apache.org/viewvc?rev=649879&view=rev
Log:
changes to one and sub level scope cursors and evaluators ...

 o making evaluators reject candidates that are aliases even if candidates match
   based on scope when alias dereferencing is enabled while searching - this is
   to filter out alias entries
 o cursors will not return alias candidates when alias dereferencing while 
   searching is enabled.  Only when disabled while searching will these scope
   cursors return alias candidates
 o added more test cases for coverage with additional code
 o fixed few bugs in the process


Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
    directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java?rev=649879&r1=649878&r2=649879&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
Sat Apr 19 20:40:56 2008
@@ -41,6 +41,9 @@
     private static final String UNSUPPORTED_MSG =
         "Scope Cursors are not ordered and do not support positioning by element.";
 
+    /** The Entry database/store */
+    private final Store<Attributes> db;
+
     /** A ScopeNode Evaluator */
     private final SubtreeScopeEvaluator evaluator;
 
@@ -66,6 +69,7 @@
      */
     public SubtreeScopeCursor( Store<Attributes> db, SubtreeScopeEvaluator evaluator
) throws Exception
     {
+        this.db = db;
         this.evaluator = evaluator;
         scopeCursor = db.getSubLevelIndex().forwardCursor( evaluator.getBaseId() );
 
@@ -144,11 +148,29 @@
             afterLast();
         }
 
-        available = cursor.previous();
-
         // if we're using the scopeCursor (1st Cursor) then return result as is
         if ( cursor == scopeCursor )
         {
+            /*
+             * If dereferencing is enabled then we must ignore alias entries, not
+             * returning them as part of the results.
+             */
+            if ( evaluator.isDereferencing() )
+            {
+                // advance until nothing is available or until we find a non-alias
+                while ( available = cursor.previous() )
+                {
+                    if ( db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null
)
+                    {
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                available = cursor.previous();
+            }
+
             return available;
         }
 
@@ -158,11 +180,21 @@
          * scopeCursor and try a previous call after positioning past it's
          * last element.
          */
-        if ( ! available )
+        if ( ! ( available = cursor.previous() ) )
         {
             cursor = scopeCursor;
             cursor.afterLast();
-            return available = cursor.previous();
+
+            // advance until nothing is available or until we find a non-alias
+            while ( available = cursor.previous() )
+            {
+                if ( db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                {
+                    break;
+                }
+            }
+
+            return available;
         }
 
         return true;
@@ -175,10 +207,27 @@
         if ( cursor == null )
         {
             beforeFirst();
-            return scopeCursor.next();
         }
 
-        available = cursor.next();
+        /*
+         * If dereferencing is enabled then we must ignore alias entries, not
+         * returning them as part of the results.
+         */
+        if ( evaluator.isDereferencing() )
+        {
+            // advance until nothing is available or until we find a non-alias
+            while ( available = cursor.next() )
+            {
+                if ( db.getAliasIndex().reverseLookup( cursor.get().getId() ) == null )
+                {
+                    break;
+                }
+            }
+        }
+        else
+        {
+            available = cursor.next();
+        }
 
         // if we're using dereferencedCursor (2nd) then we return the result
         if ( cursor == dereferencedCursor )

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java?rev=649879&r1=649878&r2=649879&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
Sat Apr 19 20:40:56 2008
@@ -23,7 +23,6 @@
 import org.apache.directory.shared.ldap.filter.ScopeNode;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
-import org.apache.directory.server.xdbm.Index;
 
 import javax.naming.directory.SearchControls;
 
@@ -46,11 +45,8 @@
     /** True if the scope requires alias dereferencing while searching */
     private final boolean dereferencing;
 
-    /** The alias index used for subtree scope expansion */
-    private final Index<Long,E> aliasIndex;
-
-    /** The subtree scope index for parent-descendant mappings */
-    private final Index<Long,E> scopeIndex;
+    /** The entry database/store */
+    private final Store<E> db;
 
 
     /**
@@ -62,6 +58,7 @@
      */
     public SubtreeScopeEvaluator( Store<E> db, ScopeNode node ) throws Exception
     {
+        this.db = db;
         this.node = node;
 
         if ( node.getScope() != SearchControls.SUBTREE_SCOPE )
@@ -70,10 +67,8 @@
         }
 
         baseId = db.getEntryId( node.getBaseDn() );
-        scopeIndex = db.getSubLevelIndex();
         dereferencing = node.getDerefAliases().isDerefInSearching() ||
             node.getDerefAliases().isDerefAlways();
-        aliasIndex = db.getSubAliasIndex();
     }
 
 
@@ -89,7 +84,7 @@
      */
     public boolean evaluate( IndexEntry<?,E> candidate ) throws Exception
     {
-        boolean isDescendant = scopeIndex.has( baseId, candidate.getId() );
+        boolean isDescendant = db.getSubLevelIndex().has( baseId, candidate.getId() );
 
         /*
          * The candidate id could be any entry in the db.  If search
@@ -106,7 +101,7 @@
          * candidate id is an alias, if so we reject it since aliases should
          * not be returned.
          */
-        if ( null != aliasIndex.reverseLookup( candidate.getId() ) )
+        if ( null != db.getAliasIndex().reverseLookup( candidate.getId() ) )
         {
             return false;
         }
@@ -133,7 +128,7 @@
          * the lookup returns true accepting the candidate.  Otherwise the
          * candidate is rejected with a false return because it is not in scope.
          */
-        return aliasIndex.has( baseId, candidate.getId() );
+        return db.getSubAliasIndex().has( baseId, candidate.getId() );
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java?rev=649879&r1=649878&r2=649879&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
Sat Apr 19 20:40:56 2008
@@ -856,6 +856,42 @@
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+
+        // --------- Test next() before positioning ---------
+
+        cursor = new OneLevelScopeCursor( store, evaluator );
+        assertFalse( cursor.available() );
+        cursor.next();
+
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 7L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 13L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 8L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
     }
 
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java?rev=649879&r1=649878&r2=649879&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
Sat Apr 19 20:40:56 2008
@@ -35,6 +35,8 @@
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.commons.io.FileUtils;
 import org.junit.Before;
 import org.junit.After;
@@ -285,14 +287,22 @@
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 9L, ( long ) indexEntry.getId() );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
-        assertTrue( cursor.next() );
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
+
+        // --------- Test first() ---------
+
+        cursor = new SubtreeScopeCursor( store, evaluator );
+        assertFalse( cursor.available() );
+        cursor.first();
+
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 10L, ( long ) indexEntry.getId() );
+        assertEquals( 7L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.next() );
@@ -305,11 +315,78 @@
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
 
-        // --------- Test first() ---------
+        // --------- Test afterLast() ---------
 
         cursor = new SubtreeScopeCursor( store, evaluator );
+        cursor.afterLast();
         assertFalse( cursor.available() );
-        cursor.first();
+
+        assertTrue( cursor.previous() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.previous() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 7L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertFalse( cursor.previous() );
+        assertFalse( cursor.available() );
+
+        // --------- Test last() ---------
+
+        cursor = new SubtreeScopeCursor( store, evaluator );
+        assertFalse( cursor.available() );
+        cursor.last();
+
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.previous() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 7L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertFalse( cursor.previous() );
+        assertFalse( cursor.available() );
+
+        // --------- Test previous() before positioning ---------
+
+        cursor = new SubtreeScopeCursor( store, evaluator );
+        assertFalse( cursor.available() );
+        cursor.previous();
+
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.previous() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 7L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertFalse( cursor.previous() );
+        assertFalse( cursor.available() );
+
+        // --------- Test next() before positioning ---------
+
+        cursor = new SubtreeScopeCursor( store, evaluator );
+        assertFalse( cursor.available() );
+        cursor.next();
 
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
@@ -321,14 +398,64 @@
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 9L, ( long ) indexEntry.getId() );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
+    }
+
+
+    @Test
+    public void testCursorWithDereferencing2() throws Exception
+    {
+        LdapDN dn = new LdapDN(
+            SchemaConstants.CN_AT_OID + "=jd," +
+            SchemaConstants.OU_AT_OID + "=board of directors," +
+            SchemaConstants.O_AT_OID  + "=good times co."
+        );
+        AttributesImpl attrs = new AttributesImpl( "objectClass", "alias", true );
+        attrs.get( "objectClass" ).add( "extensibleObject" );
+        attrs.put( "cn", "jd" );
+        attrs.put( "aliasedObjectName", "cn=Jack Daniels,ou=Engineering,o=Good Times Co."
);
+        store.add( dn, attrs );
+
+        dn = new LdapDN(
+            SchemaConstants.CN_AT_OID + "=jdoe," +
+            SchemaConstants.OU_AT_OID + "=board of directors," +
+            SchemaConstants.O_AT_OID  + "=good times co."
+        );
+        attrs = new AttributesImpl( "objectClass", "person", true );
+        attrs.put( "cn", "jdoe" );
+        attrs.put( "sn", "doe" );
+        store.add( dn, attrs );
+
+        ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING,
+            SchemaConstants.OU_AT_OID + "=board of directors," +
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+        SubtreeScopeEvaluator<Attributes> evaluator = new SubtreeScopeEvaluator<Attributes>(
store, node );
+        SubtreeScopeCursor cursor = new SubtreeScopeCursor( store, evaluator );
+
+        assertTrue( cursor.isElementReused() );
+
+
+        // --------- Test beforeFirst() ---------
+
+        cursor.beforeFirst();
+        assertFalse( cursor.available() );
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        IndexEntry<Long,Attributes> indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 7L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 10L, ( long ) indexEntry.getId() );
+        assertEquals( 13L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.next() );
@@ -338,6 +465,43 @@
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 8L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
+
+        // --------- Test first() ---------
+
+        cursor = new SubtreeScopeCursor( store, evaluator );
+        assertFalse( cursor.available() );
+        cursor.first();
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 13L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 8L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
 
@@ -351,21 +515,21 @@
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 8L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 10L, ( long ) indexEntry.getId() );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 9L, ( long ) indexEntry.getId() );
+        assertEquals( 13L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.previous() );
@@ -387,21 +551,21 @@
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 8L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 10L, ( long ) indexEntry.getId() );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 9L, ( long ) indexEntry.getId() );
+        assertEquals( 13L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.previous() );
@@ -423,21 +587,21 @@
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 8L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 10L, ( long ) indexEntry.getId() );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 9L, ( long ) indexEntry.getId() );
+        assertEquals( 13L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.previous() );
@@ -449,6 +613,42 @@
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+
+        // --------- Test next() before positioning ---------
+
+        cursor = new SubtreeScopeCursor( store, evaluator );
+        assertFalse( cursor.available() );
+        cursor.next();
+
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 7L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 13L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertTrue( cursor.next() );
+        assertTrue( cursor.available() );
+        indexEntry = cursor.get();
+        assertNotNull( indexEntry );
+        assertEquals( 8L, ( long ) indexEntry.getId() );
+        assertEquals( 3L, ( long ) indexEntry.getValue() );
+
+        assertFalse( cursor.next() );
+        assertFalse( cursor.available() );
     }
 
 
@@ -475,9 +675,13 @@
         SubtreeScopeEvaluator<Attributes> evaluator = new SubtreeScopeEvaluator<Attributes>(
store, node );
         assertEquals( node, evaluator.getExpression() );
 
+        /*
+         * With dereferencing the evaluator does not accept candidates that
+         * are aliases.  This is done to filter out aliases from the results.
+         */
         ForwardIndexEntry<Long,Attributes> indexEntry = new ForwardIndexEntry<Long,Attributes>();
         indexEntry.setId( 11L );
-        assertTrue( evaluator.evaluate( indexEntry ) );
+        assertFalse( evaluator.evaluate( indexEntry ) );
 
         indexEntry = new ForwardIndexEntry<Long,Attributes>();
         indexEntry.setId( 8L );



Mime
View raw message