You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2008/05/30 23:00:43 UTC

svn commit: r661851 - in /directory/apacheds/branches/bigbang: btree-base/src/main/java/org/apache/directory/server/xdbm/ jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-store/src/test/java/org/apache/directory...

Author: kayyagari
Date: Fri May 30 14:00:43 2008
New Revision: 661851

URL: http://svn.apache.org/viewvc?rev=661851&view=rev
Log:
Table, JdbmTable - modified the method signatures of put() and remove() with return type void

MasterTable, JdbmMasterTable - modified the method signatures of put() and delete() with return type void

JdbmTable tests - each test using remove() or put() operation has been replaced with two lines one is with the actual method call and another for asserting its effect

Modified:
    directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/MasterTable.java
    directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Table.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
    directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java
    directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java

Modified: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/MasterTable.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/MasterTable.java?rev=661851&r1=661850&r2=661851&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/MasterTable.java (original)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/MasterTable.java Fri May 30 14:00:43 2008
@@ -51,10 +51,9 @@
      *
      * @param entry the entry to add
      * @param id unique identifier of the entry to put
-     * @return the newly created entry
      * @throws Exception if there is a write error on the underlying Db.
      */
-    E put( Long id, E entry ) throws Exception;
+    void put( Long id, E entry ) throws Exception;
 
 
     /**
@@ -64,14 +63,13 @@
      * @return the deleted entry
      * @throws Exception if there is a write error on the underlying Db
      */
-    E delete( Long id ) throws Exception;
+    void delete( Long id ) throws Exception;
 
 
     /**
      * Gets the value of the id sequence from this MasterTable's sequence
      * without affecting the value.
      *
-     * @return the current value
      * @throws Exception if the admin table storing sequences cannot be read
      */
     Long getCurrentId() throws Exception;

Modified: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Table.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Table.java?rev=661851&r1=661850&r2=661851&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Table.java (original)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/xdbm/Table.java Fri May 30 14:00:43 2008
@@ -230,25 +230,21 @@
      *
      * @param key the key of the record
      * @param value the value of the record.
-     * @return the last value present for the key or null if the key did not
-     * exist before, if the key value pair existed the same exact value object
-     * is returned
      * @throws Exception if there is a failure to read or write to the
      * underlying Db
      * @throws IllegalArgumentException if a null key or value is used
      */
-    V put( K key, V value ) throws Exception;
+    void put( K key, V value ) throws Exception;
 
 
     /**
      * Removes all records with a specified key from this Table.
      *
      * @param key the key of the records to remove
-     * @return the removed object or null if one did not exist for the key
      * @throws Exception if there is a failure to read or write to
      * the underlying Db
      */
-    V remove( K key ) throws Exception;
+    void remove( K key ) throws Exception;
 
 
     /**
@@ -257,11 +253,10 @@
      *
      * @param key the key of the record to remove
      * @param value the value of the record to remove
-     * @return the removed value object or null if one did not exist
      * @throws Exception if there is a failure to read or write to
      * the underlying Db
      */
-    V remove( K key, V value ) throws Exception;
+    void remove( K key, V value ) throws Exception;
 
 
     /**

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java?rev=661851&r1=661850&r2=661851&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java Fri May 30 14:00:43 2008
@@ -147,12 +147,11 @@
      *
      * @param entry the ServerEntry w/ operational attributes
      * @param id    the Long id of the entry to put
-     * @return the ServerEntry put
      * @throws Exception if there is a write error on the underlying Db.
      */
-    public E put( Long id, E entry ) throws Exception
+    public void put( Long id, E entry ) throws Exception
     {
-        return super.put( id, entry );
+        super.put( id, entry );
     }
 
 
@@ -160,12 +159,11 @@
      * Deletes a ServerEntry from the master table at an index specified by id.
      *
      * @param id the Long id of the entry to delete
-     * @return the Attributes of the deleted entry
      * @throws Exception if there is a write error on the underlying Db
      */
