directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1199854 - in /directory/apacheds/branches/apacheds-txns/jdbm-partition/src: main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
Date Wed, 09 Nov 2011 17:05:41 GMT
Author: saya
Date: Wed Nov  9 17:05:40 2011
New Revision: 1199854

URL: http://svn.apache.org/viewvc?rev=1199854&view=rev
Log:
changed jdbm partition to use UUID instead of Long.

Modified:
    directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java
    directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
    directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
    directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
    directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java
    directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
    directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java

Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=1199854&r1=1199853&r2=1199854&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Wed Nov  9 17:05:40 2011
@@ -24,11 +24,14 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.net.URI;
+import java.util.Comparator;
+import java.util.UUID;
 
 import jdbm.RecordManager;
 import jdbm.recman.BaseRecordManager;
 import jdbm.recman.SnapshotRecordManager;
 
+import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.partition.impl.btree.IndexCursorAdaptor;
 import org.apache.directory.server.core.partition.impl.btree.LongComparator;
 import org.apache.directory.server.i18n.I18n;
@@ -37,6 +40,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.partition.index.Index;
 import org.apache.directory.server.core.api.partition.index.IndexCursor;
 import org.apache.directory.server.core.api.partition.index.ReverseIndexComparator;
+import org.apache.directory.server.core.api.partition.index.UUIDComparator;
 import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.cursor.Tuple;
 import org.apache.directory.shared.ldap.model.entry.BinaryValue;
