directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1509944 - in /directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl: CursorBuilder.java DefaultOptimizer.java
Date Sat, 03 Aug 2013 08:55:39 GMT
Author: elecharny
Date: Sat Aug  3 08:55:39 2013
New Revision: 1509944

URL: http://svn.apache.org/r1509944
Log:
o Construct the set of candidates for the equality ExprNode, to avoid fetching it again in
the build() method

Modified:
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java?rev=1509944&r1=1509943&r2=1509944&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
Sat Aug  3 08:55:39 2013
@@ -193,6 +193,20 @@ public class CursorBuilder
     private <T> long computeEquality( EqualityNode<T> node, PartitionSearchResult
searchResult )
         throws Exception
     {
+        Set<String> thisCandidates = ( Set<String> ) node.get( "candidates" );
+
+        if ( thisCandidates != null )
+        {
+            Set<String> candidates = searchResult.getCandidateSet();
+
+            for ( String candidate : thisCandidates )
+            {
+                candidates.add( candidate );
+            }
+
+            return thisCandidates.size();
+        }
+
         AttributeType attributeType = node.getAttributeType();
         Value<T> value = node.getValue();
         int nbResults = 0;

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java?rev=1509944&r1=1509943&r2=1509944&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
Sat Aug  3 08:55:39 2013
@@ -20,9 +20,12 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.cursor.Cursor;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.filter.AndNode;
 import org.apache.directory.api.ldap.model.filter.ApproximateNode;
@@ -301,7 +304,21 @@ public class DefaultOptimizer<E> impleme
         {
             Index<V, E, String> idx = ( Index<V, E, String> ) db.getIndex( node.getAttributeType()
);
 
-            return idx.count( node.getValue().getValue() );
+            //return idx.count( node.getValue().getValue() );
+
+            Cursor<String> result = idx.forwardValueCursor( node.getValue().getValue()
);
+            Set<String> values = new HashSet<String>();
+
+            for ( String value : result )
+            {
+                values.add( value );
+            }
+
+            result.close();
+
+            node.set( "candidates", values );
+
+            return values.size();
         }
 
         // count for non-indexed attribute is unknown so we presume da worst



Mime
View raw message