directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r636880 - /directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
Date Thu, 13 Mar 2008 20:49:47 GMT
Author: akarasulu
Date: Thu Mar 13 13:49:46 2008
New Revision: 636880

URL: http://svn.apache.org/viewvc?rev=636880&view=rev
Log:
fixed some bugs getting tests to pass

Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java?rev=636880&r1=636879&r2=636880&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
Thu Mar 13 13:49:46 2008
@@ -28,6 +28,7 @@
 import org.apache.directory.server.core.avltree.AvlTree;
 import org.apache.directory.server.core.avltree.AvlTreeMarshaller;
 import org.apache.directory.server.core.avltree.Marshaller;
+import org.apache.directory.server.core.avltree.LinkedAvlNode;
 import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.partition.impl.btree.*;
 import org.apache.directory.server.schema.SerializableComparator;
@@ -471,19 +472,19 @@
         
         if ( values.isAvlTree() )
         {
-            AvlTree set = values.getAvlTree();
-            Object result;
+            AvlTree<V> set = values.getAvlTree();
+            LinkedAvlNode<V> result;
     
             if ( isGreaterThan )
             {
-                result = set.findGreater( val );
+                result = set.findGreaterOrEqual( val );
             }
             else
             {
-                result = set.findLess( val );
+                result = set.findLessOrEqual( val );
             }
 
-            return ( result != null );
+            return result != null;
         }
         
         // last option is to try a btree with BTreeRedirects
@@ -660,7 +661,8 @@
             {
                 BTree tree = convertToBTree( set );
                 BTreeRedirect redirect = new BTreeRedirect( tree.getRecid() );
-                replaced = ( V ) bt.insert( key, redirect, true );
+                replaced = ( V ) bt.insert( key,
+                        BTreeRedirectMarshaller.INSTANCE.serialize( redirect ), true );
             }
             else
             {
@@ -760,7 +762,7 @@
     public V remove( K key ) throws IOException
     {
         //noinspection unchecked
-        V returned = ( V ) bt.remove( key );
+        Object returned = bt.remove( key );
 
         if ( null == returned )
         {
@@ -770,18 +772,27 @@
         if ( ! allowsDuplicates )
         {
             this.count--;
-            return returned;
+            //noinspection unchecked
+            return ( V ) returned;
+        }
+
+        if ( ! ( returned instanceof byte[] ) )
+        {
+            throw new IllegalStateException( "Expecting byte[] from returned element." );
         }
 
-        if ( returned instanceof byte[] )
+        byte[] serialized = ( byte[] ) returned;
+
+        if ( BTreeRedirectMarshaller.isNotRedirect( serialized ) )
         {
             //noinspection unchecked
-            AvlTree<V> set = marshaller.deserialize( ( byte[] ) returned );
+            AvlTree<V> set = marshaller.deserialize( serialized );
             this.count -= set.getSize();
             return set.getFirst().getKey();
         }
-        
-        BTree tree = getBTree( ( BTreeRedirect ) returned );
+
+        //noinspection ConstantConditions
+        BTree tree = getBTree( BTreeRedirectMarshaller.INSTANCE.deserialize( serialized )
);
         this.count -= tree.size();
         return removeAll( tree );
     }
@@ -1026,7 +1037,7 @@
 
         if ( valueSerializer != null )
         {
-            tree = BTree.createInstance( recMan, valueComparator, valueSerializer, valueSerializer
);
+            tree = BTree.createInstance( recMan, valueComparator, valueSerializer, null );
         }
         else
         {



Mime
View raw message