Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AFA821081B for ; Sat, 3 Aug 2013 09:01:32 +0000 (UTC) Received: (qmail 31191 invoked by uid 500); 3 Aug 2013 09:01:32 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 31155 invoked by uid 500); 3 Aug 2013 09:01:32 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 31147 invoked by uid 99); 3 Aug 2013 09:01:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Aug 2013 09:01:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Aug 2013 09:01:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C68F92388ABB; Sat, 3 Aug 2013 09:01:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1509945 - /directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java Date: Sat, 03 Aug 2013 09:01:08 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130803090108.C68F92388ABB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Sat Aug 3 09:01:08 2013 New Revision: 1509945 URL: http://svn.apache.org/r1509945 Log: Limit the number of gathered candidates to 100 to avoid the construction of a huge set of candidates (for instance if the filter is something like ObjectClass=person with 1 million entries) Modified: 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/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=1509945&r1=1509944&r2=1509945&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 09:01:08 2013 @@ -304,21 +304,35 @@ public class DefaultOptimizer impleme { Index idx = ( Index ) db.getIndex( node.getAttributeType() ); - //return idx.count( node.getValue().getValue() ); - Cursor result = idx.forwardValueCursor( node.getValue().getValue() ); Set values = new HashSet(); + int nbFound = 0; for ( String value : result ) { values.add( value ); + nbFound++; + + // Arbitrary stop gathering the candidates if we have more than 100 + if ( nbFound == 100 ) + { + break; + } } result.close(); - node.set( "candidates", values ); + if ( nbFound < 100 ) + { + // Store the found candidates in the node + node.set( "candidates", values ); - return values.size(); + return values.size(); + } + else + { + return idx.count( node.getValue().getValue() ); + } } // count for non-indexed attribute is unknown so we presume da worst