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 2013/08/02 13:30:43 UTC
svn commit: r1509638 -
/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java
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<K, V> 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<K, V> extends
try
{
- if ( !bt.hasKey( key ) )
+ if ( !allowsDuplicates )
+ {
+ V val = bt.get( key );
+
+ return new SingletonCursor<Tuple<K, V>>(
+ new Tuple<K, V>( key, val ) );
+ }
+ else
+ {
+ BTree<V, V> dups = bt.getValues( key );
+
+ return new KeyTupleArrayCursor<K, V>( dups, key );
+ }
+ }
+ catch ( KeyNotFoundException knfe )
+ {
+ return new EmptyCursor<Tuple<K, V>>();
+ }
+ catch ( Exception e )
+ {
+ throw new LdapException( e );
+ }
+ }
+
+
+ /*
+ if ( !bt.hasKey( key ) )
{
return new EmptyCursor<Tuple<K, V>>();
}
@@ -437,7 +477,7 @@ public class MavibotTable<K, V> extends
throw new LdapException( e );
}
}
-
+ */
@Override
public Cursor<V> valueCursor( K key ) throws Exception
@@ -479,6 +519,27 @@ public class MavibotTable<K, V> extends
return 0;
}
+ try
+ {
+ if ( bt.isAllowDuplicates() )
+ {
+ BTree<V, V> 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<K, V> extends
}
return 0;
+ */
}