You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/02/06 00:30:57 UTC

svn commit: r1657716 - in /directory/apacheds/trunk: core-integ/src/test/java/org/apache/directory/server/core/operations/search/ xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/

Author: elecharny
Date: Thu Feb  5 23:30:57 2015
New Revision: 1657716

URL: http://svn.apache.org/r1657716
Log:
Speed up searches using a MV attribute with numerous values (DIRSERVER-2048)

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndexedMVAttributeIT.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EqualityEvaluator.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndexedMVAttributeIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndexedMVAttributeIT.java?rev=1657716&r1=1657715&r2=1657716&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndexedMVAttributeIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndexedMVAttributeIT.java Thu Feb  5 23:30:57 2015
@@ -20,8 +20,7 @@
 package org.apache.directory.server.core.operations.search;
 
 
-import java.util.HashSet;
-import java.util.Set;
+import static org.junit.Assert.assertEquals;
 
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
@@ -78,8 +77,6 @@ public class SearchWithIndexedMVAttribut
         addGroupOfNames( "testGroup2", 2 );
         addGroupOfNames( "testGroup4", 4 );
         addGroupOfNames( "testGroup5", 5 );
-
-        // now, add thousands of members in some of those entries 
     }
 
 
@@ -109,48 +106,24 @@ public class SearchWithIndexedMVAttribut
     }
 
 
-    /**
-     *  Convenience method that performs a one level search using the
-     *  specified filter returning their DNs as Strings in a set.
-     *
-     * @param controls the search controls
-     * @param filter the filter expression
-     * @return the set of groups
-     * @throws Exception if there are problems conducting the search
-     */
-    public Set<String> searchGroups( String filter ) throws Exception
-    {
-        Set<String> results = new HashSet<String>();
-
-        EntryCursor cursor = connection.search( "ou=groups,ou=system", filter, SearchScope.SUBTREE, "1.1" );
-
-        while ( cursor.next() )
-        {
-            results.add( cursor.get().getDn().getName() );
-        }
-
-        cursor.close();
-
-        return results;
-    }
-
-
     @Test
     public void testSearch() throws Exception
     {
-        long t0 = System.currentTimeMillis();
+        //long t0 = System.currentTimeMillis();
         EntryCursor cursor = connection.search( "ou=system",
             "(&(member=cn=test74,ou=users,ou=system)(objectClass=groupOfNames))",
             SearchScope.SUBTREE,
             "member" );
+        int nbFound = 0;
 
         while ( cursor.next() )
         {
-            System.out.println( cursor.get().getDn() );
+            nbFound++;
         }
 
         cursor.close();
-        long t1 = System.currentTimeMillis();
-        System.out.println( "Search done in " + ( t1 - t0 ) + "msec" );
+        //long t1 = System.currentTimeMillis();
+        //System.out.println( "Search done in " + ( t1 - t0 ) + "msec" );
+        assertEquals( 4, nbFound );
     }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EqualityEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EqualityEvaluator.java?rev=1657716&r1=1657715&r2=1657716&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EqualityEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/EqualityEvaluator.java Thu Feb  5 23:30:57 2015
@@ -152,6 +152,11 @@ public class EqualityEvaluator<T> extend
     // wrapper or the raw normalized value
     private boolean evaluate( Attribute attribute ) throws LdapException
     {
+        if ( attribute.contains( node.getValue() ) )
+        {
+            return true;
+        }
+
         /*
          * Cycle through the attribute values testing normalized version
          * obtained from using the ordering or equality matching rule's