From commits-return-12792-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Mon Mar 12 22:54:40 2007 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 14298 invoked from network); 12 Mar 2007 22:54:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Mar 2007 22:54:35 -0000 Received: (qmail 70692 invoked by uid 500); 12 Mar 2007 22:54:33 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 70638 invoked by uid 500); 12 Mar 2007 22:54:33 -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 70600 invoked by uid 99); 12 Mar 2007 22:54:32 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Mar 2007 15:54:32 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Mar 2007 15:54:21 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 51ED61A983E; Mon, 12 Mar 2007 15:54:01 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r517448 [2/3] - in /directory/apacheds/trunk: bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ core-unit/src/test/java/org/apac... Date: Mon, 12 Mar 2007 22:53:58 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070312225401.51ED61A983E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsBTreeTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsBTreeTest.java?view=diff&rev=517448&r1=517447&r2=517448 ============================================================================== --- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsBTreeTest.java (original) +++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsBTreeTest.java Mon Mar 12 15:53:56 2007 @@ -22,7 +22,6 @@ import java.io.File; import java.io.Serializable; -import java.math.BigInteger; import javax.naming.NamingEnumeration; import javax.naming.NamingException; @@ -31,7 +30,7 @@ import org.apache.directory.server.core.partition.impl.btree.TupleComparator; import org.apache.directory.server.schema.SerializableComparator; import org.apache.directory.shared.ldap.util.ArrayEnumeration; -import org.apache.directory.shared.ldap.util.BigIntegerComparator; +import org.apache.directory.shared.ldap.util.LongComparator; import jdbm.RecordManager; import jdbm.recman.BaseRecordManager; @@ -50,7 +49,7 @@ private static final long serialVersionUID = 1L; private transient File tempFile = null; private transient RecordManager rm = null; - private final BigIntegerComparator biComparator = new BigIntegerComparator(); + private final LongComparator biComparator = new LongComparator(); private final SerializableComparator serializableComparator = new SerializableComparator( "integerMatchingRule" ) { private static final long serialVersionUID = 1L; @@ -110,14 +109,14 @@ // make sure the table never uses a btree for duplicates table = new JdbmTable( "test", true, 1, rm, comparator ); - for ( BigInteger ii = BigInteger.ZERO; ii.intValue() < 3; ii = ii.add( BigInteger.ONE ) ) + for ( Long ii = 0L; ii.intValue() < 3; ii++ ) { - table.put( BigInteger.ONE, ii ); + table.put( 1L, ii ); } - table.put( new BigInteger( "2" ), BigInteger.ONE ); - table.put( new BigInteger( "4" ), BigInteger.ONE ); - table.put( new BigInteger( "5" ), BigInteger.ONE ); + table.put( 2L, 1L ); + table.put( 4L, 1L ); + table.put( 5L, 1L ); } protected void tearDown() throws Exception @@ -142,40 +141,40 @@ public void testHas() throws Exception { // test the has( Object ) method - assertTrue( table.has( BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("2") ) ); - assertTrue( table.has( new BigInteger("4") ) ); - assertTrue( table.has( new BigInteger("5") ) ); - assertFalse( table.has( new BigInteger("3") ) ); - assertFalse( table.has( BigInteger.ZERO ) ); - assertFalse( table.has( new BigInteger( "999" ) ) ); + assertTrue( table.has( 1L ) ); + assertTrue( table.has( 2L ) ); + assertTrue( table.has( 4L ) ); + assertTrue( table.has( 5L ) ); + assertFalse( table.has( 3L ) ); + assertFalse( table.has( 0L ) ); + assertFalse( table.has( 999L ) ); // test the has( Object, Object ) method - assertTrue( table.has( BigInteger.ONE, BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("2"), BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("4"), BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("5"), BigInteger.ONE ) ); - assertFalse( table.has( new BigInteger("5"), BigInteger.ZERO ) ); - assertFalse( table.has( new BigInteger("3"), BigInteger.ONE ) ); - assertFalse( table.has( BigInteger.ONE, new BigInteger("999") ) ); - assertFalse( table.has( new BigInteger( "999" ), BigInteger.ONE ) ); + assertTrue( table.has( 1L, 1L ) ); + assertTrue( table.has( 2L, 1L ) ); + assertTrue( table.has( 4L, 1L ) ); + assertTrue( table.has( 5L, 1L ) ); + assertFalse( table.has( 5L, 0L ) ); + assertFalse( table.has( 3L, 1L ) ); + assertFalse( table.has( 1L, 999L ) ); + assertFalse( table.has( 999L, 1L ) ); // test the has( Object, boolean ) method - assertFalse( table.has( BigInteger.ZERO, false ) ); // we do not have a key less than or equal to 0 - assertTrue( table.has( BigInteger.ONE, false ) ); // we do have a key less than or equal to 1 - assertTrue( table.has( BigInteger.ZERO, true ) ); // we do have a key greater than or equal to 0 - assertTrue( table.has( BigInteger.ONE, true ) ); // we do have a key greater than or equal to 1 - assertTrue( table.has( new BigInteger( "5" ), true ) ); // we do have a key greater than or equal to 5 - assertFalse( table.has( new BigInteger( "6" ), true ) ); // we do NOT have a key greater than or equal to 11 - assertFalse( table.has( new BigInteger( "999" ), true ) ); // we do NOT have a key greater than or equal to 12 + assertFalse( table.has( Long.valueOf( 0L ), false ) ); // we do not have a key less than or equal to 0 + assertTrue( table.has( Long.valueOf( 1L ), false ) ); // we do have a key less than or equal to 1 + assertTrue( table.has( Long.valueOf( 0L ), true ) ); // we do have a key greater than or equal to 0 + assertTrue( table.has( Long.valueOf( 1L ), true ) ); // we do have a key greater than or equal to 1 + assertTrue( table.has( Long.valueOf( 5L ), true ) ); // we do have a key greater than or equal to 5 + assertFalse( table.has( Long.valueOf( 6L ), true ) ); // we do NOT have a key greater than or equal to 11 + assertFalse( table.has( Long.valueOf( 999L ), true ) ); // we do NOT have a key greater than or equal to 12 // test the has( Object, Object, boolean ) method - assertTrue( table.has( BigInteger.ONE, BigInteger.ZERO, true ) ); - assertTrue( table.has( BigInteger.ONE, BigInteger.ONE, true ) ); - assertTrue( table.has( BigInteger.ONE, new BigInteger("2"), true ) ); - assertFalse( table.has( BigInteger.ONE, new BigInteger("3"), true ) ); - assertTrue( table.has( BigInteger.ONE, BigInteger.ZERO, false ) ); - assertFalse( table.has( BigInteger.ONE, new BigInteger("-1"), false ) ); + assertTrue( table.has( 1L, 0L, true ) ); + assertTrue( table.has( 1L, 1L, true ) ); + assertTrue( table.has( 1L, 2L, true ) ); + assertFalse( table.has( 1L, 3L, true ) ); + assertTrue( table.has( 1L, 0L, false ) ); + assertFalse( table.has( 1L, -1L, false ) ); } @@ -195,13 +194,13 @@ assertEquals( 6, table.count() ); // test the count(Object) method - assertEquals( 3, table.count( BigInteger.ONE ) ); - assertEquals( 0, table.count( BigInteger.ZERO ) ); - assertEquals( 1, table.count( new BigInteger( "2" ) ) ); + assertEquals( 3, table.count( 1L ) ); + assertEquals( 0, table.count( 0L ) ); + assertEquals( 1, table.count( 2L ) ); // test the count( Object, boolean ) method // note for speed this count method returns the same as count() - assertEquals( table.count(), table.count( BigInteger.ONE, true ) ); + assertEquals( table.count(), table.count( 1L, true ) ); } @@ -212,11 +211,11 @@ */ public void testGet() throws Exception { - assertEquals( BigInteger.ZERO, table.get( BigInteger.ONE ) ); - assertEquals( BigInteger.ONE, table.get( new BigInteger( "2" ) ) ); - assertEquals( null, table.get( new BigInteger( "3" ) ) ); - assertEquals( BigInteger.ONE, table.get( new BigInteger( "4" ) ) ); - assertEquals( BigInteger.ONE, table.get( new BigInteger( "5" ) ) ); + assertEquals( 0L, table.get( 1L ) ); + assertEquals( 1L, table.get( 2L ) ); + assertEquals( null, table.get( 3L ) ); + assertEquals( 1L, table.get( 4L ) ); + assertEquals( 1L, table.get( 5L ) ); } @@ -243,33 +242,33 @@ assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "4" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 4L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "5" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 5L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); @@ -277,31 +276,31 @@ // test the listTuples(Object) method // ------------------------------------------------------------------- - tuples = table.listTuples( BigInteger.ZERO ); + tuples = table.listTuples( 0L ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ) ); + tuples = table.listTuples( 2L ); assertTrue( tuples.hasMore() ); tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE ); + tuples = table.listTuples( 1L ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertFalse( tuples.hasMore() ); @@ -309,141 +308,141 @@ // test the listTuples(Object, boolean) method // ------------------------------------------------------------------- - tuples = table.listTuples( BigInteger.ZERO, false ); + tuples = table.listTuples( 0L, false ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, false ); + tuples = table.listTuples( 1L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), false ); + tuples = table.listTuples( 2L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "6" ), true ); + tuples = table.listTuples( 6L, true ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "5" ), true ); + tuples = table.listTuples( 5L, true ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "5" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 5L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "4" ), true ); + tuples = table.listTuples( 4L, true ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "4" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 4L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "5" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 5L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); // ------------------------------------------------------------------- // test the listTuples(Object,Object,boolean) method // ------------------------------------------------------------------- - tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, true ); + tuples = table.listTuples( 0L, 0L, true ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, false ); + tuples = table.listTuples( 0L, 0L, false ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), BigInteger.ZERO, false ); + tuples = table.listTuples( 2L, 0L, false ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), new BigInteger( "99" ), true ); + tuples = table.listTuples( 2L, 99L, true ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), BigInteger.ONE, false ); + tuples = table.listTuples( 2L, 1L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), new BigInteger( "99" ), false ); + tuples = table.listTuples( 2L, 99L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, new BigInteger( "3" ), true ); + tuples = table.listTuples( 1L, 3L, true ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, new BigInteger( "-1" ), false ); + tuples = table.listTuples( 1L, -1L, false ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, new BigInteger( "1" ), true ); + tuples = table.listTuples( 1L, 1L, true ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, new BigInteger( "1" ), false ); + tuples = table.listTuples( 1L, 1L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertFalse( tuples.hasMore() ); @@ -459,27 +458,27 @@ // test the listValues(Object) method // ------------------------------------------------------------------- - NamingEnumeration values = table.listValues( BigInteger.ZERO ); + NamingEnumeration values = table.listValues( 0L ); assertFalse( values.hasMore() ); - values = table.listValues( new BigInteger( "2" ) ); + values = table.listValues( 2L ); assertTrue( values.hasMore() ); Object value = values.next(); - assertEquals( BigInteger.ONE, value ); + assertEquals( 1L, value ); assertFalse( values.hasMore() ); - values = table.listValues( BigInteger.ONE ); + values = table.listValues( 1L ); assertTrue( values.hasMore() ) ; value = values.next(); - assertEquals( BigInteger.ZERO, value ); + assertEquals( 0L, value ); assertTrue( values.hasMore() ) ; value = values.next(); - assertEquals( BigInteger.ONE, value ); + assertEquals( 1L, value ); assertTrue( values.hasMore() ) ; value = values.next(); - assertEquals( new BigInteger( "2" ), value ); + assertEquals( 2L, value ); assertFalse( values.hasMore() ); } @@ -498,63 +497,63 @@ // this instead tests the NamingEnumeration overload NamingEnumeration values = new ArrayNE( new Object[] { - new BigInteger( "3" ), - new BigInteger( "4" ), - new BigInteger( "5" ), - new BigInteger( "6" ), + 3L, + 4L, + 5L, + 6L, } ); - table.put( BigInteger.ONE, values ); + table.put( 1L, values ); assertFalse( values.hasMore() ); - values = table.listValues( BigInteger.ONE ); + values = table.listValues( 1L ); assertTrue( values.hasMore() ); - assertEquals( BigInteger.ZERO, values.next() ); + assertEquals( 0L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( BigInteger.ONE, values.next() ); + assertEquals( 1L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "2" ), values.next() ); + assertEquals( 2L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "3" ), values.next() ); + assertEquals( 3L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "4" ), values.next() ); + assertEquals( 4L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "5" ), values.next() ); + assertEquals( 5L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "6" ), values.next() ); + assertEquals( 6L, values.next() ); assertFalse( values.hasMore() ); values = new ArrayNE( new Object[] { - new BigInteger( "3" ), - new BigInteger( "4" ), - new BigInteger( "5" ), - new BigInteger( "6" ), + 3L, + 4L, + 5L, + 6L, } ); - table.put( BigInteger.ZERO, values ); + table.put( 0L, values ); assertFalse( values.hasMore() ); - values = table.listValues( BigInteger.ZERO ); + values = table.listValues( 0L ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "3" ), values.next() ); + assertEquals( 3L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "4" ), values.next() ); + assertEquals( 4L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "5" ), values.next() ); + assertEquals( 5L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "6" ), values.next() ); + assertEquals( 6L, values.next() ); assertFalse( values.hasMore() ); } @@ -570,19 +569,19 @@ try { - table.remove( BigInteger.ZERO ); + table.remove( 0L ); fail( "should not get here trying to remove non-existent key" ); } catch ( IllegalArgumentException e ) { } - Object value = table.remove( new BigInteger( "2" ) ); - assertEquals( BigInteger.ONE, value ); + Object value = table.remove( 2L ); + assertEquals( 1L, value ); assertEquals( 5, table.count() ); - value = table.remove( BigInteger.ONE ); - assertEquals( BigInteger.ZERO, value ); // return first value of dups + value = table.remove( 1L ); + assertEquals( 0L, value ); // return first value of dups assertEquals( 2, table.count() ); } @@ -596,15 +595,15 @@ // tests the remove(Object) method // ------------------------------------------------------------------- - Object value = table.remove( BigInteger.ZERO, BigInteger.ZERO ); + Object value = table.remove( 0L, 0L ); assertNull( value ); - value = table.remove( new BigInteger( "2" ), BigInteger.ONE ); - assertEquals( BigInteger.ONE, value ); + value = table.remove( 2L, 1L ); + assertEquals( 1L, value ); assertEquals( 5, table.count() ); - value = table.remove( BigInteger.ONE, new BigInteger( "2" ) ); - assertEquals( new BigInteger( "2" ), value ); + value = table.remove( 1L, 2L ); + assertEquals( 2L, value ); assertEquals( 4, table.count() ); } @@ -615,12 +614,12 @@ public void testRemoveObjectNamingEnumeration() throws Exception { NamingEnumeration values = new ArrayNE( new Object[] { - new BigInteger( "1" ), - new BigInteger( "2" ) + 1L, + 2L } ); - Object value = table.remove( BigInteger.ONE, values ); - assertEquals( BigInteger.ONE, value ); + Object value = table.remove( 1L, values ); + assertEquals( 1L, value ); assertEquals( 4, table.count() ); } Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsTreeSetTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsTreeSetTest.java?view=diff&rev=517448&r1=517447&r2=517448 ============================================================================== --- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsTreeSetTest.java (original) +++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableDupsTreeSetTest.java Mon Mar 12 15:53:56 2007 @@ -22,7 +22,6 @@ import java.io.File; import java.io.Serializable; -import java.math.BigInteger; import javax.naming.NamingEnumeration; import javax.naming.NamingException; @@ -31,7 +30,7 @@ import org.apache.directory.server.core.partition.impl.btree.TupleComparator; import org.apache.directory.server.schema.SerializableComparator; import org.apache.directory.shared.ldap.util.ArrayEnumeration; -import org.apache.directory.shared.ldap.util.BigIntegerComparator; +import org.apache.directory.shared.ldap.util.LongComparator; import jdbm.RecordManager; import jdbm.recman.BaseRecordManager; @@ -50,7 +49,7 @@ private static final long serialVersionUID = 1L; private transient File tempFile = null; private transient RecordManager rm = null; - private final BigIntegerComparator biComparator = new BigIntegerComparator(); + private final LongComparator biComparator = new LongComparator(); private final SerializableComparator serializableComparator = new SerializableComparator( "integerMatchingRule" ) { private static final long serialVersionUID = 1L; @@ -110,14 +109,14 @@ // make sure the table never uses a btree for duplicates table = new JdbmTable( "test", true, Integer.MAX_VALUE, rm, comparator ); - for ( BigInteger ii = BigInteger.ZERO; ii.intValue() < 3; ii = ii.add( BigInteger.ONE ) ) + for ( Long ii = 0L; ii.intValue() < 3; ii++ ) { - table.put( BigInteger.ONE, ii ); + table.put( 1L, ii ); } - table.put( new BigInteger( "2" ), BigInteger.ONE ); - table.put( new BigInteger( "4" ), BigInteger.ONE ); - table.put( new BigInteger( "5" ), BigInteger.ONE ); + table.put( 2L, 1L ); + table.put( 4L, 1L ); + table.put( 5L, 1L ); } protected void tearDown() throws Exception @@ -143,40 +142,40 @@ public void testHas() throws Exception { // test the has( Object ) method - assertTrue( table.has( BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("2") ) ); - assertTrue( table.has( new BigInteger("4") ) ); - assertTrue( table.has( new BigInteger("5") ) ); - assertFalse( table.has( new BigInteger("3") ) ); - assertFalse( table.has( BigInteger.ZERO ) ); - assertFalse( table.has( new BigInteger( "999" ) ) ); + assertTrue( table.has( 1L ) ); + assertTrue( table.has( 2L ) ); + assertTrue( table.has( 4L ) ); + assertTrue( table.has( 5L ) ); + assertFalse( table.has( 3L ) ); + assertFalse( table.has( 0L ) ); + assertFalse( table.has( 999L ) ); // test the has( Object, Object ) method - assertTrue( table.has( BigInteger.ONE, BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("2"), BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("4"), BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("5"), BigInteger.ONE ) ); - assertFalse( table.has( new BigInteger("5"), BigInteger.ZERO ) ); - assertFalse( table.has( new BigInteger("3"), BigInteger.ONE ) ); - assertFalse( table.has( BigInteger.ONE, new BigInteger("999") ) ); - assertFalse( table.has( new BigInteger( "999" ), BigInteger.ONE ) ); + assertTrue( table.has( 1L, 1L ) ); + assertTrue( table.has( 2L, 1L ) ); + assertTrue( table.has( 4L, 1L ) ); + assertTrue( table.has( 5L, 1L ) ); + assertFalse( table.has( 5L, 0L ) ); + assertFalse( table.has( 3L, 1L ) ); + assertFalse( table.has( 1L, 999L ) ); + assertFalse( table.has( 999L, 1L ) ); // test the has( Object, boolean ) method - assertFalse( table.has( BigInteger.ZERO, false ) ); // we do not have a key less than or equal to 0 - assertTrue( table.has( BigInteger.ONE, false ) ); // we do have a key less than or equal to 1 - assertTrue( table.has( BigInteger.ZERO, true ) ); // we do have a key greater than or equal to 0 - assertTrue( table.has( BigInteger.ONE, true ) ); // we do have a key greater than or equal to 1 - assertTrue( table.has( new BigInteger( "5" ), true ) ); // we do have a key greater than or equal to 5 - assertFalse( table.has( new BigInteger( "6" ), true ) ); // we do NOT have a key greater than or equal to 11 - assertFalse( table.has( new BigInteger( "999" ), true ) ); // we do NOT have a key greater than or equal to 12 + assertFalse( table.has( Long.valueOf( 0 ), false ) ); // we do not have a key less than or equal to 0 + assertTrue( table.has( Long.valueOf( 1 ), false ) ); // we do have a key less than or equal to 1 + assertTrue( table.has( Long.valueOf( 0 ), true ) ); // we do have a key greater than or equal to 0 + assertTrue( table.has( Long.valueOf( 1 ), true ) ); // we do have a key greater than or equal to 1 + assertTrue( table.has( Long.valueOf( 5 ), true ) ); // we do have a key greater than or equal to 5 + assertFalse( table.has( Long.valueOf( 6 ), true ) ); // we do NOT have a key greater than or equal to 11 + assertFalse( table.has( Long.valueOf( 999 ), true ) ); // we do NOT have a key greater than or equal to 12 // test the has( Object, Object, boolean ) method - assertTrue( table.has( BigInteger.ONE, BigInteger.ZERO, true ) ); - assertTrue( table.has( BigInteger.ONE, BigInteger.ONE, true ) ); - assertTrue( table.has( BigInteger.ONE, new BigInteger("2"), true ) ); - assertFalse( table.has( BigInteger.ONE, new BigInteger("3"), true ) ); - assertTrue( table.has( BigInteger.ONE, BigInteger.ZERO, false ) ); - assertFalse( table.has( BigInteger.ONE, new BigInteger("-1"), false ) ); + assertTrue( table.has( 1L, 0L, true ) ); + assertTrue( table.has( 1L, 1L, true ) ); + assertTrue( table.has( 1L, 2L, true ) ); + assertFalse( table.has( 1L, 3L, true ) ); + assertTrue( table.has( 1L, 0L, false ) ); + assertFalse( table.has( 1L, -1L, false ) ); } @@ -196,13 +195,13 @@ assertEquals( 6, table.count() ); // test the count(Object) method - assertEquals( 3, table.count( BigInteger.ONE ) ); - assertEquals( 0, table.count( BigInteger.ZERO ) ); - assertEquals( 1, table.count( new BigInteger( "2" ) ) ); + assertEquals( 3, table.count( 1L ) ); + assertEquals( 0, table.count( 0L ) ); + assertEquals( 1, table.count( 2L ) ); // test the count( Object, boolean ) method // note for speed this count method returns the same as count() - assertEquals( table.count(), table.count( BigInteger.ONE, true ) ); + assertEquals( table.count(), table.count( 1L, true ) ); } @@ -213,11 +212,11 @@ */ public void testGet() throws Exception { - assertEquals( BigInteger.ZERO, table.get( BigInteger.ONE ) ); - assertEquals( BigInteger.ONE, table.get( new BigInteger( "2" ) ) ); - assertEquals( null, table.get( new BigInteger( "3" ) ) ); - assertEquals( BigInteger.ONE, table.get( new BigInteger( "4" ) ) ); - assertEquals( BigInteger.ONE, table.get( new BigInteger( "5" ) ) ); + assertEquals( 0L, table.get( 1L ) ); + assertEquals( 1L, table.get( 2L ) ); + assertEquals( null, table.get( 3L ) ); + assertEquals( 1L, table.get( 4L ) ); + assertEquals( 1L, table.get( 5L ) ); } @@ -244,33 +243,33 @@ assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "4" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 4L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "5" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 5L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); @@ -278,31 +277,31 @@ // test the listTuples(Object) method // ------------------------------------------------------------------- - tuples = table.listTuples( BigInteger.ZERO ); + tuples = table.listTuples( 0L ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ) ); + tuples = table.listTuples( 2L ); assertTrue( tuples.hasMore() ); tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE ); + tuples = table.listTuples( 1L ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertFalse( tuples.hasMore() ); @@ -310,141 +309,141 @@ // test the listTuples(Object, boolean) method // ------------------------------------------------------------------- - tuples = table.listTuples( BigInteger.ZERO, false ); + tuples = table.listTuples( 0L, false ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, false ); + tuples = table.listTuples( 1L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), false ); + tuples = table.listTuples( 2L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "6" ), true ); + tuples = table.listTuples( 6L, true ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "5" ), true ); + tuples = table.listTuples( 5L, true ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "5" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 5L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "4" ), true ); + tuples = table.listTuples( 4L, true ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "4" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 4L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "5" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 5L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); // ------------------------------------------------------------------- // test the listTuples(Object,Object,boolean) method // ------------------------------------------------------------------- - tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, true ); + tuples = table.listTuples( 0L, 0L, true ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, false ); + tuples = table.listTuples( 0L, 0L, false ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), BigInteger.ZERO, false ); + tuples = table.listTuples( 2L, 0L, false ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), new BigInteger( "99" ), true ); + tuples = table.listTuples( 2L, 99L, true ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), BigInteger.ONE, false ); + tuples = table.listTuples( 2L, 1L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), new BigInteger( "99" ), false ); + tuples = table.listTuples( 2L, 99L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, new BigInteger( "3" ), true ); + tuples = table.listTuples( 1L, 3L, true ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, new BigInteger( "-1" ), false ); + tuples = table.listTuples( 1L, -1L, false ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, new BigInteger( "1" ), true ); + tuples = table.listTuples( 1L, 1L, true ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "2" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 2L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, new BigInteger( "1" ), false ); + tuples = table.listTuples( 1L, 1L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ZERO, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 0L, tuple.getValue() ); assertFalse( tuples.hasMore() ); @@ -460,27 +459,27 @@ // test the listValues(Object) method // ------------------------------------------------------------------- - NamingEnumeration values = table.listValues( BigInteger.ZERO ); + NamingEnumeration values = table.listValues( 0L ); assertFalse( values.hasMore() ); - values = table.listValues( new BigInteger( "2" ) ); + values = table.listValues( 2L ); assertTrue( values.hasMore() ); Object value = values.next(); - assertEquals( BigInteger.ONE, value ); + assertEquals( 1L, value ); assertFalse( values.hasMore() ); - values = table.listValues( BigInteger.ONE ); + values = table.listValues( 1L ); assertTrue( values.hasMore() ) ; value = values.next(); - assertEquals( BigInteger.ZERO, value ); + assertEquals( 0L, value ); assertTrue( values.hasMore() ) ; value = values.next(); - assertEquals( BigInteger.ONE, value ); + assertEquals( 1L, value ); assertTrue( values.hasMore() ) ; value = values.next(); - assertEquals( new BigInteger( "2" ), value ); + assertEquals( 2L, value ); assertFalse( values.hasMore() ); } @@ -499,63 +498,63 @@ // this instead tests the NamingEnumeration overload NamingEnumeration values = new ArrayNE( new Object[] { - new BigInteger( "3" ), - new BigInteger( "4" ), - new BigInteger( "5" ), - new BigInteger( "6" ), + 3L, + 4L, + 5L, + 6L, } ); - table.put( BigInteger.ONE, values ); + table.put( 1L, values ); assertFalse( values.hasMore() ); - values = table.listValues( BigInteger.ONE ); + values = table.listValues( 1L ); assertTrue( values.hasMore() ); - assertEquals( BigInteger.ZERO, values.next() ); + assertEquals( 0L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( BigInteger.ONE, values.next() ); + assertEquals( 1L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "2" ), values.next() ); + assertEquals( 2L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "3" ), values.next() ); + assertEquals( 3L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "4" ), values.next() ); + assertEquals( 4L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "5" ), values.next() ); + assertEquals( 5L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "6" ), values.next() ); + assertEquals( 6L, values.next() ); assertFalse( values.hasMore() ); values = new ArrayNE( new Object[] { - new BigInteger( "3" ), - new BigInteger( "4" ), - new BigInteger( "5" ), - new BigInteger( "6" ), + 3L, + 4L, + 5L, + 6L, } ); - table.put( BigInteger.ZERO, values ); + table.put( 0L, values ); assertFalse( values.hasMore() ); - values = table.listValues( BigInteger.ZERO ); + values = table.listValues( 0L ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "3" ), values.next() ); + assertEquals( 3L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "4" ), values.next() ); + assertEquals( 4L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "5" ), values.next() ); + assertEquals( 5L, values.next() ); assertTrue( values.hasMore() ); - assertEquals( new BigInteger( "6" ), values.next() ); + assertEquals( 6L, values.next() ); assertFalse( values.hasMore() ); } @@ -571,19 +570,19 @@ try { - table.remove( BigInteger.ZERO ); + table.remove( 0L ); fail( "should not get here trying to remove non-existent key" ); } catch ( IllegalArgumentException e ) { } - Object value = table.remove( new BigInteger( "2" ) ); - assertEquals( BigInteger.ONE, value ); + Object value = table.remove( 2L ); + assertEquals( 1L, value ); assertEquals( 5, table.count() ); - value = table.remove( BigInteger.ONE ); - assertEquals( BigInteger.ZERO, value ); // return first value of dups + value = table.remove( 1L ); + assertEquals( 0L, value ); // return first value of dups assertEquals( 2, table.count() ); } @@ -597,15 +596,15 @@ // tests the remove(Object) method // ------------------------------------------------------------------- - Object value = table.remove( BigInteger.ZERO, BigInteger.ZERO ); + Object value = table.remove( 0L, 0L ); assertNull( value ); - value = table.remove( new BigInteger( "2" ), BigInteger.ONE ); - assertEquals( BigInteger.ONE, value ); + value = table.remove( 2L, 1L ); + assertEquals( 1L, value ); assertEquals( 5, table.count() ); - value = table.remove( BigInteger.ONE, new BigInteger( "2" ) ); - assertEquals( new BigInteger( "2" ), value ); + value = table.remove( 1L, 2L ); + assertEquals( 2L, value ); assertEquals( 4, table.count() ); } @@ -616,12 +615,12 @@ public void testRemoveObjectNamingEnumeration() throws Exception { NamingEnumeration values = new ArrayNE( new Object[] { - new BigInteger( "1" ), - new BigInteger( "2" ) + 1L, + 2L } ); - Object value = table.remove( BigInteger.ONE, values ); - assertEquals( BigInteger.ONE, value ); + Object value = table.remove( 1L, values ); + assertEquals( 1L, value ); assertEquals( 4, table.count() ); } Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDupsTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDupsTest.java?view=diff&rev=517448&r1=517447&r2=517448 ============================================================================== --- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDupsTest.java (original) +++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTableNoDupsTest.java Mon Mar 12 15:53:56 2007 @@ -22,7 +22,6 @@ import java.io.File; import java.io.Serializable; -import java.math.BigInteger; import javax.naming.NamingEnumeration; import javax.naming.NamingException; @@ -31,7 +30,7 @@ import org.apache.directory.server.core.partition.impl.btree.TupleRenderer; import org.apache.directory.server.schema.SerializableComparator; import org.apache.directory.shared.ldap.util.ArrayEnumeration; -import org.apache.directory.shared.ldap.util.BigIntegerComparator; +import org.apache.directory.shared.ldap.util.LongComparator; import jdbm.RecordManager; import jdbm.recman.BaseRecordManager; @@ -50,7 +49,7 @@ private static final long serialVersionUID = 1L; private transient File tempFile = null; private transient RecordManager rm = null; - private final BigIntegerComparator biComparator = new BigIntegerComparator(); + private final LongComparator biComparator = new LongComparator(); private final SerializableComparator serializableComparator = new SerializableComparator( "integerMatchingRule" ) { private static final long serialVersionUID = 1L; @@ -84,10 +83,10 @@ // make sure the table does not use duplicates table = new JdbmTable( "test", rm, serializableComparator ); - table.put( new BigInteger( "1" ), BigInteger.ONE ); - table.put( new BigInteger( "2" ), BigInteger.ONE ); - table.put( new BigInteger( "4" ), BigInteger.ONE ); - table.put( new BigInteger( "5" ), BigInteger.ONE ); + table.put( 1L, 1L ); + table.put( 2L, 1L ); + table.put( 4L, 1L ); + table.put( 5L, 1L ); } protected void tearDown() throws Exception @@ -137,37 +136,37 @@ public void testHas() throws Exception { // test the has( Object ) method - assertTrue( table.has( BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("2") ) ); - assertTrue( table.has( new BigInteger("4") ) ); - assertTrue( table.has( new BigInteger("5") ) ); - assertFalse( table.has( new BigInteger("3") ) ); - assertFalse( table.has( BigInteger.ZERO ) ); - assertFalse( table.has( new BigInteger( "999" ) ) ); + assertTrue( table.has( 1L ) ); + assertTrue( table.has( 2L ) ); + assertTrue( table.has( 4L ) ); + assertTrue( table.has( 5L ) ); + assertFalse( table.has( 3L ) ); + assertFalse( table.has( 0L ) ); + assertFalse( table.has( 999L ) ); // test the has( Object, Object ) method - assertTrue( table.has( BigInteger.ONE, BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("2"), BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("4"), BigInteger.ONE ) ); - assertTrue( table.has( new BigInteger("5"), BigInteger.ONE ) ); - assertFalse( table.has( new BigInteger("5"), BigInteger.ZERO ) ); - assertFalse( table.has( new BigInteger("3"), BigInteger.ONE ) ); - assertFalse( table.has( BigInteger.ONE, new BigInteger("999") ) ); - assertFalse( table.has( new BigInteger( "999" ), BigInteger.ONE ) ); + assertTrue( table.has( 1L, 1L ) ); + assertTrue( table.has( 2L, 1L ) ); + assertTrue( table.has( 4L, 1L ) ); + assertTrue( table.has( 5L, 1L ) ); + assertFalse( table.has( 5L, 0L ) ); + assertFalse( table.has( 3L, 1L ) ); + assertFalse( table.has( 1L, 999L ) ); + assertFalse( table.has( 999L, 1L ) ); // test the has( Object, boolean ) method - assertFalse( table.has( BigInteger.ZERO, false ) ); // we do not have a key less than or equal to 0 - assertTrue( table.has( BigInteger.ONE, false ) ); // we do have a key less than or equal to 1 - assertTrue( table.has( BigInteger.ZERO, true ) ); // we do have a key greater than or equal to 0 - assertTrue( table.has( BigInteger.ONE, true ) ); // we do have a key greater than or equal to 1 - assertTrue( table.has( new BigInteger( "5" ), true ) ); // we do have a key greater than or equal to 5 - assertFalse( table.has( new BigInteger( "6" ), true ) ); // we do NOT have a key greater than or equal to 11 - assertFalse( table.has( new BigInteger( "999" ), true ) ); // we do NOT have a key greater than or equal to 12 + assertFalse( table.has( Long.valueOf(0), false ) ); // we do not have a key less than or equal to 0 + assertTrue( table.has( Long.valueOf(1), false ) ); // we do have a key less than or equal to 1 + assertTrue( table.has( Long.valueOf(0), true ) ); // we do have a key greater than or equal to 0 + assertTrue( table.has( Long.valueOf(1), true ) ); // we do have a key greater than or equal to 1 + assertTrue( table.has( Long.valueOf(5), true ) ); // we do have a key greater than or equal to 5 + assertFalse( table.has( Long.valueOf(6), true ) ); // we do NOT have a key greater than or equal to 11 + assertFalse( table.has( Long.valueOf(999), true ) ); // we do NOT have a key greater than or equal to 12 // test the has( Object, Object, boolean ) method try { - table.has( BigInteger.ONE, BigInteger.ZERO, true ); + table.has( 1L, 0L, true ); } catch ( UnsupportedOperationException usoe ) { @@ -192,13 +191,13 @@ assertEquals( 4, table.count() ); // test the count(Object) method - assertEquals( 1, table.count( BigInteger.ONE ) ); - assertEquals( 0, table.count( BigInteger.ZERO ) ); - assertEquals( 1, table.count( new BigInteger( "2" ) ) ); + assertEquals( 1, table.count( 1L ) ); + assertEquals( 0, table.count( 0L ) ); + assertEquals( 1, table.count( 2L ) ); // test the count( Object, boolean ) method // note for speed this count method returns the same as count() - assertEquals( table.count(), table.count( BigInteger.ONE, true ) ); + assertEquals( table.count(), table.count( 1L, true ) ); } @@ -209,11 +208,11 @@ */ public void testGet() throws Exception { - assertEquals( BigInteger.ONE, table.get( BigInteger.ONE ) ); - assertEquals( BigInteger.ONE, table.get( new BigInteger( "2" ) ) ); - assertEquals( null, table.get( new BigInteger( "3" ) ) ); - assertEquals( BigInteger.ONE, table.get( new BigInteger( "4" ) ) ); - assertEquals( BigInteger.ONE, table.get( new BigInteger( "5" ) ) ); + assertEquals( 1L, table.get( 1L ) ); + assertEquals( 1L, table.get( 2L ) ); + assertEquals( null, table.get( 3L ) ); + assertEquals( 1L, table.get( 4L ) ); + assertEquals( 1L, table.get( 5L ) ); } @@ -240,23 +239,23 @@ assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "4" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 4L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "5" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 5L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); @@ -264,69 +263,69 @@ // test the listTuples(Object) method // ------------------------------------------------------------------- - tuples = table.listTuples( BigInteger.ZERO ); + tuples = table.listTuples( 0L ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ) ); + tuples = table.listTuples( 2L ); assertTrue( tuples.hasMore() ); tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); // ------------------------------------------------------------------- // test the listTuples(Object, boolean) method // ------------------------------------------------------------------- - tuples = table.listTuples( BigInteger.ZERO, false ); + tuples = table.listTuples( 0L, false ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( BigInteger.ONE, false ); + tuples = table.listTuples( 1L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( new BigInteger( "1" ), tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "2" ), false ); + tuples = table.listTuples( 2L, false ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "2" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 2L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( BigInteger.ONE, tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 1L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "6" ), true ); + tuples = table.listTuples( 6L, true ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "5" ), true ); + tuples = table.listTuples( 5L, true ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "5" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 5L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); - tuples = table.listTuples( new BigInteger( "4" ), true ); + tuples = table.listTuples( 4L, true ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "4" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 4L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertTrue( tuples.hasMore() ) ; tuple = ( Tuple ) tuples.next(); - assertEquals( new BigInteger( "5" ), tuple.getKey() ); - assertEquals( BigInteger.ONE, tuple.getValue() ); + assertEquals( 5L, tuple.getKey() ); + assertEquals( 1L, tuple.getValue() ); assertFalse( tuples.hasMore() ); // ------------------------------------------------------------------- @@ -335,7 +334,7 @@ try { - tuples = table.listTuples( BigInteger.ZERO, BigInteger.ZERO, true ); + tuples = table.listTuples( 0L, 0L, true ); } catch( UnsupportedOperationException e ) { @@ -353,19 +352,19 @@ // test the listValues(Object) method // ------------------------------------------------------------------- - NamingEnumeration values = table.listValues( BigInteger.ZERO ); + NamingEnumeration values = table.listValues( 0L ); assertFalse( values.hasMore() ); - values = table.listValues( new BigInteger( "2" ) ); + values = table.listValues( 2L ); assertTrue( values.hasMore() ); Object value = values.next(); - assertEquals( BigInteger.ONE, value ); + assertEquals( 1L, value ); assertFalse( values.hasMore() ); - values = table.listValues( BigInteger.ONE ); + values = table.listValues( 1L ); assertTrue( values.hasMore() ) ; value = values.next(); - assertEquals( BigInteger.ONE, value ); + assertEquals( 1L, value ); assertFalse( values.hasMore() ); } @@ -383,15 +382,15 @@ // this instead tests the NamingEnumeration overload NamingEnumeration values = new ArrayNE( new Object[] { - new BigInteger( "3" ), - new BigInteger( "4" ), - new BigInteger( "5" ), - new BigInteger( "6" ), + 3L, + 4L, + 5L, + 6L, } ); try { - table.put( BigInteger.ONE, values ); + table.put( 1L, values ); } catch( UnsupportedOperationException e ) { @@ -410,19 +409,19 @@ try { - table.remove( BigInteger.ZERO ); + table.remove( 0L ); fail( "should not get here trying to remove non-existent key" ); } catch ( IllegalArgumentException e ) { } - Object value = table.remove( new BigInteger( "2" ) ); - assertEquals( BigInteger.ONE, value ); + Object value = table.remove( 2L ); + assertEquals( 1L, value ); assertEquals( 3, table.count() ); - value = table.remove( BigInteger.ONE ); - assertEquals( BigInteger.ONE, value ); + value = table.remove( 1L ); + assertEquals( 1L, value ); assertEquals( 2, table.count() ); } @@ -436,14 +435,14 @@ // tests the remove(Object) method // ------------------------------------------------------------------- - Object value = table.remove( BigInteger.ZERO, BigInteger.ZERO ); + Object value = table.remove( 0L, 0L ); assertNull( value ); - value = table.remove( new BigInteger( "2" ), BigInteger.ONE ); - assertEquals( BigInteger.ONE, value ); + value = table.remove( 2L, 1L ); + assertEquals( 1L, value ); assertEquals( 3, table.count() ); - value = table.remove( BigInteger.ONE, new BigInteger( "2" ) ); + value = table.remove( 1L, 2L ); assertEquals( null, value ); assertEquals( 3, table.count() ); } @@ -455,13 +454,13 @@ public void testRemoveObjectNamingEnumeration() throws Exception { NamingEnumeration values = new ArrayNE( new Object[] { - new BigInteger( "1" ), - new BigInteger( "2" ) + 1L, + 2L } ); try { - table.remove( BigInteger.ONE, values ); + table.remove( 1L, values ); } catch( UnsupportedOperationException e ) { Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?view=diff&rev=517448&r1=517447&r2=517448 ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Mon Mar 12 15:53:56 2007 @@ -22,7 +22,6 @@ import java.io.File; import java.io.IOException; -import java.math.BigInteger; import java.util.regex.Pattern; import javax.naming.NamingEnumeration; @@ -198,9 +197,9 @@ /** * @see Index#forwardLookup(java.lang.Object) */ - public BigInteger forwardLookup( Object attrVal ) throws NamingException + public Long forwardLookup( Object attrVal ) throws NamingException { - return ( BigInteger ) forward.get( getNormalized( attrVal ) ); + return ( Long ) forward.get( getNormalized( attrVal ) ); } Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java?view=diff&rev=517448&r1=517447&r2=517448 ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java Mon Mar 12 15:53:56 2007 @@ -20,8 +20,6 @@ package org.apache.directory.server.core.partition.impl.btree.jdbm; -import java.math.BigInteger; - import javax.naming.NamingException; import javax.naming.directory.Attributes; @@ -30,7 +28,8 @@ import org.apache.directory.server.core.partition.impl.btree.MasterTable; import org.apache.directory.server.schema.SerializableComparator; -import org.apache.directory.shared.ldap.util.BigIntegerComparator; +//import org.apache.directory.shared.ldap.util.BigIntegerComparator; +import org.apache.directory.shared.ldap.util.LongComparator; /** @@ -42,7 +41,7 @@ public class JdbmMasterTable extends JdbmTable implements MasterTable { private static final StringComparator STRCOMP = new StringComparator(); - private static final SerializableComparator BIG_INTEGER_COMPARATOR = new SerializableComparator( + private static final SerializableComparator LONG_COMPARATOR = new SerializableComparator( "1.3.6.1.4.1.18060.0.4.1.1.2" ) { private static final long serialVersionUID = 4048791282048841016L; @@ -50,7 +49,7 @@ public int compare( Object o1, Object o2 ) { - return BigIntegerComparator.INSTANCE.compare( o1, o2 ); + return LongComparator.INSTANCE.compare( o1, o2 ); } }; private static final SerializableComparator STRING_COMPARATOR = new SerializableComparator( @@ -76,13 +75,13 @@ */ public JdbmMasterTable(RecordManager recMan) throws NamingException { - super( DBF, recMan, BIG_INTEGER_COMPARATOR ); + super( DBF, recMan, LONG_COMPARATOR ); adminTbl = new JdbmTable( "admin", recMan, STRING_COMPARATOR ); String seqValue = ( String ) adminTbl.get( SEQPROP_KEY ); if ( null == seqValue ) { - adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() ); + adminTbl.put( SEQPROP_KEY, "0" ); } } @@ -137,18 +136,18 @@ * @throws NamingException if the admin table storing sequences cannot be * read. */ - public BigInteger getCurrentId() throws NamingException + public Long getCurrentId() throws NamingException { - BigInteger id = null; + Long id = null; synchronized ( adminTbl ) { - id = new BigInteger( ( String ) adminTbl.get( SEQPROP_KEY ) ); + id = new Long( ( String ) adminTbl.get( SEQPROP_KEY ) ); if ( null == id ) { - adminTbl.put( SEQPROP_KEY, BigInteger.ZERO.toString() ); - id = BigInteger.ZERO; + adminTbl.put( SEQPROP_KEY, "0" ); + id = 0L; } } @@ -166,23 +165,23 @@ * @throws NamingException if the admin table storing sequences cannot be * read and writen to. */ - public BigInteger getNextId() throws NamingException + public Long getNextId() throws NamingException { - BigInteger lastVal = null; - BigInteger nextVal = null; + Long lastVal = null; + Long nextVal = null; synchronized ( adminTbl ) { - lastVal = new BigInteger( ( String ) adminTbl.get( SEQPROP_KEY ) ); + lastVal = new Long( ( String ) adminTbl.get( SEQPROP_KEY ) ); if ( null == lastVal ) { - adminTbl.put( SEQPROP_KEY, BigInteger.ONE.toString() ); - return BigInteger.ONE; + adminTbl.put( SEQPROP_KEY, "1" ); + return 1L; } else { - nextVal = lastVal.add( BigInteger.ONE ); + nextVal = lastVal + 1L; adminTbl.put( SEQPROP_KEY, nextVal.toString() ); } } Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?view=diff&rev=517448&r1=517447&r2=517448 ============================================================================== --- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original) +++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Mon Mar 12 15:53:56 2007 @@ -21,7 +21,6 @@ import java.io.File; import java.io.IOException; -import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -783,32 +782,32 @@ } - public BigInteger getEntryId( String dn ) throws NamingException + public Long getEntryId( String dn ) throws NamingException { - return (BigInteger)ndnIdx.forwardLookup( dn ); + return (Long)ndnIdx.forwardLookup( dn ); } - public String getEntryDn( BigInteger id ) throws NamingException + public String getEntryDn( Long id ) throws NamingException { return ( String ) ndnIdx.reverseLookup( id ); } - public BigInteger getParentId( String dn ) throws NamingException + public Long getParentId( String dn ) throws NamingException { - BigInteger childId = (BigInteger)ndnIdx.forwardLookup( dn ); - return ( BigInteger ) hierarchyIdx.reverseLookup( childId ); + Long childId = (Long)ndnIdx.forwardLookup( dn ); + return ( Long ) hierarchyIdx.reverseLookup( childId ); } - public BigInteger getParentId( BigInteger childId ) throws NamingException + public Long getParentId( Long childId ) throws NamingException { - return ( BigInteger ) hierarchyIdx.reverseLookup( childId ); + return ( Long ) hierarchyIdx.reverseLookup( childId ); } - public String getEntryUpdn( BigInteger id ) throws NamingException + public String getEntryUpdn( Long id ) throws NamingException { return ( String ) updnIdx.reverseLookup( id ); } @@ -816,7 +815,7 @@ public String getEntryUpdn( String dn ) throws NamingException { - BigInteger id = (BigInteger)ndnIdx.forwardLookup( dn ); + Long id = (Long)ndnIdx.forwardLookup( dn ); return ( String ) updnIdx.reverseLookup( id ); } @@ -835,13 +834,13 @@ * @param aliasId the id of the alias entry in the master table * @throws NamingException if we cannot delete the indices */ - private void dropAliasIndices( BigInteger aliasId ) throws NamingException + private void dropAliasIndices( Long aliasId ) throws NamingException { String targetDn = ( String ) aliasIdx.reverseLookup( aliasId ); - BigInteger targetId = getEntryId( targetDn ); + Long targetId = getEntryId( targetDn ); String aliasDn = getEntryDn( aliasId ); LdapDN ancestorDn = ( LdapDN ) new LdapDN( aliasDn ).getPrefix( 1 ); - BigInteger ancestorId = getEntryId( ancestorDn.toString() ); + Long ancestorId = getEntryId( ancestorDn.toString() ); /* * We cannot just drop all tuples in the one level and subtree indices @@ -880,12 +879,12 @@ * @throws NamingException if index addition fails, of the alias is not * allowed due to chaining or cycle formation. */ - private void addAliasIndices( BigInteger aliasId, LdapDN aliasDn, String aliasTarget ) throws NamingException + private void addAliasIndices( Long aliasId, LdapDN aliasDn, String aliasTarget ) throws NamingException { LdapDN normalizedAliasTargetDn = null; // Name value of aliasedObjectName - BigInteger targetId = null; // Id of the aliasedObjectName + Long targetId = null; // Id of the aliasedObjectName LdapDN ancestorDn = null; // Name of an alias entry relative - BigInteger ancestorId = null; // Id of an alias entry relative + Long ancestorId = null; // Id of an alias entry relative // Access aliasedObjectName, normalize it and generate the Name normalizedAliasTargetDn = new LdapDN( aliasTarget ); @@ -930,7 +929,7 @@ } // L O O K U P T A R G E T I D - targetId = (BigInteger)ndnIdx.forwardLookup( normalizedAliasTargetDn.toNormName() ); + targetId = (Long)ndnIdx.forwardLookup( normalizedAliasTargetDn.toNormName() ); /* * Check For Target Existance @@ -1007,8 +1006,8 @@ public void add( LdapDN normName, Attributes entry ) throws NamingException { - BigInteger id; - BigInteger parentId = null; + Long id; + Long parentId = null; id = master.getNextId(); @@ -1021,7 +1020,7 @@ LdapDN parentDn = null; if ( normName.equals( normSuffix ) ) { - parentId = BigInteger.ZERO; + parentId = 0L; } else { @@ -1091,16 +1090,16 @@ } - public Attributes lookup( BigInteger id ) throws NamingException + public Attributes lookup( Long id ) throws NamingException { return master.get( id ); } - public void delete( BigInteger id ) throws NamingException + public void delete( Long id ) throws NamingException { Attributes entry = lookup( id ); - BigInteger parentId = getParentId( id ); + Long parentId = getParentId( id ); NamingEnumeration attrs = entry.getIDs(); Attribute objectClass = AttributeUtils.getAttribute( entry, OBJECT_CLASS_AT ); @@ -1114,7 +1113,7 @@ hierarchyIdx.drop( id ); // Remove parent's reference to entry only if entry is not the upSuffix - if ( !parentId.equals( BigInteger.ZERO ) ) + if ( !parentId.equals( 0L ) ) { hierarchyIdx.drop( parentId, id ); } @@ -1150,13 +1149,13 @@ } - public NamingEnumeration list( BigInteger id ) throws NamingException + public NamingEnumeration list( Long id ) throws NamingException { return hierarchyIdx.listIndices( id ); } - public int getChildCount( BigInteger id ) throws NamingException + public int getChildCount( Long id ) throws NamingException { return hierarchyIdx.count( id ); } @@ -1175,7 +1174,7 @@ public Attributes getSuffixEntry() throws NamingException { - BigInteger id = getEntryId( normSuffix.toNormName() ); + Long id = getEntryId( normSuffix.toNormName() ); if ( null == id ) { @@ -1198,7 +1197,7 @@ } - public Attributes getIndices( BigInteger id ) throws NamingException + public Attributes getIndices( Long id ) throws NamingException { Attributes attributes = new AttributesImpl(); @@ -1276,7 +1275,7 @@ * @throws NamingException if index alteration or attribute addition * fails. */ - private void add( BigInteger id, Attributes entry, Attribute mods ) throws NamingException + private void add( Long id, Attributes entry, Attribute mods ) throws NamingException { String modsOid = oidRegistry.getOid( mods.getID() ); @@ -1329,7 +1328,7 @@ * @throws NamingException if index alteration or attribute modification * fails. */ - private void remove( BigInteger id, Attributes entry, Attribute mods ) throws NamingException + private void remove( Long id, Attributes entry, Attribute mods ) throws NamingException { String modsOid = oidRegistry.getOid( mods.getID() ); @@ -1395,7 +1394,7 @@ * @throws NamingException if index alteration or attribute modification * fails. */ - private void replace( BigInteger id, Attributes entry, Attribute mods ) throws NamingException + private void replace( Long id, Attributes entry, Attribute mods ) throws NamingException { String modsOid = oidRegistry.getOid( mods.getID() ); @@ -1444,7 +1443,7 @@ public void modify( LdapDN dn, int modOp, Attributes mods ) throws NamingException { NamingEnumeration attrs = null; - BigInteger id = getEntryId( dn.toString() ); + Long id = getEntryId( dn.toString() ); Attributes entry = master.get( id ); switch ( modOp ) @@ -1497,7 +1496,7 @@ public void modify( LdapDN dn, ModificationItemImpl[] mods ) throws NamingException { - BigInteger id = getEntryId( dn.toString() ); + Long id = getEntryId( dn.toString() ); Attributes entry = master.get( id ); for ( int ii = 0; ii < mods.length; ii++ ) @@ -1550,7 +1549,7 @@ { String newRdnAttr = NamespaceTools.getRdnAttribute( newRdn ); String newRdnValue = NamespaceTools.getRdnValue( newRdn ); - BigInteger id = getEntryId( dn.toString() ); + Long id = getEntryId( dn.toString() ); Attributes entry = lookup( id ); LdapDN updn = new LdapDN( getEntryUpdn( id ) ); @@ -1671,7 +1670,7 @@ * which affects alias indices. * @throws NamingException if something goes wrong */ - private void modifyDn( BigInteger id, LdapDN updn, boolean isMove ) throws NamingException + private void modifyDn( Long id, LdapDN updn, boolean isMove ) throws NamingException { String aliasTarget = null; @@ -1710,7 +1709,7 @@ { // Get the child and its id IndexRecord rec = ( IndexRecord ) children.next(); - BigInteger childId = (BigInteger)rec.getEntryId(); + Long childId = (Long)rec.getEntryId(); /* * Calculate the Dn for the child's new name by copying the parents @@ -1729,7 +1728,7 @@ public void move( LdapDN oldChildDn, LdapDN newParentDn, String newRdn, boolean deleteOldRdn ) throws NamingException { - BigInteger childId = getEntryId( oldChildDn.toString() ); + Long childId = getEntryId( oldChildDn.toString() ); modifyRn( oldChildDn, newRdn, deleteOldRdn ); move( oldChildDn, childId, newParentDn ); @@ -1742,7 +1741,7 @@ public void move( LdapDN oldChildDn, LdapDN newParentDn ) throws NamingException { - BigInteger childId = getEntryId( oldChildDn.toString() ); + Long childId = getEntryId( oldChildDn.toString() ); move( oldChildDn, childId, newParentDn ); if ( isSyncOnWrite ) @@ -1765,11 +1764,11 @@ * @param newParentDn the normalized dn of the new parent for the child * @throws NamingException if something goes wrong */ - private void move( LdapDN oldChildDn, BigInteger childId, LdapDN newParentDn ) throws NamingException + private void move( LdapDN oldChildDn, Long childId, LdapDN newParentDn ) throws NamingException { // Get the child and the new parent to be entries and Ids - BigInteger newParentId = getEntryId( newParentDn.toString() ); - BigInteger oldParentId = getParentId( childId ); + Long newParentId = getEntryId( newParentDn.toString() ); + Long oldParentId = getParentId( childId ); /* * All aliases including and below oldChildDn, will be affected by @@ -1818,7 +1817,7 @@ { public boolean assertCandidate( IndexRecord rec ) throws NamingException { - String dn = getEntryDn( (BigInteger)rec.getEntryId() ); + String dn = getEntryDn( (Long)rec.getEntryId() ); if ( dn.endsWith( movedBase.toString() ) ) { return true; @@ -1828,7 +1827,7 @@ } }; - BigInteger movedBaseId = getEntryId( movedBase.toString() ); + Long movedBaseId = getEntryId( movedBase.toString() ); if ( aliasIdx.reverseLookup( movedBaseId ) != null ) { dropAliasIndices( movedBaseId, movedBase ); @@ -1839,7 +1838,7 @@ while ( aliases.hasMore() ) { IndexRecord entry = ( IndexRecord ) aliases.next(); - dropAliasIndices( (BigInteger)entry.getEntryId(), movedBase ); + dropAliasIndices( (Long)entry.getEntryId(), movedBase ); } } @@ -1852,10 +1851,10 @@ * @param movedBase the base where the move occured * @throws NamingException if indices fail */ - private void dropAliasIndices( BigInteger aliasId, LdapDN movedBase ) throws NamingException + private void dropAliasIndices( Long aliasId, LdapDN movedBase ) throws NamingException { String targetDn = ( String ) aliasIdx.reverseLookup( aliasId ); - BigInteger targetId = getEntryId( targetDn ); + Long targetId = getEntryId( targetDn ); String aliasDn = getEntryDn( aliasId ); /* @@ -1863,7 +1862,7 @@ * moved base. This is the first ancestor effected by the move. */ LdapDN ancestorDn = ( LdapDN ) movedBase.getPrefix( 1 ); - BigInteger ancestorId = getEntryId( ancestorDn.toString() ); + Long ancestorId = getEntryId( ancestorDn.toString() ); /* * We cannot just drop all tuples in the one level and subtree indices