@@ -54,7 +58,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class JdbmIndex<K, O> extends AbstractIndex<K, O, Long>
+public class JdbmIndex<K> extends AbstractIndex<K>
 {
     /** A logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( JdbmIndex.class.getSimpleName() );
@@ -75,14 +79,14 @@ public class JdbmIndex<K, O> extends Abs
      * the value of the btree is the entry id of the entry containing an attribute with
      * that value
      */
-    protected JdbmTable<K, Long> forward;
+    protected JdbmTable<K, UUID> forward;
 
     /**
      * the reverse btree where the btree key is the entry id of the entry containing a
      * value for the indexed attribute, and the btree value is the value of the indexed
      * attribute
      */
-    protected JdbmTable<Long, K> reverse;
+    protected JdbmTable<UUID, K> reverse;
 
     /**
      * the JDBM record manager for the file containing this index
@@ -105,10 +109,10 @@ public class JdbmIndex<K, O> extends Abs
     protected File wkDirPath;
     
     /** Forward index entry comparator */
-    protected ForwardIndexComparator<K,Long> fIndexEntryComparator;
+    protected ForwardIndexComparator<K> fIndexEntryComparator;
     
     /** Reverse index entry comparator */
-    protected ReverseIndexComparator<K,Long> rIndexEntryComparator;
+    protected ReverseIndexComparator<K> rIndexEntryComparator;
 
 
     /*
@@ -215,7 +219,7 @@ public class JdbmIndex<K, O> extends Abs
      */
     private void initTables( SchemaManager schemaManager ) throws IOException
     {
-        SerializableComparator<K> comp;
+        SerializableComparator comp;
 
         MatchingRule mr = attributeType.getEquality();
 
@@ -231,11 +235,20 @@ public class JdbmIndex<K, O> extends Abs
          * primary keys.  A value for an attribute can occur several times in
          * different entries so the forward map can have more than one value.
          */
-        LongComparator.INSTANCE.setSchemaManager( schemaManager );
+        String attributeOid = attributeType.getOid();
+        
+        if ( attributeOid.equals( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) ||
+            attributeOid.equals( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) ||
+            attributeOid.equals( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) ||
+            attributeOid.equals( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) )
+        {
+            comp = UUIDComparator.INSTANCE;
+        }
+        
         comp.setSchemaManager( schemaManager );
 
-        forward = new JdbmTable<K, Long>( schemaManager, attributeType.getOid() + FORWARD_BTREE, numDupLimit, recMan,
-            comp, LongComparator.INSTANCE, null, LongSerializer.INSTANCE );
+        forward = new JdbmTable<K, UUID>( schemaManager, attributeType.getOid() + FORWARD_BTREE, numDupLimit, recMan,
+            comp, UUIDComparator.INSTANCE, null, UUIDSerializer.INSTANCE );
 
         /*
          * Now the reverse map stores the primary key into the master table as
@@ -245,17 +258,17 @@ public class JdbmIndex<K, O> extends Abs
          */
         if ( attributeType.isSingleValued() )
         {
-            reverse = new JdbmTable<Long, K>( schemaManager, attributeType.getOid() + REVERSE_BTREE, recMan,
-                LongComparator.INSTANCE, LongSerializer.INSTANCE, null );
+            reverse = new JdbmTable<UUID, K>( schemaManager, attributeType.getOid() + REVERSE_BTREE, recMan,
+                UUIDComparator.INSTANCE, UUIDSerializer.INSTANCE, null );
         }
         else
         {
-            reverse = new JdbmTable<Long, K>( schemaManager, attributeType.getOid() + REVERSE_BTREE, numDupLimit, recMan,
-                LongComparator.INSTANCE, comp, LongSerializer.INSTANCE, null );
+            reverse = new JdbmTable<UUID, K>( schemaManager, attributeType.getOid() + REVERSE_BTREE, numDupLimit, recMan,
+                UUIDComparator.INSTANCE, comp, UUIDSerializer.INSTANCE, null );
         }
         
-        fIndexEntryComparator = new ForwardIndexComparator( comp, LongComparator.INSTANCE );
-        rIndexEntryComparator = new ReverseIndexComparator( comp, LongComparator.INSTANCE );
+        fIndexEntryComparator = new ForwardIndexComparator( comp );
+        rIndexEntryComparator = new ReverseIndexComparator( comp );
     }
 
 
@@ -356,7 +369,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * @see Index#forwardLookup(java.lang.Object)
      */
-    public Long forwardLookup( K attrVal ) throws Exception
+    public UUID forwardLookup( K attrVal ) throws Exception
     {
         return forward.get( getNormalized( attrVal ) );
     }
@@ -365,7 +378,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public K reverseLookup( Long id ) throws Exception
+    public K reverseLookup( UUID id ) throws Exception
     {
         return reverse.get( id );
     }
@@ -378,7 +391,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public synchronized void add( K attrVal, Long id ) throws Exception
+    public synchronized void add( K attrVal, UUID id ) throws Exception
     {
         K normalizedValue = getNormalized( attrVal );
 
@@ -391,7 +404,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public synchronized void drop( K attrVal, Long id ) throws Exception
+    public synchronized void drop( K attrVal, UUID id ) throws Exception
     {
         K normalizedValue = getNormalized( attrVal );
         
@@ -407,11 +420,11 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public void drop( Long entryId ) throws Exception
+    public void drop( UUID entryId ) throws Exception
     {
         // Build a cursor to iterate on all the keys referencing
         // this entryId
-        Cursor<Tuple<Long, K>> values = reverse.cursor( entryId );
+        Cursor<Tuple<UUID, K>> values = reverse.cursor( entryId );
 
         while ( values.next() )
         {
@@ -428,40 +441,40 @@ public class JdbmIndex<K, O> extends Abs
     // Index Cursor Operations
     // ------------------------------------------------------------------------
     @SuppressWarnings("unchecked")
-    public IndexCursor<K, O, Long> reverseCursor() throws Exception
+    public IndexCursor<K> reverseCursor() throws Exception
     {
-        return new IndexCursorAdaptor<K, O, Long>( ( Cursor ) reverse.cursor(), false );
+        return new IndexCursorAdaptor<K>( ( Cursor ) reverse.cursor(), false );
     }
 
 
     @SuppressWarnings("unchecked")
-    public IndexCursor<K, O, Long> forwardCursor() throws Exception
+    public IndexCursor<K> forwardCursor() throws Exception
     {
-        return new IndexCursorAdaptor<K, O, Long>( ( Cursor ) forward.cursor(), true );
+        return new IndexCursorAdaptor<K>( ( Cursor ) forward.cursor(), true );
     }
 
 
     @SuppressWarnings("unchecked")
-    public IndexCursor<K, O, Long> reverseCursor( Long id ) throws Exception
+    public IndexCursor<K> reverseCursor( UUID id ) throws Exception
     {
-        return new IndexCursorAdaptor<K, O, Long>( (Cursor) reverse.cursor( id ), false );
+        return new IndexCursorAdaptor<K>( (Cursor) reverse.cursor( id ), false );
     }
 
 
     @SuppressWarnings("unchecked")
-    public IndexCursor<K, O, Long> forwardCursor( K key ) throws Exception
+    public IndexCursor<K> forwardCursor( K key ) throws Exception
     {
-        return new IndexCursorAdaptor<K, O, Long>( ( Cursor ) forward.cursor( key ), true );
+        return new IndexCursorAdaptor<K>( ( Cursor ) forward.cursor( key ), true );
     }
 
 
-    public Cursor<K> reverseValueCursor( Long id ) throws Exception
+    public Cursor<K> reverseValueCursor( UUID id ) throws Exception
     {
         return reverse.valueCursor( id );
     }
 
 
-    public Cursor<Long> forwardValueCursor( K key ) throws Exception
+    public Cursor<UUID> forwardValueCursor( K key ) throws Exception
     {
         return forward.valueCursor( key );
     }
@@ -482,7 +495,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean forward( K attrVal, Long id ) throws Exception
+    public boolean forward( K attrVal, UUID id ) throws Exception
     {
         return forward.has( getNormalized( attrVal ), id );
     }
@@ -491,7 +504,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean reverse( Long id ) throws Exception
+    public boolean reverse( UUID id ) throws Exception
     {
         return reverse.has( id );
     }
@@ -500,7 +513,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean reverse( Long id, K attrVal ) throws Exception
+    public boolean reverse( UUID id, K attrVal ) throws Exception
     {
         return forward.has( getNormalized( attrVal ), id );
     }
@@ -518,7 +531,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean forwardGreaterOrEq( K attrVal, Long id ) throws Exception
+    public boolean forwardGreaterOrEq( K attrVal, UUID id ) throws Exception
     {
         return forward.hasGreaterOrEqual( getNormalized( attrVal ), id );
     }
@@ -536,7 +549,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean forwardLessOrEq( K attrVal, Long id ) throws Exception
+    public boolean forwardLessOrEq( K attrVal, UUID id ) throws Exception
     {
         return forward.hasLessOrEqual( getNormalized( attrVal ), id );
     }
@@ -545,7 +558,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean reverseGreaterOrEq( Long id ) throws Exception
+    public boolean reverseGreaterOrEq( UUID id ) throws Exception
     {
         return reverse.hasGreaterOrEqual( id );
     }
@@ -554,7 +567,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean reverseGreaterOrEq( Long id, K attrVal ) throws Exception
+    public boolean reverseGreaterOrEq( UUID id, K attrVal ) throws Exception
     {
         return reverse.hasGreaterOrEqual( id, getNormalized( attrVal ) );
     }
@@ -563,7 +576,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean reverseLessOrEq( Long id ) throws Exception
+    public boolean reverseLessOrEq( UUID id ) throws Exception
     {
         return reverse.hasLessOrEqual( id );
     }
@@ -572,7 +585,7 @@ public class JdbmIndex<K, O> extends Abs
     /**
      * {@inheritDoc}
      */
-    public boolean reverseLessOrEq( Long id, K attrVal ) throws Exception
+    public boolean reverseLessOrEq( UUID id, K attrVal ) throws Exception
     {
         return reverse.hasLessOrEqual( id, getNormalized( attrVal ) );
     }
@@ -617,7 +630,7 @@ public class JdbmIndex<K, O> extends Abs
     @SuppressWarnings("unchecked")
     public K getNormalized( K attrVal ) throws Exception
     {
-        if ( attrVal instanceof Long )
+        if ( attrVal instanceof UUID )
         {
             return attrVal;
         }
@@ -655,12 +668,12 @@ public class JdbmIndex<K, O> extends Abs
         return reverse.isDupsEnabled();
     }
     
-    public ForwardIndexComparator<K,Long> getForwardIndexEntryComparator()
+    public ForwardIndexComparator<K> getForwardIndexEntryComparator()
     {
         return this.fIndexEntryComparator;
     }
     
-    public ReverseIndexComparator<K,Long> getReverseIndexEntryComparator()
+    public ReverseIndexComparator<K> getReverseIndexEntryComparator()
     {
         return this.rIndexEntryComparator;
     }

Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java?rev=1199854&r1=1199853&r2=1199854&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java (original)
+++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java Wed Nov  9 17:05:40 2011
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
+import java.util.UUID;
 
 import jdbm.RecordManager;
 import jdbm.helper.LongSerializer;
@@ -27,6 +28,9 @@ import jdbm.helper.StringComparator;
 
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.core.api.partition.index.MasterTable;
+import org.apache.directory.server.core.api.partition.index.UUIDComparator;
+import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.model.schema.comparators.SerializableComparator;
 
@@ -36,77 +40,8 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class JdbmMasterTable<E> extends JdbmTable<Long,E> implements MasterTable<Long, E>
+public class JdbmMasterTable extends JdbmTable<UUID,Entry> implements MasterTable
 {
-    private static final StringComparator STRCOMP = new StringComparator();
-
-
-    private static final SerializableComparator<Long> LONG_COMPARATOR =
-            new SerializableComparator<Long>( "1.3.6.1.4.1.18060.0.4.1.1.2" )
-    {
-        private static final long serialVersionUID = 4048791282048841016L;
-
-
-        public int compare( Long o1, Long o2 )
-        {
-            if ( o1 == null )
-            {
-                throw new IllegalArgumentException( I18n.err( I18n.ERR_525 ) );
-            } 
-            else if ( o2 == null )
-            {
-                throw new IllegalArgumentException( I18n.err( I18n.ERR_526 ) );
-            }
-
-            if ( o1 == ( long ) o2 )
-            {
-                return 0;
-            }
-            
-            if ( o1 == ( long ) o2 )
-            {
-                return 0;
-            }
-            
-            if ( o1 >= 0 )
-            {
-                if ( o2 >= 0 )
-                {
-                    return ( o1 > ( long ) o2 ) ? 1 : -1;
-                }
-                else
-                {
-                    return -1;
-                }
-            }
-            else if ( o2 >= 0 )
-            {
-                return 1;
-            }
-            else
-            {
-                return ( o1 < ( long ) o2 ) ? -1 : 1;
-            }
-        }
-    };
-
-
-    private static final SerializableComparator<String> STRING_COMPARATOR =
-            new SerializableComparator<String>( "1.3.6.1.4.1.18060.0.4.1.1.3" )
-    {
-        private static final long serialVersionUID = 3258689922792961845L;
-
-
-        public int compare( String o1, String o2 )
-        {
-            return STRCOMP.compare( o1, o2 );
-        }
-    };
-
-
-    protected final JdbmTable<String,String> adminTbl;
-
-
     /**
      * Creates the master table using JDBM B+Trees for the backing store.
      *
@@ -116,56 +51,23 @@ public class JdbmMasterTable<E> extends 
      */
     public JdbmMasterTable( RecordManager recMan, SchemaManager schemaManager ) throws Exception
     {
-        super( schemaManager, DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, new EntrySerializer( schemaManager ) );
-        adminTbl = new JdbmTable<String,String>( schemaManager, "admin", recMan, STRING_COMPARATOR, null, null );
-        String seqValue = adminTbl.get( SEQPROP_KEY );
-
-        if ( null == seqValue )
-        {
-            adminTbl.put( SEQPROP_KEY, "0" );
-        }
-        
-        LONG_COMPARATOR.setSchemaManager( schemaManager );
-        STRING_COMPARATOR.setSchemaManager( schemaManager );
+        super( schemaManager, DBF, recMan, UUIDComparator.INSTANCE, UUIDSerializer.INSTANCE, new EntrySerializer( schemaManager ) );
     }
 
 
     protected JdbmMasterTable( RecordManager recMan, SchemaManager schemaManager, String dbName, Serializer serializer ) throws Exception
     {
-        super( schemaManager, DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, serializer );
-        adminTbl = new JdbmTable<String,String>( schemaManager, dbName, recMan, STRING_COMPARATOR, null, null );
-        String seqValue = adminTbl.get( SEQPROP_KEY );
-
-        if ( null == seqValue )
-        {
-            adminTbl.put( SEQPROP_KEY, "0" );
-        }
+        super( schemaManager, DBF, recMan, UUIDComparator.INSTANCE, UUIDSerializer.INSTANCE, serializer );
     }
 
-
     /**
-     * Get's the next value from this SequenceBDb.  This has the side-effect of
-     * changing the current sequence values permanently in memory and on disk.
-     * Master table sequence begins at BigInteger.ONE.  The BigInteger.ZERO is
-     * used for the fictitious parent of the suffix root entry.
-     *
-     * @return the current value incremented by one.
-     * @throws Exception if the admin table storing sequences cannot be
-     *                         read and written to.
+     * {@inheritDoc}
      */
-    public Long getNextId( E entry ) throws Exception
+    public UUID getNextId( Entry entry ) throws Exception
     {
-        Long nextVal;
-        Long lastVal;
-
-        synchronized ( adminTbl )
-        {
-            lastVal = new Long( adminTbl.get( SEQPROP_KEY ) );
-            nextVal = lastVal + 1L;
-            adminTbl.put( SEQPROP_KEY, nextVal.toString() );
-        }
-
-        return nextVal;
+        String name = entry.get( SchemaConstants.ENTRY_UUID_AT ).getString();
+        UUID uuid = UUID.fromString( name );
+        return uuid; 
     }
 
 
@@ -174,9 +76,5 @@ public class JdbmMasterTable<E> extends 
      */
     public void resetCounter() throws Exception
     {
-        synchronized ( adminTbl )
-        {
-            adminTbl.put( SEQPROP_KEY, "0" );
-        }
     }
 }

Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=1199854&r1=1199853&r2=1199854&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original)
+++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Wed Nov  9 17:05:40 2011
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.UUID;
 
 import jdbm.RecordManager;
 import jdbm.recman.BaseRecordManager;
@@ -59,7 +60,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class JdbmPartition extends AbstractBTreePartition<Long>
+public class JdbmPartition extends AbstractBTreePartition
 {
     /** static logger */
     private static final Logger LOG = LoggerFactory.getLogger( JdbmPartition.class );
@@ -110,13 +111,13 @@ public class JdbmPartition extends Abstr
             }
             else
             {
-                optimizer = new DefaultOptimizer<Entry, Long>( this );
+                optimizer = new DefaultOptimizer( this );
             }
     
-            EvaluatorBuilder<Long> evaluatorBuilder = new EvaluatorBuilder<Long>( this, schemaManager );
-            CursorBuilder<Long> cursorBuilder = new CursorBuilder<Long>( this, evaluatorBuilder );
+            EvaluatorBuilder evaluatorBuilder = new EvaluatorBuilder( this, schemaManager );
+            CursorBuilder cursorBuilder = new CursorBuilder( this, evaluatorBuilder );
     
-            searchEngine = new DefaultSearchEngine<Long>( this, cursorBuilder, evaluatorBuilder, optimizer );
+            searchEngine = new DefaultSearchEngine( this, cursorBuilder, evaluatorBuilder, optimizer );
 
             // Create the underlying directories (only if needed)
             File partitionDir = new File( getPartitionPath() );
@@ -147,7 +148,7 @@ public class JdbmPartition extends Abstr
             recMan = new SnapshotRecordManager( baseRecordManager, cacheSize );
     
             // Create the master table (the table containing all the entries)
-            master = new JdbmMasterTable<Entry>( recMan, schemaManager );
+            master = new JdbmMasterTable( recMan, schemaManager );
     
             // get all index db files first
             File[] allIndexDbFiles = partitionDir.listFiles( DB_FILTER );
@@ -158,7 +159,7 @@ public class JdbmPartition extends Abstr
             // then add all index objects to a list
             List<String> allIndices = new ArrayList<String>();
             
-            for( Index<?, Entry, Long> index : systemIndices.values() )
+            for( Index<?> index : systemIndices.values() )
             {
                 allIndices.add( index.getAttribute().getOid() );
             }
@@ -167,7 +168,7 @@ public class JdbmPartition extends Abstr
             // one for collecting all user indices
             // two for finding a new index to be built
             // just to avoid another iteration for determining which is the new index
-            for( Index<?, Entry, Long> index : userIndices.values() )
+            for( Index<?> index : userIndices.values() )
             {
                 allIndices.add( index.getAttributeId() );
     
@@ -189,24 +190,6 @@ public class JdbmPartition extends Abstr
         }
     }
 
-    
-    /**
-     * {@inheritDoc}}
-     */
-    public Long getDefaultId()
-    {
-        return 1L;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Long getRootId()
-    {
-        return 0L;
-    }
-
 
     /**
      * This method is called when the synch thread is waking up, to write
@@ -222,18 +205,18 @@ public class JdbmPartition extends Abstr
         }
 
         // Sync all system indices
-        for ( Index<?, Entry, Long> idx : systemIndices.values() )
+        for ( Index<?> idx : systemIndices.values() )
         {
             idx.sync();
         }
         
         // Sync all user defined userIndices
-        for ( Index<?, Entry, Long> idx : userIndices.values() )
+        for ( Index<?> idx : userIndices.values() )
         {
             idx.sync();
         }
 
-        ( ( JdbmMasterTable<Entry> ) master ).sync();
+        ( ( JdbmMasterTable ) master ).sync();
         recMan.commit();
     }
     
@@ -250,16 +233,16 @@ public class JdbmPartition extends Abstr
 
         LOG.info( "building the index for attribute type {}", atType );
         
-        Cursor<Tuple<Long,Entry>> cursor = master.cursor();
+        Cursor<Tuple<UUID,Entry>> cursor = master.cursor();
         cursor.beforeFirst();
         
         String attributeOid = userIdx.getAttribute().getOid();
         
         while ( cursor.next() )
         {
-            Tuple<Long,Entry> tuple = cursor.get();
+            Tuple<UUID,Entry> tuple = cursor.get();
             
-            Long id = tuple.getKey();
+            UUID id = tuple.getKey();
             Entry entry = tuple.getValue();
             
             Attribute entryAttr = entry.get( atType );
@@ -329,9 +312,9 @@ public class JdbmPartition extends Abstr
     /**
      * {@inheritDoc}
      */
-    protected Index<?, Entry, Long> convertAndInit( Index<?, Entry, Long> index ) throws Exception
+    protected Index<?> convertAndInit( Index<?> index ) throws Exception
     {
-        JdbmIndex<?, Entry> jdbmIndex;
+        JdbmIndex<?> jdbmIndex;
         
         if ( index.getAttributeId().equals( ApacheSchemaConstants.APACHE_RDN_AT_OID ) )
         {
@@ -341,9 +324,9 @@ public class JdbmPartition extends Abstr
             jdbmIndex.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
             jdbmIndex.setWkDirPath( index.getWkDirPath() );
         }
-        else if ( index instanceof JdbmIndex<?, ?> )
+        else if ( index instanceof JdbmIndex<?> )
         {
-            jdbmIndex = ( JdbmIndex<?, Entry> ) index;
+            jdbmIndex = ( JdbmIndex<?> ) index;
             
             if ( jdbmIndex.getWkDirPath() == null )
             {

Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java?rev=1199854&r1=1199853&r2=1199854&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java (original)
+++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java Wed Nov  9 17:05:40 2011
@@ -24,6 +24,7 @@ package org.apache.directory.server.core
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.util.UUID;
 
 import javax.naming.NamingException;
 
@@ -34,6 +35,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.core.api.partition.index.ParentIdAndRdn;
 import org.apache.directory.server.core.api.partition.index.ParentIdAndRdnComparator;
+import org.apache.directory.server.core.api.partition.index.UUIDComparator;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
 import org.apache.directory.shared.ldap.model.schema.MatchingRule;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
@@ -47,7 +49,7 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class JdbmRdnIndex<E> extends JdbmIndex<ParentIdAndRdn<Long>, E>
+public class JdbmRdnIndex<E> extends JdbmIndex<ParentIdAndRdn>
 {
 
     /** A logger for this class */
@@ -134,36 +136,34 @@ public class JdbmRdnIndex<E> extends Jdb
             throw new IOException( I18n.err( I18n.ERR_574, attributeType.getName() ) );
         }
 
-        ParentIdAndRdnComparator<Long> comp = new ParentIdAndRdnComparator<Long>( mr.getOid() );
+        ParentIdAndRdnComparator comp = new ParentIdAndRdnComparator( mr.getOid() );
 
-        LongComparator.INSTANCE.setSchemaManager( schemaManager );
-
-        forward = new JdbmTable<ParentIdAndRdn<Long>, Long>( schemaManager, attributeType.getOid() + FORWARD_BTREE,
-            recMan, comp, null, LongSerializer.INSTANCE );
-        reverse = new JdbmTable<Long, ParentIdAndRdn<Long>>( schemaManager, attributeType.getOid() + REVERSE_BTREE,
-            recMan, LongComparator.INSTANCE, LongSerializer.INSTANCE, null );
+        forward = new JdbmTable<ParentIdAndRdn, UUID>( schemaManager, attributeType.getOid() + FORWARD_BTREE,
+            recMan, comp, null, UUIDSerializer.INSTANCE );
+        reverse = new JdbmTable<UUID, ParentIdAndRdn>( schemaManager, attributeType.getOid() + REVERSE_BTREE,
+            recMan, UUIDComparator.INSTANCE, UUIDSerializer.INSTANCE, null );
     }
 
 
-    public void add( ParentIdAndRdn<Long> rdn, Long entryId ) throws Exception
+    public void add( ParentIdAndRdn rdn, UUID entryId ) throws Exception
     {
         forward.put( rdn, entryId );
         reverse.put( entryId, rdn );
     }
 
 
-    public void drop( Long entryId ) throws Exception
+    public void drop( UUID entryId ) throws Exception
     {
-        ParentIdAndRdn<Long> rdn = reverse.get( entryId );
+        ParentIdAndRdn rdn = reverse.get( entryId );
         forward.remove( rdn );
         reverse.remove( entryId );
     }
 
 
-    public void drop( ParentIdAndRdn<Long> rdn, Long id ) throws Exception
+    public void drop( ParentIdAndRdn rdn, UUID id ) throws Exception
     {
-        long val = forward.get( rdn );
-        if ( val == id )
+        UUID val = forward.get( rdn );
+        if ( val.compareTo( id ) == 0 )
         {
             forward.remove( rdn );
             reverse.remove( val );
@@ -171,7 +171,7 @@ public class JdbmRdnIndex<E> extends Jdb
     }
 
 
-    public ParentIdAndRdn<Long> getNormalized( ParentIdAndRdn<Long> rdn ) throws Exception
+    public ParentIdAndRdn getNormalized( ParentIdAndRdn rdn ) throws Exception
     {
         return rdn;
     }

Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java?rev=1199854&r1=1199853&r2=1199854&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java (original)
+++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java Wed Nov  9 17:05:40 2011
@@ -28,6 +28,7 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.UUID;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.core.api.partition.index.Index;
@@ -56,7 +57,7 @@ import org.junit.Test;
 public class JdbmIndexTest
 {
     private static File dbFileDir;
-    Index<String, Entry, Long> idx;
+    Index<String> idx;
     private static SchemaManager schemaManager;
 
 
@@ -137,17 +138,17 @@ public class JdbmIndexTest
 
     void initIndex() throws Exception
     {
-        JdbmIndex<String, Entry> index = new JdbmIndex<String, Entry>();
+        JdbmIndex<String> index = new JdbmIndex<String>();
         index.setWkDirPath( dbFileDir.toURI() );
         initIndex( index );
     }
 
 
-    void initIndex( JdbmIndex<String, Entry> jdbmIdx ) throws Exception
+    void initIndex( JdbmIndex<String> jdbmIdx ) throws Exception
     {
         if ( jdbmIdx == null )
         {
-            jdbmIdx = new JdbmIndex<String, Entry>();
+            jdbmIdx = new JdbmIndex<String>();
         }
         
         AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT );
@@ -165,11 +166,11 @@ public class JdbmIndexTest
     public void testAttributeId() throws Exception
     {
         // uninitialized index
-        JdbmIndex<Object, Object> jdbmIndex1 = new JdbmIndex<Object, Object>();
+        JdbmIndex<Object> jdbmIndex1 = new JdbmIndex<Object>();
         jdbmIndex1.setAttributeId( "foo" );
         assertEquals( "foo", jdbmIndex1.getAttributeId() );
 
-        JdbmIndex<Object, Object> jdbmIndex2 = new JdbmIndex<Object, Object>( "bar" );
+        JdbmIndex<Object> jdbmIndex2 = new JdbmIndex<Object>( "bar" );
         assertEquals( "bar", jdbmIndex2.getAttributeId() );
 
         // initialized index
@@ -187,7 +188,7 @@ public class JdbmIndexTest
         assertEquals( "ou", idx.getAttributeId() );
 
         destroyIndex();
-        JdbmIndex<String, Entry> index = new JdbmIndex<String, Entry>( "foo" );
+        JdbmIndex<String> index = new JdbmIndex<String>( "foo" );
         index.setWkDirPath( dbFileDir.toURI() );
         initIndex( index );
         assertEquals( "foo", idx.getAttributeId() );
@@ -198,7 +199,7 @@ public class JdbmIndexTest
     public void testCacheSize() throws Exception
     {
         // uninitialized index
-        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+        JdbmIndex<Object> jdbmIndex = new JdbmIndex<Object>();
         jdbmIndex.setCacheSize( 337 );
         assertEquals( 337, jdbmIndex.getCacheSize() );
 
@@ -222,7 +223,7 @@ public class JdbmIndexTest
         File wkdir = new File( dbFileDir, "foo" );
 
         // uninitialized index
-        JdbmIndex<String, Entry> jdbmIndex = new JdbmIndex<String, Entry>();
+        JdbmIndex<String> jdbmIndex = new JdbmIndex<String>();
         jdbmIndex.setWkDirPath( wkdir.toURI() );
         assertEquals( "foo", new File( jdbmIndex.getWkDirPath() ).getName() );
 
@@ -241,7 +242,7 @@ public class JdbmIndexTest
         assertEquals( dbFileDir.toURI(), idx.getWkDirPath() );
 
         destroyIndex();
-        jdbmIndex = new JdbmIndex<String, Entry>();
+        jdbmIndex = new JdbmIndex<String>();
         wkdir.mkdirs();
         jdbmIndex.setWkDirPath( wkdir.toURI() );
         initIndex( jdbmIndex );
@@ -253,7 +254,7 @@ public class JdbmIndexTest
     public void testNumDupLimit() throws Exception
     {
         // uninitialized index
-        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+        JdbmIndex<Object> jdbmIndex = new JdbmIndex<Object>();
         jdbmIndex.setNumDupLimit( 337 );
         assertEquals( 337, jdbmIndex.getNumDupLimit() );
 
@@ -261,13 +262,13 @@ public class JdbmIndexTest
         initIndex();
         try
         {
-            ( ( JdbmIndex<String, Entry> ) idx ).setNumDupLimit( 30 );
+            ( ( JdbmIndex<String> ) idx ).setNumDupLimit( 30 );
             fail( "Should not be able to set numDupLimit after initialization." );
         }
         catch ( Exception e )
         {
         }
-        assertEquals( JdbmIndex.DEFAULT_DUPLICATE_LIMIT, ( ( JdbmIndex<String, Entry> ) idx ).getNumDupLimit() );
+        assertEquals( JdbmIndex.DEFAULT_DUPLICATE_LIMIT, ( ( JdbmIndex<String> ) idx ).getNumDupLimit() );
     }
 
 
@@ -275,7 +276,7 @@ public class JdbmIndexTest
     public void testGetAttribute() throws Exception
     {
         // uninitialized index
-        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+        JdbmIndex<Object> jdbmIndex = new JdbmIndex<Object>();
         assertNull( jdbmIndex.getAttribute() );
 
         initIndex();
@@ -293,13 +294,13 @@ public class JdbmIndexTest
         initIndex();
         assertEquals( 0, idx.count() );
 
-        idx.add( "foo", 1234L );
+        idx.add( "foo", getUUIDString( 1234 ) );
         assertEquals( 1, idx.count() );
 
-        idx.add( "foo", 333L );
+        idx.add( "foo", getUUIDString( 333 ) );
         assertEquals( 2, idx.count() );
 
-        idx.add( "bar", 555L );
+        idx.add( "bar", getUUIDString( 555 ) );
         assertEquals( 3, idx.count() );
     }
 
@@ -310,13 +311,13 @@ public class JdbmIndexTest
         initIndex();
         assertEquals( 0, idx.count( "foo" ) );
 
-        idx.add( "bar", 1234L );
+        idx.add( "bar", getUUIDString( 1234 ) );
         assertEquals( 0, idx.count( "foo" ) );
 
-        idx.add( "foo", 1234L );
+        idx.add( "foo", getUUIDString( 1234 ) );
         assertEquals( 1, idx.count( "foo" ) );
 
-        idx.add( "foo", 333L );
+        idx.add( "foo", getUUIDString( 333 ) );
         assertEquals( 2, idx.count( "foo" ) );
     }
 
@@ -329,7 +330,7 @@ public class JdbmIndexTest
 
         for ( char ch = 'a'; ch <= 'z'; ch++ )
         {
-            idx.add( String.valueOf( ch ), ( long ) ch );
+            idx.add( String.valueOf( ch ), getUUIDString( ( int ) ch ) );
         }
         assertEquals( 26, idx.greaterThanCount( "a" ) );
     }
@@ -343,7 +344,7 @@ public class JdbmIndexTest
 
         for ( char ch = 'a'; ch <= 'z'; ch++ )
         {
-            idx.add( String.valueOf( ch ), ( long ) ch );
+            idx.add( String.valueOf( ch ), getUUIDString( ( int ) ch ) );
         }
         assertEquals( 26, idx.lessThanCount( "z" ) );
     }
@@ -359,58 +360,58 @@ public class JdbmIndexTest
         initIndex();
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", 0L ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", -24L ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", 24L ) );
-        assertFalse( idx.forwardLessOrEq( "foo", 0L ) );
-        assertFalse( idx.forwardLessOrEq( "foo", 24L ) );
-        assertFalse( idx.forwardLessOrEq( "foo", -24L ) );
-
-        idx.add( "foo", 0L );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
-        assertTrue( idx.forward( "foo", 0L ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", 1L ) );
-        assertTrue( idx.forwardLessOrEq( "foo", 0L ) );
-        assertTrue( idx.forwardLessOrEq( "foo", 1L ) );
-        assertFalse( idx.forwardLessOrEq( "foo", -1L ) );
-
-        idx.add( "foo", 1L );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
-        assertTrue( idx.forward( "foo", 0L ) );
-        assertTrue( idx.forward( "foo", 1L ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", 1L ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", 2L ) );
-        assertTrue( idx.forwardLessOrEq( "foo", 0L ) );
-        assertTrue( idx.forwardLessOrEq( "foo", 1L ) );
-        assertTrue( idx.forwardLessOrEq( "foo", 2L ) );
-        assertFalse( idx.forwardLessOrEq( "foo", -1L ) );
-
-        idx.add( "bar", 0L );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
-        assertEquals( "bar", idx.reverseLookup( 0L ) ); // reverse lookup returns first val
-        assertTrue( idx.forward( "bar", 0L ) );
-        assertTrue( idx.forward( "foo", 0L ) );
-        assertTrue( idx.forward( "foo", 1L ) );
-        assertTrue( idx.forwardGreaterOrEq( "bar", 0L ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", 0L ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", 1L ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", -1L ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", 2L ) );
-        assertFalse( idx.forwardGreaterOrEq( "bar", 1L ) );
-        assertTrue( idx.forwardLessOrEq( "bar", 0L ) );
-        assertTrue( idx.forwardLessOrEq( "foo", 0L ) );
-        assertTrue( idx.forwardLessOrEq( "foo", 1L ) );
-        assertTrue( idx.forwardLessOrEq( "foo", 2L ) );
-        assertFalse( idx.forwardLessOrEq( "foo", -1L ) );
-        assertFalse( idx.forwardLessOrEq( "bar", -1L ) );
+        assertNull( idx.reverseLookup( getUUIDString( 0 ) ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", getUUIDString( 0 ) ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", getUUIDString( -24 ) ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", getUUIDString( 24 ) ) );
+        assertFalse( idx.forwardLessOrEq( "foo", getUUIDString( 0 ) ) );
+        assertFalse( idx.forwardLessOrEq( "foo", getUUIDString( 24 ) ) );
+        assertFalse( idx.forwardLessOrEq( "foo", getUUIDString( -24 ) ) );
+
+        idx.add( "foo", getUUIDString( 1 ) );
+        assertEquals( getUUIDString( 1 ), idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 1 ) ) );
+        assertTrue( idx.forward( "foo", getUUIDString( 1 ) ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", getUUIDString( 1 ) ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", getUUIDString( 0 ) ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", getUUIDString( 2 ) ) );
+        assertTrue( idx.forwardLessOrEq( "foo", getUUIDString( 1 ) ) );
+        assertTrue( idx.forwardLessOrEq( "foo", getUUIDString( 2 ) ) );
+        assertFalse( idx.forwardLessOrEq( "foo", getUUIDString( 0 ) ) );
+
+        idx.add( "foo", getUUIDString( 2 ) );
+        assertEquals( getUUIDString( 1 ), idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 1 ) ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 2 ) ) );
+        assertTrue( idx.forward( "foo", getUUIDString( 1 ) ) );
+        assertTrue( idx.forward( "foo", getUUIDString( 2 ) ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", getUUIDString( 1 ) ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", getUUIDString( 2 ) ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", getUUIDString( 0 ) ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", getUUIDString( 3 ) ) );
+        assertTrue( idx.forwardLessOrEq( "foo", getUUIDString( 1 ) ) );
+        assertTrue( idx.forwardLessOrEq( "foo", getUUIDString( 2 ) ) );
+        assertTrue( idx.forwardLessOrEq( "foo", getUUIDString( 3 ) ) );
+        assertFalse( idx.forwardLessOrEq( "foo", getUUIDString( 0 ) ) );
+
+        idx.add( "bar", getUUIDString( 1 ) );
+        assertEquals( getUUIDString( 1 ), idx.forwardLookup( "bar" ) );
+        assertEquals( "bar", idx.reverseLookup( getUUIDString( 1 ) ) ); // reverse lookup returns first val
+        assertTrue( idx.forward( "bar", getUUIDString( 1 ) ) );
+        assertTrue( idx.forward( "foo", getUUIDString( 1 ) ) );
+        assertTrue( idx.forward( "foo", getUUIDString( 2 ) ) );
+        assertTrue( idx.forwardGreaterOrEq( "bar", getUUIDString( 1 ) ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", getUUIDString( 1 ) ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", getUUIDString( 2 ) ) );
+        assertTrue( idx.forwardGreaterOrEq( "foo", getUUIDString( 0 ) ) );
+        assertFalse( idx.forwardGreaterOrEq( "foo", getUUIDString( 3 ) ) );
+        assertFalse( idx.forwardGreaterOrEq( "bar", getUUIDString( 2 ) ) );
+        assertTrue( idx.forwardLessOrEq( "bar", getUUIDString( 1 ) ) );
+        assertTrue( idx.forwardLessOrEq( "foo", getUUIDString( 1 ) ) );
+        assertTrue( idx.forwardLessOrEq( "foo", getUUIDString( 2 ) ) );
+        assertTrue( idx.forwardLessOrEq( "foo", getUUIDString( 3 ) ) );
+        assertFalse( idx.forwardLessOrEq( "foo", getUUIDString( 0 ) ) );
+        assertFalse( idx.forwardLessOrEq( "bar", getUUIDString( 0 ) ) );
     }
 
 
@@ -420,37 +421,37 @@ public class JdbmIndexTest
         initIndex();
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
-        assertNull( idx.reverseLookup( 1L ) );
+        assertNull( idx.reverseLookup( getUUIDString( 0 ) ) );
+        assertNull( idx.reverseLookup( getUUIDString( 1 ) ) );
 
         // test add/drop without adding any duplicates
-        idx.add( "foo", 0L );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
+        idx.add( "foo", getUUIDString( 0 ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 0 ) ) );
 
-        idx.drop( 0L );
+        idx.drop( getUUIDString( 0 ) );
         assertNull( idx.forwardLookup( "foo" ) );
-        assertNull( idx.reverseLookup( 0L ) );
+        assertNull( idx.reverseLookup( getUUIDString( 0 ) ) );
 
         // test add/drop with duplicates in bulk
-        idx.add( "foo", 0L );
-        idx.add( "foo", 1L );
-        idx.add( "bar", 0L );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
-        assertEquals( "bar", idx.reverseLookup( 0L ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
-
-        idx.drop( 0L );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
-        assertFalse( idx.forward( "bar", 0L ) );
-        assertFalse( idx.forward( "foo", 0L ) );
+        idx.add( "foo", getUUIDString( 0 ) );
+        idx.add( "foo", getUUIDString( 1 ) );
+        idx.add( "bar", getUUIDString( 0 ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( "foo" ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( "bar" ) );
+        assertEquals( "bar", idx.reverseLookup( getUUIDString( 0 ) ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 1 ) ) );
+
+        idx.drop( getUUIDString( 0 ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 1 ) ) );
+        assertFalse( idx.forward( "bar", getUUIDString( 0 ) ) );
+        assertFalse( idx.forward( "foo", getUUIDString( 0 ) ) );
 
-        idx.drop( 1L );
+        idx.drop( getUUIDString( 1 ) );
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
-        assertNull( idx.reverseLookup( 1L ) );
+        assertNull( idx.reverseLookup( getUUIDString( 0 ) ) );
+        assertNull( idx.reverseLookup( getUUIDString( 1 ) ) );
         assertEquals( 0, idx.count() );
     }
 
@@ -461,43 +462,43 @@ public class JdbmIndexTest
         initIndex();
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
-        assertNull( idx.reverseLookup( 1L ) );
+        assertNull( idx.reverseLookup( getUUIDString( 0 ) ) );
+        assertNull( idx.reverseLookup( getUUIDString( 1 ) ) );
 
         // test add/drop without adding any duplicates
-        idx.add( "foo", 0L );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
+        idx.add( "foo", getUUIDString( 0 ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 0 ) ) );
 
-        idx.drop( "foo", 0L );
+        idx.drop( "foo", getUUIDString( 0 ) );
         assertNull( idx.forwardLookup( "foo" ) );
-        assertNull( idx.reverseLookup( 0L ) );
+        assertNull( idx.reverseLookup( getUUIDString( 0 ) ) );
 
         // test add/drop with duplicates but one at a time
-        idx.add( "foo", 0L );
-        idx.add( "foo", 1L );
-        idx.add( "bar", 0L );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "bar" ) );
-        assertEquals( "bar", idx.reverseLookup( 0L ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
-
-        idx.drop( "bar", 0L );
-        assertEquals( 0L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 0L ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
-        assertFalse( idx.forward( "bar", 0L ) );
-
-        idx.drop( "foo", 0L );
-        assertEquals( 1L, ( long ) idx.forwardLookup( "foo" ) );
-        assertEquals( "foo", idx.reverseLookup( 1L ) );
-        assertFalse( idx.forward( "foo", 0L ) );
+        idx.add( "foo", getUUIDString( 0 ) );
+        idx.add( "foo", getUUIDString( 1 ) );
+        idx.add( "bar", getUUIDString( 0 ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( "foo" ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( "bar" ) );
+        assertEquals( "bar", idx.reverseLookup( getUUIDString( 0 ) ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 1 ) ) );
+
+        idx.drop( "bar", getUUIDString( 0 ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 0 ) ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 1 ) ) );
+        assertFalse( idx.forward( "bar", getUUIDString( 0 ) ) );
+
+        idx.drop( "foo", getUUIDString( 0 ) );
+        assertEquals( getUUIDString( 1 ), idx.forwardLookup( "foo" ) );
+        assertEquals( "foo", idx.reverseLookup( getUUIDString( 1 ) ) );
+        assertFalse( idx.forward( "foo", getUUIDString( 0 ) ) );
 
-        idx.drop( "foo", 1L );
+        idx.drop( "foo", getUUIDString( 1 ) );
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertNull( idx.reverseLookup( 0L ) );
-        assertNull( idx.reverseLookup( 1L ) );
+        assertNull( idx.reverseLookup( getUUIDString( 0 ) ) );
+        assertNull( idx.reverseLookup( getUUIDString( 1 ) ) );
         assertEquals( 0, idx.count() );
     }
 
@@ -512,32 +513,32 @@ public class JdbmIndexTest
         initIndex();
         assertEquals( 0, idx.count() );
 
-        idx.add( "foo", 1234L );
+        idx.add( "foo", getUUIDString( 1234 ) );
         assertEquals( 1, idx.count() );
 
-        idx.add( "foo", 333L );
+        idx.add( "foo", getUUIDString( 333 ) );
         assertEquals( 2, idx.count() );
 
-        idx.add( "bar", 555L );
+        idx.add( "bar", getUUIDString( 555 ) );
         assertEquals( 3, idx.count() );
 
         // use forward index's cursor
-        Cursor<IndexEntry<String, Long>> cursor = idx.forwardCursor();
+        Cursor<IndexEntry<String>> cursor = idx.forwardCursor();
         cursor.beforeFirst();
 
         cursor.next();
-        IndexEntry<String, Long> e1 = cursor.get();
-        assertEquals( 555L, ( long ) e1.getId() );
+        IndexEntry<String> e1 = cursor.get();
+        assertEquals( getUUIDString( 555 ), e1.getId() );
         assertEquals( "bar", e1.getValue() );
 
         cursor.next();
-        IndexEntry<String, Long> e2 = cursor.get();
-        assertEquals( 333L, ( long ) e2.getId() );
+        IndexEntry<String> e2 = cursor.get();
+        assertEquals( getUUIDString( 333 ), e2.getId() );
         assertEquals( "foo", e2.getValue() );
 
         cursor.next();
-        IndexEntry<String, Long> e3 = cursor.get();
-        assertEquals( 1234L, ( long ) e3.getId() );
+        IndexEntry<String> e3 = cursor.get();
+        assertEquals( getUUIDString( 1234 ), e3.getId() );
         assertEquals( "foo", e3.getValue() );
 
         // use reverse index's cursor
@@ -546,17 +547,17 @@ public class JdbmIndexTest
 
         cursor.next();
         e1 = cursor.get();
-        assertEquals( 333L, ( long ) e1.getId() );
+        assertEquals( getUUIDString( 333 ), e1.getId() );
         assertEquals( "foo", e1.getValue() );
 
         cursor.next();
         e2 = cursor.get();
-        assertEquals( 555L, ( long ) e2.getId() );
+        assertEquals( getUUIDString( 555 ), e2.getId() );
         assertEquals( "bar", e2.getValue() );
 
         cursor.next();
         e3 = cursor.get();
-        assertEquals( 1234L, ( long ) e3.getId() );
+        assertEquals( getUUIDString( 1234 ), e3.getId() );
         assertEquals( "foo", e3.getValue() );
     }
 
@@ -564,7 +565,7 @@ public class JdbmIndexTest
     @Test
     public void testNoEqualityMatching() throws Exception
     {
-        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+        JdbmIndex<Object> jdbmIndex = new JdbmIndex<Object>();
 
         try
         {
@@ -586,9 +587,21 @@ public class JdbmIndexTest
     @Test
     public void testSingleValuedAttribute() throws Exception
     {
-        JdbmIndex<Object, Object> jdbmIndex = new JdbmIndex<Object, Object>();
+        JdbmIndex<Object> jdbmIndex = new JdbmIndex<Object>();
         jdbmIndex.setWkDirPath( dbFileDir.toURI() );
         jdbmIndex.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.CREATORS_NAME_AT ) );
         jdbmIndex.close();
     }
+    
+    public static UUID getUUIDString( int idx )
+    {
+        /** UUID string */
+        UUID baseUUID = UUID.fromString( "00000000-0000-0000-0000-000000000000" );
+        
+        long low = baseUUID.getLeastSignificantBits();
+        long high = baseUUID.getMostSignificantBits();
+        low = low + idx;
+        
+        return new UUID( high, low );
+    }
 }

Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java?rev=1199854&r1=1199853&r2=1199854&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java (original)
+++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java Wed Nov  9 17:05:40 2011
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.fail;
 
 import java.io.File;
+import java.util.UUID;
 
 import jdbm.RecordManager;
 import jdbm.recman.BaseRecordManager;
@@ -52,7 +53,7 @@ public class JdbmMasterTableTest
     private static final Logger LOG = LoggerFactory.getLogger( JdbmMasterTableTest.class.getSimpleName() );
     private static final String TEST_OUTPUT_PATH = "test.output.path";
 
-    JdbmMasterTable<Integer> table;
+    JdbmMasterTable table;
     File dbFile;
     RecordManager recman;
     SchemaManager schemaManager = null;
@@ -98,10 +99,10 @@ public class JdbmMasterTableTest
         dbFile = File.createTempFile( getClass().getSimpleName(), "db", tmpDir );
         recman = new BaseRecordManager( dbFile.getAbsolutePath() );
 
-        table = new JdbmMasterTable<Integer>( recman, schemaManager );
+        table = new JdbmMasterTable( recman, schemaManager );
         LOG.debug( "Created new table and populated it with data" );
 
-        JdbmMasterTable<Integer> t2 = new JdbmMasterTable<Integer>( recman, schemaManager );
+        JdbmMasterTable t2 = new JdbmMasterTable( recman, schemaManager );
         t2.close();
     }
 
@@ -139,12 +140,7 @@ public class JdbmMasterTableTest
     @Test
     public void testAll() throws Exception
     {
-        assertNull( table.get( 0L ) );
+        assertNull( table.get( UUID.fromString( "00000000-0000-0000-0000-000000000000" ) ) );
         assertEquals( 0, table.count() );
-
-        assertEquals( 1, ( long ) table.getNextId( null ) );
-        assertEquals( 0, table.count() );
-
-        assertEquals( 2, ( long ) table.getNextId( null ) );
     }
 }

Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java?rev=1199854&r1=1199853&r2=1199854&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java (original)
+++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java Wed Nov  9 17:05:40 2011
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.UUID;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
@@ -55,7 +56,7 @@ import org.junit.Test;
 public class JdbmRdnIndexTest
 {
     private static File dbFileDir;
-    Index<ParentIdAndRdn<Long>, Long, Long> idx;
+    Index<ParentIdAndRdn> idx;
     private static SchemaManager schemaManager;
 
 
@@ -240,23 +241,23 @@ public class JdbmRdnIndexTest
         initIndex();
         assertEquals( 0, idx.count() );
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( getUUIDString( 0 ), new Rdn( "cn=key" ) );
 
-        idx.add( key, 0l );
+        idx.add( key, getUUIDString( 0 ) );
         assertEquals( 1, idx.count() );
 
         // setting a different parentId should make this key a different key
-        key = new ParentIdAndRdn<Long>( 1L, new Rdn( "cn=key" ) );
+        key = new ParentIdAndRdn( getUUIDString( 1 ), new Rdn( "cn=key" ) );
         
-        idx.add( key, 1l );
+        idx.add( key, getUUIDString( 1 ) );
         assertEquals( 2, idx.count() );
 
         //count shouldn't get affected cause of inserting the same key
-        idx.add( key, 2l );
+        idx.add( key, getUUIDString( 2 ) );
         assertEquals( 2, idx.count() );
         
-        key = new ParentIdAndRdn<Long>( 2L, new Rdn( "cn=key" ) );
-        idx.add( key, 3l );
+        key = new ParentIdAndRdn( getUUIDString( 2 ), new Rdn( "cn=key" ) );
+        idx.add( key, getUUIDString( 3 ) );
         assertEquals( 3, idx.count() );
     }
 
@@ -266,11 +267,11 @@ public class JdbmRdnIndexTest
     {
         initIndex();
         
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( getUUIDString( 0 ), new Rdn( "cn=key" ) );
         
         assertEquals( 0, idx.count( key ) );
 
-        idx.add( key, 0l );
+        idx.add( key, getUUIDString( 0 ) );
         assertEquals( 1, idx.count( key ) );
     }
 
@@ -284,19 +285,19 @@ public class JdbmRdnIndexTest
     {
         initIndex();
         
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( schemaManager, "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( getUUIDString( 0 ), new Rdn( schemaManager, "cn=key" ) );
         
         assertNull( idx.forwardLookup( key ) );
 
-        idx.add( key, 0l );
-        assertEquals( 0, ( long ) idx.forwardLookup( key ) );
-        assertEquals( key, idx.reverseLookup( 0l ) );
+        idx.add( key, getUUIDString( 0 ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( key ) );
+        assertEquals( key, idx.reverseLookup( getUUIDString( 0 ) ) );
         
         // check with the different case in UP name, this ensures that the custom
         // key comparator is used
-        key = new ParentIdAndRdn<Long>( 0L, new Rdn( schemaManager, "cn=KEY" ) );
-        assertEquals( 0, ( long ) idx.forwardLookup( key ) );
-        assertEquals( key, idx.reverseLookup( 0l ) );
+        key = new ParentIdAndRdn( getUUIDString( 0 ), new Rdn( schemaManager, "cn=KEY" ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( key ) );
+        assertEquals( key, idx.reverseLookup( getUUIDString( 0 ) ) );
     }
 
 
@@ -305,17 +306,17 @@ public class JdbmRdnIndexTest
     {
         initIndex();
         
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( getUUIDString( 0 ), new Rdn( "cn=key" ) );
         
         assertNull( idx.forwardLookup( key ) );
 
         // test add/drop without adding any duplicates
-        idx.add( key, 0l );
-        assertEquals( 0, ( long ) idx.forwardLookup( key ) );
+        idx.add( key, getUUIDString( 0 ) );
+        assertEquals( getUUIDString( 0 ), idx.forwardLookup( key ) );
         
-        idx.drop( key, 0l );
+        idx.drop( key, getUUIDString( 0 ) );
         assertNull( idx.forwardLookup( key ) );
-        assertNull( idx.reverseLookup( 0l ) );
+        assertNull( idx.reverseLookup( getUUIDString( 0 ) ) );
     }
 
 
@@ -328,43 +329,43 @@ public class JdbmRdnIndexTest
     {
         initIndex();
         
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key" ) );
+        ParentIdAndRdn key = new ParentIdAndRdn( getUUIDString( 0 ), new Rdn( "cn=key" ) );
         
         assertEquals( 0, idx.count() );
 
-        idx.add( key, 0l );
+        idx.add( key, getUUIDString( 0 ) );
         assertEquals( 1, idx.count() );
         
         for( long i=1; i< 5; i++ )
         {
-            key = new ParentIdAndRdn<Long>( i, new Rdn( "cn=key" + i ) );
+            key = new ParentIdAndRdn( getUUIDString( ( int )i ), new Rdn( "cn=key" + i ) );
             
-            idx.add( key, ( long ) i );
+            idx.add( key, getUUIDString( ( int )i ) );
         }
 
         assertEquals( 5, idx.count() );
         
         // use forward index's cursor
-        Cursor<IndexEntry<ParentIdAndRdn<Long>, Long>> cursor = idx.forwardCursor();
+        Cursor<IndexEntry<ParentIdAndRdn>> cursor = idx.forwardCursor();
         cursor.beforeFirst();
 
         cursor.next();
-        IndexEntry<ParentIdAndRdn<Long>, Long> e1 = cursor.get();
-        assertEquals( 0, ( long ) e1.getId() );
+        IndexEntry<ParentIdAndRdn> e1 = cursor.get();
+        assertEquals( getUUIDString( 0 ), e1.getId() );
         assertEquals( "cn=key", e1.getValue().getRdns()[0].getName() );
-        assertEquals( 0, e1.getValue().getParentId().longValue() );
+        assertEquals( getUUIDString( 0 ), e1.getValue().getParentId() );
 
         cursor.next();
-        IndexEntry<ParentIdAndRdn<Long>, Long> e2 = cursor.get();
-        assertEquals( 1, ( long ) e2.getId() );
+        IndexEntry<ParentIdAndRdn> e2 = cursor.get();
+        assertEquals( getUUIDString( 1 ), e2.getId() );
         assertEquals( "cn=key1", e2.getValue().getRdns()[0].getName() );
-        assertEquals( 1, e2.getValue().getParentId().longValue() );
+        assertEquals( getUUIDString( 1 ), e2.getValue().getParentId() );
         
         cursor.next();
-        IndexEntry<ParentIdAndRdn<Long>, Long> e3 = cursor.get();
-        assertEquals( 2, ( long ) e3.getId() );
+        IndexEntry<ParentIdAndRdn> e3 = cursor.get();
+        assertEquals( getUUIDString( 2 ), e3.getId() );
         assertEquals( "cn=key2", e3.getValue().getRdns()[0].getName() );
-        assertEquals( 2, e3.getValue().getParentId().longValue() );
+        assertEquals( getUUIDString( 2 ), e3.getValue().getParentId() );
     }
 
 
@@ -385,4 +386,16 @@ public class JdbmRdnIndexTest
 //        InternalRdnComparator rdnCom = new InternalRdnComparator( "" );
 //        assertEquals( 0, rdnCom.compare( rdn, rdn2 ) );
 //    }
+    
+    public static UUID getUUIDString( int idx )
+    {
+        /** UUID string */
+        UUID baseUUID = UUID.fromString( "00000000-0000-0000-0000-000000000000" );
+        
+        long low = baseUUID.getLeastSignificantBits();
+        long high = baseUUID.getMostSignificantBits();
+        low = low + idx;
+        
+        return new UUID( high, low );
+    }
 }

Modified: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1199854&r1=1199853&r2=1199854&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Wed Nov  9 17:05:40 2011
@@ -216,11 +216,11 @@ public class JdbmStoreTest
         entry.add( "objectClass", "top", "domain" );
         entry.add( "dc", "example" );
         entry.add( SchemaConstants.ENTRY_CSN_AT, new CsnFactory( 0 ).newInstance().toString() );
-        entry.add( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
+        entry.add( SchemaConstants.ENTRY_UUID_AT, StoreUtils.getUUIDString( 1 ).toString() );
         store2.add( new AddOperationContext( null, entry ) );
 
         // lookup the context entry
-        Long id = store2.getEntryId( suffixDn );
+        UUID id = store2.getEntryId( suffixDn );
         Entry lookup = store2.lookup( id );
         assertEquals( 2, lookup.getDn().size() );
 
@@ -236,8 +236,8 @@ public class JdbmStoreTest
         jdbmPartition.setSyncOnWrite( true ); // for code coverage
 
         assertNull( jdbmPartition.getAliasIndex() );
-        Index<String, Entry, Long> index = new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
-        ((Store<Entry, Long>)jdbmPartition).addIndex( index );
+        Index<String> index = new JdbmIndex<String>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
+        ((Store)jdbmPartition).addIndex( index );
         assertNotNull( jdbmPartition.getAliasIndex() );
 
         assertEquals( JdbmPartition.DEFAULT_CACHE_SIZE, jdbmPartition.getCacheSize() );
@@ -245,15 +245,15 @@ public class JdbmStoreTest
         assertEquals( 24, jdbmPartition.getCacheSize() );
 
         assertNull( jdbmPartition.getPresenceIndex() );
-        jdbmPartition.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ) );
+        jdbmPartition.addIndex( new JdbmIndex<String>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ) );
         assertNotNull( jdbmPartition.getPresenceIndex() );
 
         assertNull( jdbmPartition.getOneLevelIndex() );
-        ((Store<Entry, Long>)jdbmPartition).addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
+        ((Store)jdbmPartition).addIndex( new JdbmIndex<UUID>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
         assertNotNull( jdbmPartition.getOneLevelIndex() );
 
         assertNull( jdbmPartition.getSubLevelIndex() );
-        ((Store<Entry, Long>)jdbmPartition).addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) );
+        ((Store)jdbmPartition).addIndex( new JdbmIndex<UUID>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) );
         assertNotNull( jdbmPartition.getSubLevelIndex() );
 
         assertNull( jdbmPartition.getId() );
