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 9EAC110D62 for ; Fri, 2 Aug 2013 11:31:05 +0000 (UTC) Received: (qmail 38774 invoked by uid 500); 2 Aug 2013 11:31:05 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 38633 invoked by uid 500); 2 Aug 2013 11:31:05 -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 38626 invoked by uid 99); 2 Aug 2013 11:31:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Aug 2013 11:31:04 +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; Fri, 02 Aug 2013 11:31:03 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8A40423888E2; Fri, 2 Aug 2013 11:30:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1509638 - /directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java Date: Fri, 02 Aug 2013 11:30:43 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130802113043.8A40423888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Fri Aug 2 11:30:43 2013 New Revision: 1509638 URL: http://svn.apache.org/r1509638 Log: o The get(key), cursor() and count() methodsnow avoiding doing a call to haskey() Modified: directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java Modified: directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java?rev=1509638&r1=1509637&r2=1509638&view=diff ============================================================================== --- directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java (original) +++ directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java Fri Aug 2 11:30:43 2013 @@ -35,6 +35,7 @@ import org.apache.directory.server.xdbm. import org.apache.mavibot.btree.BTree; import org.apache.mavibot.btree.RecordManager; import org.apache.mavibot.btree.exception.BTreeAlreadyManagedException; +import org.apache.mavibot.btree.exception.KeyNotFoundException; import org.apache.mavibot.btree.serializer.ElementSerializer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -305,17 +306,30 @@ public class MavibotTable extends try { - if ( bt.hasKey( key ) ) - { - return bt.get( key ); - } + return bt.get( key ); + } + catch ( KeyNotFoundException knfe ) + { + return null; } catch ( Exception e ) { throw new LdapException( e ); } - return null; + // try + // { + // if ( bt.hasKey( key ) ) + // { + // return bt.get( key ); + // } + // } + // catch ( Exception e ) + // { + // throw new LdapException( e ); + // } + // + // return null; } @@ -416,7 +430,33 @@ public class MavibotTable extends try { - if ( !bt.hasKey( key ) ) + if ( !allowsDuplicates ) + { + V val = bt.get( key ); + + return new SingletonCursor>( + new Tuple( key, val ) ); + } + else + { + BTree dups = bt.getValues( key ); + + return new KeyTupleArrayCursor( dups, key ); + } + } + catch ( KeyNotFoundException knfe ) + { + return new EmptyCursor>(); + } + catch ( Exception e ) + { + throw new LdapException( e ); + } + } + + + /* + if ( !bt.hasKey( key ) ) { return new EmptyCursor>(); } @@ -437,7 +477,7 @@ public class MavibotTable extends throw new LdapException( e ); } } - + */ @Override public Cursor valueCursor( K key ) throws Exception @@ -479,6 +519,27 @@ public class MavibotTable extends return 0; } + try + { + if ( bt.isAllowDuplicates() ) + { + BTree values = bt.getValues( key ); + + return values.getNbElems(); + } + else + { + bt.get( key ); + + return 1; + } + } + catch ( KeyNotFoundException knfe ) + { + return 0L; + } + + /* if ( bt.hasKey( key ) ) { if ( !allowsDuplicates ) @@ -493,6 +554,7 @@ public class MavibotTable extends } return 0; + */ }