-    public E delete( Long id ) throws Exception
+    public void delete( Long id ) throws Exception
     {
-        return super.remove( id );
+        super.remove( id );
     }
 
 

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java?rev=661851&r1=661850&r2=661851&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java Fri May 30 14:00:43 2008
@@ -420,7 +420,7 @@
         if ( ! allowsDuplicates )
         {
             throw new UnsupportedOperationException( "Unfortunately this Table without duplicates enabled " +
-            		"does not contain a value comparator which is needed to answer your ordering question." );
+                    "does not contain a value comparator which is needed to answer your ordering question." );
         }
 
         DupsContainer<V> values = getDupsContainer( ( byte[] ) bt.find( key ) );
@@ -451,7 +451,7 @@
         if ( ! allowsDuplicates )
         {
             throw new UnsupportedOperationException( "Unfortunately this Table without duplicates enabled " +
-            		"does not contain a value comparator which is needed to answer your ordering question." );
+                    "does not contain a value comparator which is needed to answer your ordering question." );
         }
 
         DupsContainer<V> values = getDupsContainer( ( byte[] ) bt.find( key ) );
@@ -584,7 +584,7 @@
      * java.lang.Object)
      */
     @SuppressWarnings("unchecked")
-    public V put( K key, V value ) throws Exception
+    public void put( K key, V value ) throws Exception
     {
         if ( value == null || key == null )
         {
@@ -602,7 +602,7 @@
                 count++;
             }
 
-            return replaced;
+            return;
         }
         
         DupsContainer<V> values = getDupsContainer( ( byte[] ) bt.find( key ) );
@@ -613,7 +613,7 @@
             
             if ( replaced != null )// if the value already present returns the same value
             {
-                return value;
+                return;
             }
             
             if ( set.getSize() > numDupLimit )
@@ -628,7 +628,7 @@
             }
 
             count++;
-            return replaced;
+            return;
         }
         
         BTree tree = getBTree( values.getBTreeRedirect() );
@@ -638,7 +638,6 @@
         {
             count++;
         }
-        return replaced;
     }
     
 
@@ -646,11 +645,11 @@
      * @see org.apache.directory.server.xdbm.Table#remove(java.lang.Object,
      * java.lang.Object)
      */
-    public V remove( K key, V value ) throws IOException
+    public void remove( K key, V value ) throws IOException
     {
         if ( key == null )
         {
-            return null;
+            return;
         }
 
         if ( ! allowsDuplicates )
@@ -663,10 +662,10 @@
             {
                 bt.remove( key );
                 count--;
-                return oldValue;
+                return;
             }
 
-            return null;
+            return;
         }
 
         DupsContainer<V> values = getDupsContainer( ( byte[] ) bt.find( key ) );
@@ -686,10 +685,10 @@
                     bt.insert( key, marshaller.serialize( set ), true );
                 }
                 count--;
-                return value;
+                return;
             }
 
-            return null;
+            return;
         }
 
         // if the number of duplicates falls below the numDupLimit value
@@ -708,35 +707,32 @@
             }
             
             count--;
-            return value;
         }
         
-        return null;
     }
 
 
     /**
      * @see Table#remove(Object)
      */
-    public V remove( K key ) throws IOException
+    public void remove( K key ) throws IOException
     {
         if ( key == null )
         {
-            return null;
+            return;
         }
 
         Object returned = bt.remove( key );
 
         if ( null == returned )
         {
-            return null;
+            return;
         }
 
         if ( ! allowsDuplicates )
         {
             this.count--;
-            //noinspection unchecked
-            return ( V ) returned;
+            return;
         }
 
         byte[] serialized = ( byte[] ) returned;
@@ -745,13 +741,13 @@
         {
             BTree tree = getBTree( BTreeRedirectMarshaller.INSTANCE.deserialize( serialized ) );
             this.count -= tree.size();
-            return removeAll( tree );
+            return;
         }
         else
         {
             AvlTree<V> set = marshaller.deserialize( serialized );
             this.count -= set.getSize();
-            return set.getFirst().getKey();
+            return;
         }
     }
 

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java?rev=661851&r1=661850&r2=661851&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDuplicatesTest.java Fri May 30 14:00:43 2008
@@ -148,7 +148,8 @@
         assertNull( table.get( 0 ) );
         
         // Test remove methods