@@ -265,11 +265,11 @@ public class JdbmStoreTest
         assertNotNull( jdbmPartition.getRdnIndex() );
 
         assertNull( jdbmPartition.getOneAliasIndex() );
-        ((Store<Entry, Long>)jdbmPartition).addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
+        ((Store)jdbmPartition).addIndex( new JdbmIndex<UUID>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
         assertNotNull( jdbmPartition.getOneAliasIndex() );
 
         assertNull( jdbmPartition.getSubAliasIndex() );
-        jdbmPartition.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
+        jdbmPartition.addIndex( new JdbmIndex<UUID>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
         assertNotNull( jdbmPartition.getSubAliasIndex() );
 
         assertNull( jdbmPartition.getSuffixDn() );
@@ -279,7 +279,7 @@ public class JdbmStoreTest
         assertNotNull( jdbmPartition.getSuffixDn() );
 
         assertFalse( jdbmPartition.getUserIndices().hasNext() );
-        jdbmPartition.addIndex( new JdbmIndex<Object, Entry>( "2.5.4.3" ) );
+        jdbmPartition.addIndex( new JdbmIndex<Object>( "2.5.4.3" ) );
         assertEquals( true, jdbmPartition.getUserIndices().hasNext() );
 
         assertNull( jdbmPartition.getPartitionPath() );
@@ -303,7 +303,7 @@ public class JdbmStoreTest
         assertNotNull( store.getAliasIndex() );
         try
         {
-            store.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) );
+            store.addIndex( new JdbmIndex<String>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -322,7 +322,7 @@ public class JdbmStoreTest
         assertNotNull( store.getPresenceIndex() );
         try
         {
-            store.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ) );
+            store.addIndex( new JdbmIndex<String>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -332,7 +332,7 @@ public class JdbmStoreTest
         assertNotNull( store.getOneLevelIndex() );
         try
         {
-            store.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
+            store.addIndex( new JdbmIndex<UUID>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -342,7 +342,7 @@ public class JdbmStoreTest
         assertNotNull( store.getSubLevelIndex() );
         try
         {
-            store.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) );
+            store.addIndex( new JdbmIndex<UUID>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -374,7 +374,7 @@ public class JdbmStoreTest
         assertNotNull( store.getOneAliasIndex() );
         try
         {
-            store.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
+            store.addIndex( new JdbmIndex<UUID>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -384,7 +384,7 @@ public class JdbmStoreTest
         assertNotNull( store.getSubAliasIndex() );
         try
         {
-            store.addIndex( new JdbmIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
+            store.addIndex( new JdbmIndex<UUID>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -489,36 +489,36 @@ public class JdbmStoreTest
     public void testFreshStore() throws Exception
     {
         Dn dn = new Dn( schemaManager, "o=Good Times Co." );
-        assertEquals( 1L, ( long ) store.getEntryId( dn ) );
+        assertEquals( StoreUtils.getUUIDString( 1 ), store.getEntryId( dn ) );
         assertEquals( 11, store.count() );
-        assertEquals( "o=Good Times Co.", store.getEntryDn( 1L ).getName() );
-        assertEquals( dn.getNormName(), store.getEntryDn( 1L ).getNormName() );
-        assertEquals( dn.getName(), store.getEntryDn( 1L ).getName() );
+        assertEquals( "o=Good Times Co.", store.getEntryDn( StoreUtils.getUUIDString( 1 ) ).getName() );
+        assertEquals( dn.getNormName(), store.getEntryDn( StoreUtils.getUUIDString( 1 ) ).getNormName() );
+        assertEquals( dn.getName(), store.getEntryDn( StoreUtils.getUUIDString( 1 ) ).getName() );
 
         // note that the suffix entry returns 0 for it's parent which does not exist
-        assertEquals( 0L, ( long ) store.getParentId( store.getEntryId( dn ) ) );
-        assertNull( store.getParentId( 0L ) );
+        assertEquals( StoreUtils.getUUIDString( 0 ), store.getParentId( store.getEntryId( dn ) ) );
+        assertNull( store.getParentId( StoreUtils.getUUIDString( 0 ) ) );
 
         // should NOW be allowed
-        store.delete( 1L );
+        store.delete( StoreUtils.getUUIDString( 1 ) );
     }
 
 
     @Test
     public void testEntryOperations() throws Exception
     {
-        assertEquals( 3, store.getChildCount( 1L ) );
+        assertEquals( 3, store.getChildCount( StoreUtils.getUUIDString( 1 ) ) );
 
-        Cursor<IndexEntry<Long, Long>> cursor = store.list( 1L );
+        Cursor<IndexEntry<UUID>> cursor = store.list( StoreUtils.getUUIDString( 1 ) );
         assertNotNull( cursor );
         cursor.beforeFirst();
         assertTrue( cursor.next() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 2 ), cursor.get().getId() );
         assertTrue( cursor.next() );
-        assertEquals( 3, store.getChildCount( 1L ) );
+        assertEquals( 3, store.getChildCount( StoreUtils.getUUIDString( 1 ) ) );
 
-        store.delete( 2L );
-        assertEquals( 2, store.getChildCount( 1L ) );
+        store.delete( StoreUtils.getUUIDString( 2 ) );
+        assertEquals( 2, store.getChildCount( StoreUtils.getUUIDString( 1 ) ) );
         assertEquals( 10, store.count() );
 
         // add an alias and delete to test dropAliasIndices method
@@ -529,12 +529,12 @@ public class JdbmStoreTest
         entry.add( "commonName", "Jack Daniels" );
         entry.add( "aliasedObjectName", "cn=Jack Daniels,ou=Engineering,o=Good Times Co." );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry.add( "entryUUID", StoreUtils.getUUIDString( 12 ).toString() );
         
         AddOperationContext addContext = new AddOperationContext( null, entry );
         store.add( addContext );
 
-        store.delete( 12L ); // drops the alias indices
+        store.delete( StoreUtils.getUUIDString( 12 ) ); // drops the alias indices
 
     }
 
@@ -546,28 +546,28 @@ public class JdbmStoreTest
 
         assertEquals( 19, idx.count() );
 
-        Cursor<IndexEntry<Long, Long>> cursor = idx.forwardCursor( 2L );
+        Cursor<IndexEntry<UUID>> cursor = idx.forwardCursor( StoreUtils.getUUIDString( 2 ) );
 
         assertTrue( cursor.next() );
-        assertEquals( 2, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 2 ), cursor.get().getId() );
 
         assertTrue( cursor.next() );
-        assertEquals( 5, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 5 ), cursor.get().getId() );
 
         assertTrue( cursor.next() );
-        assertEquals( 6, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 6 ), cursor.get().getId() );
 
         assertFalse( cursor.next() );
 
-        idx.drop( 5L );
+        idx.drop( StoreUtils.getUUIDString( 5 ) );
 
-        cursor = idx.forwardCursor( 2L );
+        cursor = idx.forwardCursor( StoreUtils.getUUIDString( 2 ) );
 
         assertTrue( cursor.next() );
-        assertEquals( 2, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 2 ), cursor.get().getId() );
 
         assertTrue( cursor.next() );
-        assertEquals( 6, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 6 ), cursor.get().getId() );
 
         assertFalse( cursor.next() );
 
@@ -578,24 +578,24 @@ public class JdbmStoreTest
         entry.add( "ou", "Sales" );
         entry.add( "cn", "Martin King" );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry.add( "entryUUID", StoreUtils.getUUIDString( 12 ).toString() );
         AddOperationContext addContext = new AddOperationContext( null, entry );
         store.add( addContext );
 
-        cursor = idx.forwardCursor( 2L );
+        cursor = idx.forwardCursor( StoreUtils.getUUIDString( 2 ) );
         cursor.afterLast();
         assertTrue( cursor.previous() );
-        assertEquals( 12, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 12 ), cursor.get().getId() );
 
         Dn newParentDn = new Dn( schemaManager, "ou=Board of Directors,o=Good Times Co." );
 
         Dn newDn = newParentDn.add( martinDn.getRdn() );
 
         store.move( martinDn, newParentDn, newDn, entry );
-        cursor = idx.forwardCursor( 3L );
+        cursor = idx.forwardCursor( StoreUtils.getUUIDString( 3 ) );
         cursor.afterLast();
         assertTrue( cursor.previous() );
-        assertEquals( 12, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 12 ), cursor.get().getId() );
 
         // dn id 13
         Dn marketingDn = new Dn( schemaManager, "ou=Marketing,ou=Sales,o=Good Times Co." );
@@ -603,7 +603,7 @@ public class JdbmStoreTest
         entry.add( "objectClass", "top", "organizationalUnit" );
         entry.add( "ou", "Marketing" );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry.add( "entryUUID", StoreUtils.getUUIDString( 13 ).toString() );
         addContext = new AddOperationContext( null, entry );
         store.add( addContext );
 
@@ -614,7 +614,7 @@ public class JdbmStoreTest
         entry.add( "ou", "Marketing" );
         entry.add( "cn", "Jimmy Wales" );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry.add( "entryUUID", StoreUtils.getUUIDString( 14 ).toString() );
         addContext = new AddOperationContext( null, entry );
         store.add( addContext );
 
@@ -622,29 +622,29 @@ public class JdbmStoreTest
 
         store.move( marketingDn, newParentDn, newDn, entry );
 
-        cursor = idx.forwardCursor( 3L );
+        cursor = idx.forwardCursor( StoreUtils.getUUIDString( 3 ) );
         cursor.afterLast();
 
         assertTrue( cursor.previous() );
-        assertEquals( 14, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 14 ), cursor.get().getId() );
 
         assertTrue( cursor.previous() );
-        assertEquals( 13, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 13 ), cursor.get().getId() );
 
         assertTrue( cursor.previous() );
-        assertEquals( 12, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 12 ), cursor.get().getId() );
 
         assertTrue( cursor.previous() );
-        assertEquals( 10, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 10 ), cursor.get().getId() );
 
         assertTrue( cursor.previous() );
-        assertEquals( 9, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 9 ), cursor.get().getId() );
 
         assertTrue( cursor.previous() );
-        assertEquals( 7, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 7 ), cursor.get().getId() );;
 
         assertTrue( cursor.previous() );
-        assertEquals( 3, ( long ) cursor.get().getId() );
+        assertEquals( StoreUtils.getUUIDString( 3 ), cursor.get().getId() );
 
         assertFalse( cursor.previous() );
     }
@@ -658,7 +658,7 @@ public class JdbmStoreTest
         File testSpecificDir = new File( wkdir, "testConvertIndex" );
         testSpecificDir.mkdirs();
 
-        Index<?, Object, Long> nonJdbmIndex = new GenericIndex<Object, Object, Long>( "ou", 10, testSpecificDir.toURI() );
+        Index<?> nonJdbmIndex = new GenericIndex<Object>( "ou", 10, testSpecificDir.toURI() );
 
         Method convertIndex = store.getClass().getDeclaredMethod( "convertAndInit", Index.class );
         convertIndex.setAccessible( true );