-        assertNull( table.remove( 1 ) );
+        table.remove( 1 );
+        assertNull( table.get( 1 ) );
         
         // Test has operations
         assertFalse( table.has( 1 ) );
@@ -256,11 +257,16 @@
     public void testRemove() throws Exception
     {
         table.put( 1, 1 );
-        assertEquals( 1, ( int ) table.remove( 1 ) );
+        table.remove( 1 );
+        assertNull( table.get( 1 ) );
+
         table.put( 10, 10 );
-        assertNull( table.remove( 10, 11 ) );
-        assertNull( table.remove( null ) );
-        assertNull( table.remove( null, null ) );
+        
+        table.remove( 10, 11 );
+        assertFalse( table.has( 10, 11 ) );
+        
+//        assertNull( table.remove( null ) );
+//        assertNull( table.remove( null, null ) );
     }
 
 
@@ -274,7 +280,8 @@
             table.put( ii, ii );
         }
         assertEquals( SIZE, table.count() );
-        assertNotNull( table.put( 0, 0 ) );
+        table.put( 0, 0 );
+        assertTrue( table.has( 0, 0 ) );
     }
     
 

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java?rev=661851&r1=661850&r2=661851&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableWithDuplicatesTest.java Fri May 30 14:00:43 2008
@@ -199,7 +199,8 @@
         assertNull( table.get( null ) );
 
         // Test remove methods
-        assertNull( table.remove( 1 ) );
+        table.remove( 1 );
+        assertFalse( table.has( 1 ) );
         
         // Test has operations
         assertFalse( table.has( 1 ) );
@@ -221,7 +222,8 @@
             table.put( ii, ii );
         }
         assertEquals( SIZE, table.count() );
-        assertNotNull( table.put( 0, 0 ) );
+        table.put( 0, 0 );
+        assertTrue( table.has( 0, 0 ) );
 
         // add some duplicates
         for ( int ii = 0; ii < SIZE*2; ii++ )
@@ -229,8 +231,12 @@
             table.put( SIZE*2, ii );
         }
         assertEquals( SIZE*3, table.count() );
-        assertNotNull( table.put( 0, 0 ) );
-        assertNotNull( table.put( SIZE*2, 0 ) );
+        
+        table.put( 0, 0 );
+        assertTrue( table.has( 0, 0 ) );
+        
+        table.put( SIZE*2, 0 );
+        assertTrue( table.has( SIZE*2, 0 ) );
     }
 
 
@@ -345,14 +351,17 @@
         table.put( 1, 1 );
         table.put( 1, 2 );
         assertEquals( 2, table.count() );
-        assertEquals( 1, ( int ) table.remove( 1 ) );
+        table.remove( 1 );
+        assertFalse( table.has( 1 ) );
         assertEquals( 0, table.count() );
 
         table.put( 10, 10 );
         assertEquals( 1, table.count() );
-        assertNull( table.remove( 10, 11 ) );
+        table.remove( 10, 11 );
+        assertFalse( table.has( 10, 11 ) );
         assertEquals( 1, table.count() );
-        assertNotNull( table.remove( 10, 10 ) );
+        table.remove( 10, 10 );
+        assertFalse( table.has( 10, 10 ) );
         assertEquals( 0, table.count() );
 
         // add duplicates
@@ -362,10 +371,12 @@
         }
 
         assertEquals( SIZE*2, table.count() );
-        assertNull( table.remove( 0, 100 ) );
+        table.remove( 0, 100 );
+        assertFalse( table.has( 0, 100 ) );
         assertEquals( SIZE*2, table.count() );
-
-        assertEquals( 0, ( int ) table.remove( 0 ) );
+        
+        table.remove( 0 );
+        assertNull( table.get( 0 ) );
     }
     
     
@@ -516,7 +527,8 @@
         {
             table.put( 0, ii );
         }
-        assertEquals( 0, ( int ) table.remove( 0 ) );
+        table.remove( 0 );
+        assertFalse( table.has( 0 ) );
     }