@@ -679,6 +679,7 @@ public class JdbmStoreTest
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
         entry.add( "ou", "Not Present" );
         entry.add( "cn", "Martin King" );
+        entry.add( "entryUUID", StoreUtils.getUUIDString( 12 ).toString() );
         AddOperationContext addContext = new AddOperationContext( null, entry );
         store.add( addContext );
     }
@@ -691,6 +692,7 @@ public class JdbmStoreTest
         Entry entry = new DefaultEntry( schemaManager, dn );
         entry.add( "ou", "Sales" );
         entry.add( "cn", "Martin King" );
+        entry.add( "entryUUID", StoreUtils.getUUIDString( 12 ).toString() );
         AddOperationContext addContext = new AddOperationContext( null, entry );
         store.add( addContext );
     }
@@ -719,7 +721,7 @@ public class JdbmStoreTest
         entry.add( "ou", "Engineering" );
         entry.add( "cn", "Private Ryan" );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry.add( "entryUUID", StoreUtils.getUUIDString( 12 ).toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, entry );
         store.add( addContext );
@@ -744,7 +746,7 @@ public class JdbmStoreTest
         entry.add( "ou", "Engineering" );
         entry.add( "cn", "Private Ryan" );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry.add( "entryUUID", StoreUtils.getUUIDString( 12 ).toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, entry );
         store.add( addContext );
@@ -754,7 +756,7 @@ public class JdbmStoreTest
         store.rename( dn, rdn, true, null );
 
         Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
-        Long id = store.getEntryId( dn2 );
+        UUID id = store.getEntryId( dn2 );
         assertNotNull( id );
         Entry entry2 = store.lookup( id );
         assertEquals( "ja+es", entry2.get( "sn" ).getString() );
@@ -770,7 +772,7 @@ public class JdbmStoreTest
         childEntry.add( "ou", "Engineering" );
         childEntry.add( "cn", "Private Ryan" );
         childEntry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        childEntry.add( "entryUUID", UUID.randomUUID().toString() );
+        childEntry.add( "entryUUID", StoreUtils.getUUIDString( 12 ).toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, childEntry );
         store.add( addContext );
@@ -878,7 +880,7 @@ public class JdbmStoreTest
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
         entry.add( "cn", "Tim B" );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry.add( "entryUUID", StoreUtils.getUUIDString( 12 ).toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, entry );
         store.add( addContext );



Mime
View raw message