directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1540319 - in /directory/apacheds/trunk/mavibot-partition/src: main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/ test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/
Date Sat, 09 Nov 2013 14:50:31 GMT
Author: elecharny
Date: Sat Nov  9 14:50:30 2013
New Revision: 1540319

URL: http://svn.apache.org/r1540319
Log:
Fixed the failures in the mavibot partition, now that we have a new version of mavibot

Modified:
    directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotCursor.java
    directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndex.java
    directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java
    directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndexTest.java
    directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java

Modified: directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotCursor.java?rev=1540319&r1=1540318&r2=1540319&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotCursor.java
(original)
+++ directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotCursor.java
Sat Nov  9 14:50:30 2013
@@ -33,7 +33,8 @@ import org.slf4j.LoggerFactory;
 
 
 /**
- * Cursor over the Tuples of a Mavibot BTree.
+ * Cursor over the Tuples of a Mavibot BTree. If the BTree allows duplicate values,
+ * we will browse each value and return a Tuple for each one of them.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -42,11 +43,16 @@ class MavibotCursor<K, V> extends Abstra
     /** A dedicated log for cursors */
     private static final Logger LOG_CURSOR = LoggerFactory.getLogger( "CURSOR" );
 
+    /** The table we are building a cursor over */
     private final MavibotTable<K, V> table;
 
+    /** The tuple which will be returned */
     private Tuple<K, V> returnedTuple = new Tuple<K, V>();
-    private boolean valueAvailable;
+    
+    /** A flag set when there is a Tuple available */
+    private boolean valueAvailable = false;
 
+    /** The Tuple browser */
     private TupleCursor<K, V> browser;
 
 
@@ -62,6 +68,9 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
+    /**
+     * Cleanup the returned tuple before reusing it.
+     */
     private void clearValue()
     {
         returnedTuple.setKey( null );
@@ -70,12 +79,21 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean available()
     {
         return valueAvailable;
     }
 
 
+    /**
+     * Sets the position before a given key
+     * @param key The key we want to start with
+     * @throws LdapException 
+     * @throws CursorException
+     */
     public void beforeKey( K key ) throws LdapException, CursorException
     {
         checkNotClosed( "beforeKey()" );
@@ -103,7 +121,12 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
-    @SuppressWarnings("unchecked")
+    /**
+     * Sets the position before a given key
+     * @param key The key we want to start with
+     * @throws LdapException 
+     * @throws CursorException
+     */
     public void afterKey( K key ) throws LdapException, CursorException
     {
         checkNotClosed( "afterKey()" );
@@ -139,12 +162,26 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
+    /**
+     * Sets the position before a given key and a given value for this key
+     * @param key The key we want to start with
+     * @param value The value we want to start with
+     * @throws LdapException 
+     * @throws CursorException
+     */
     public void beforeValue( K key, V value ) throws LdapException, CursorException
     {
         throw new UnsupportedOperationException( I18n.err( I18n.ERR_596 ) );
     }
 
 
+    /**
+     * Sets the position after a given key and a given value for this key
+     * @param key The key we want to start with
+     * @param value The value we want to start with
+     * @throws LdapException 
+     * @throws CursorException
+     */
     public void afterValue( K key, V value ) throws LdapException, CursorException
     {
         throw new UnsupportedOperationException( I18n.err( I18n.ERR_596 ) );
@@ -152,9 +189,7 @@ class MavibotCursor<K, V> extends Abstra
 
 
     /**
-     * Positions this Cursor before the key of the supplied tuple.
-     *
-     * @param element the tuple who's key is used to position this Cursor
+     * {@inheritDoc}
      */
     public void before( Tuple<K, V> element ) throws LdapException, CursorException
     {
@@ -162,12 +197,18 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void after( Tuple<K, V> element ) throws LdapException, CursorException
     {
         afterKey( element.getKey() );
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void beforeFirst() throws LdapException, CursorException
     {
         checkNotClosed( "beforeFirst()" );
@@ -189,6 +230,9 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void afterLast() throws LdapException, CursorException
     {
         checkNotClosed( "afterLast()" );
@@ -210,13 +254,20 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean first() throws LdapException, CursorException
     {
         beforeFirst();
+        
         return next();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public boolean last() throws LdapException, CursorException
     {
         afterLast();
@@ -224,7 +275,9 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
-    @SuppressWarnings("unchecked")
+    /**
+     * {@inheritDoc}
+     */
     public boolean previous() throws LdapException, CursorException
     {
         checkNotClosed( "previous()" );
@@ -256,7 +309,9 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
-    @SuppressWarnings("unchecked")
+    /**
+     * {@inheritDoc}
+     */
     public boolean next() throws LdapException, CursorException
     {
         checkNotClosed( "previous()" );
@@ -289,6 +344,9 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public Tuple<K, V> get() throws CursorException
     {
         checkNotClosed( "get()" );
@@ -325,6 +383,9 @@ class MavibotCursor<K, V> extends Abstra
     }
 
 
+    /**
+     * Close the browser
+     */
     private void closeBrowser( TupleCursor<K, V> browser )
     {
         if ( browser != null )

Modified: directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndex.java?rev=1540319&r1=1540318&r2=1540319&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndex.java
(original)
+++ directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndex.java
Sat Nov  9 14:50:30 2013
@@ -502,106 +502,6 @@ public class MavibotIndex<K> extends Abs
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public boolean forwardGreaterOrEq( K attrVal ) throws Exception
-    {
-        return forward.hasGreaterOrEqual( attrVal );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean forwardGreaterOrEq( K attrVal, String id ) throws Exception
-    {
-        return forward.hasGreaterOrEqual( attrVal, id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean forwardLessOrEq( K attrVal ) throws Exception
-    {
-        return forward.hasLessOrEqual( attrVal );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean forwardLessOrEq( K attrVal, String id ) throws Exception
-    {
-        return forward.hasLessOrEqual( attrVal, id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseGreaterOrEq( String id ) throws Exception
-    {
-        if ( withReverse )
-        {
-            return reverse.hasGreaterOrEqual( id );
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseGreaterOrEq( String id, K attrVal ) throws LdapException
-    {
-        if ( withReverse )
-        {
-            return reverse.hasGreaterOrEqual( id, attrVal );
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseLessOrEq( String id ) throws Exception
-    {
-        if ( withReverse )
-        {
-            return reverse.hasLessOrEqual( id );
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean reverseLessOrEq( String id, K attrVal ) throws Exception
-    {
-        if ( withReverse )
-        {
-            return reverse.hasLessOrEqual( id, attrVal );
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-
     // ------------------------------------------------------------------------
     // Maintenance Methods
     // ------------------------------------------------------------------------

Modified: directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java?rev=1540319&r1=1540318&r2=1540319&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java
(original)
+++ directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotTable.java
Sat Nov  9 14:50:30 2013
@@ -100,6 +100,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public boolean isDupsEnabled()
     {
@@ -107,6 +110,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public boolean has( K key ) throws IOException
     {
@@ -114,6 +120,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public boolean has( K key, V value ) throws LdapException
     {
@@ -128,6 +137,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public boolean hasGreaterOrEqual( K key ) throws Exception
     {
@@ -195,6 +207,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public boolean hasGreaterOrEqual( K key, V val ) throws LdapException
     {
@@ -221,7 +236,7 @@ public class MavibotTable<K, V> extends 
 
             int equal = bt.getValueSerializer().compare( val, valueCursor.next() );
 
-            return ( equal == 0 );
+            return ( equal >= 0 );
         }
         catch ( Exception e )
         {
@@ -237,6 +252,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public boolean hasLessOrEqual( K key, V val ) throws Exception
     {
@@ -261,6 +279,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public V get( K key ) throws LdapException
     {
@@ -284,6 +305,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void put( K key, V value ) throws Exception
     {
@@ -294,10 +318,10 @@ public class MavibotTable<K, V> extends 
                 throw new IllegalArgumentException( I18n.err( I18n.ERR_594 ) );
             }
 
-            V replaced = bt.insert( key, value );
-
-            if  ( ( replaced == null ) || ( !replaced.equals( value ) ) )
+            if ( !bt.contains( key, value ) )
             {
+                bt.insert( key, value );
+    
                 count++;
             }
         }
@@ -309,6 +333,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void remove( K key ) throws Exception
     {
@@ -342,6 +369,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void remove( K key, V value ) throws Exception
     {
@@ -352,10 +382,10 @@ public class MavibotTable<K, V> extends 
                 return;
             }
 
-            org.apache.directory.mavibot.btree.Tuple<K, V> t = bt.delete( key, value
);
+            org.apache.directory.mavibot.btree.Tuple<K, V> tuple = bt.delete( key,
value );
 
             // We decrement the counter only when the key was found
-            if ( t != null )
+            if ( tuple != null )
             {
                 count--;
             }
@@ -367,6 +397,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public Cursor<Tuple<K, V>> cursor() throws LdapException
     {
@@ -374,6 +407,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public Cursor<Tuple<K, V>> cursor( K key ) throws LdapException
     {
@@ -409,6 +445,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public Cursor<V> valueCursor( K key ) throws Exception
     {
@@ -427,9 +466,9 @@ public class MavibotTable<K, V> extends 
             }
             else
             {
-                ValueCursor<V> dupHolder = bt.getValues( key );
+                ValueCursor<V> dupCursor = bt.getValues( key );
 
-                return new ValueTreeCursor<V>( dupHolder );
+                return new ValueTreeCursor<V>( dupCursor );
             }
         }
         catch ( KeyNotFoundException knfe )
@@ -443,6 +482,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public long count( K key ) throws Exception
     {
@@ -451,45 +493,37 @@ public class MavibotTable<K, V> extends 
             return 0;
         }
 
-        try
+        if ( bt.isAllowDuplicates() )
         {
-            if ( bt.isAllowDuplicates() )
+            try
             {
                 ValueCursor<V> dupHolder = bt.getValues( key );
-
+    
                 return dupHolder.size();
             }
-            else
+            catch ( KeyNotFoundException knfe )
             {
-                bt.get( key );
-
-                return 1;
+                // No key 
+                return 0;
             }
         }
-        catch ( KeyNotFoundException knfe )
+        else
         {
-            return 0L;
-        }
-
-        /*
-        if ( bt.hasKey( key ) )
-        {
-            if ( !allowsDuplicates )
+            if ( bt.hasKey( key ) )
             {
-                return 1L;
+                return 1;
             }
             else
             {
-                BTree<V, V> values = bt.getValues( key );
-                return values.getNbElems();
+                return 0;
             }
         }
-
-        return 0;
-        */
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public long greaterThanCount( K key ) throws Exception
     {
@@ -498,6 +532,9 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public long lessThanCount( K key ) throws Exception
     {
@@ -506,6 +543,12 @@ public class MavibotTable<K, V> extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void close() throws Exception
     {

Modified: directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndexTest.java?rev=1540319&r1=1540318&r2=1540319&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndexTest.java
(original)
+++ directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotIndexTest.java
Sat Nov  9 14:50:30 2013
@@ -32,7 +32,6 @@ import java.io.IOException;
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.cursor.Cursor;
-import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.ldap.schemaextractor.SchemaLdifExtractor;
@@ -47,7 +46,6 @@ import org.apache.directory.server.xdbm.
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
@@ -65,6 +63,12 @@ public class MavibotIndexTest
     private static SchemaManager schemaManager;
 
     private RecordManager recordMan;
+    
+    private static final String UUID_0 = Strings.getUUID( 0L );
+    private static final String UUID_1 = Strings.getUUID( 1L );
+    private static final String UUID_1234 = Strings.getUUID( 1234L );
+    private static final String UUID_333 = Strings.getUUID( 333L );
+    private static final String UUID_555 = Strings.getUUID( 555L );
 
     @Rule
     public TemporaryFolder tempFolder = new TemporaryFolder();
@@ -270,13 +274,13 @@ public class MavibotIndexTest
         initIndex();
         assertEquals( 0, idx.count() );
 
-        idx.add( "foo", Strings.getUUID( 1234L ) );
+        idx.add( "foo", UUID_1234 );
         assertEquals( 1, idx.count() );
 
-        idx.add( "foo", Strings.getUUID( 333L ) );
+        idx.add( "foo", UUID_333 );
         assertEquals( 2, idx.count() );
 
-        idx.add( "bar", Strings.getUUID( 555L ) );
+        idx.add( "bar", UUID_555 );
         assertEquals( 3, idx.count() );
     }
 
@@ -287,13 +291,13 @@ public class MavibotIndexTest
         initIndex();
         assertEquals( 0, idx.count( "foo" ) );
 
-        idx.add( "bar", Strings.getUUID( 1234L ) );
+        idx.add( "bar", UUID_1234 );
         assertEquals( 0, idx.count( "foo" ) );
 
-        idx.add( "foo", Strings.getUUID( 1234L ) );
+        idx.add( "foo", UUID_1234 );
         assertEquals( 1, idx.count( "foo" ) );
 
-        idx.add( "foo", Strings.getUUID( 333L ) );
+        idx.add( "foo", UUID_333 );
         assertEquals( 2, idx.count( "foo" ) );
     }
 
@@ -340,53 +344,21 @@ public class MavibotIndexTest
         initIndex();
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 0L ) ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( -24L ) ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 24L ) ) );
-        assertFalse( idx.forwardLessOrEq( "foo", Strings.getUUID( 0L ) ) );
-        assertFalse( idx.forwardLessOrEq( "foo", Strings.getUUID( 24L ) ) );
-        assertFalse( idx.forwardLessOrEq( "foo", Strings.getUUID( -24L ) ) );
-
-        idx.add( "foo", Strings.getUUID( 0L ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
-        assertTrue( idx.forward( "foo", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 0L ) ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( -1L ) ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 1L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 1L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( -1L ) ) );
-
-        idx.add( "foo", Strings.getUUID( 1L ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
-        assertTrue( idx.forward( "foo", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forward( "foo", Strings.getUUID( 1L ) ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 1L ) ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( -1L ) ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 2L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 1L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 2L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( -1L ) ) );
-
-        idx.add( "bar", Strings.getUUID( 0L ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "bar" ) );
-        assertTrue( idx.forward( "bar", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forward( "foo", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forward( "foo", Strings.getUUID( 1L ) ) );
-        assertTrue( idx.forwardGreaterOrEq( "bar", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 1L ) ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( -1L ) ) );
-        assertFalse( idx.forwardGreaterOrEq( "foo", Strings.getUUID( 2L ) ) );
-        assertFalse( idx.forwardGreaterOrEq( "bar", Strings.getUUID( 1L ) ) );
-        assertTrue( idx.forwardLessOrEq( "bar", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 0L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 1L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( 2L ) ) );
-        assertTrue( idx.forwardLessOrEq( "foo", Strings.getUUID( -1L ) ) );
-        assertTrue( idx.forwardLessOrEq( "bar", Strings.getUUID( -1L ) ) );
+
+        idx.add( "foo", UUID_0 );
+        assertEquals( UUID_0, idx.forwardLookup( "foo" ) );
+        assertTrue( idx.forward( "foo", UUID_0 ) );
+
+        idx.add( "foo", UUID_1 );
+        assertEquals( UUID_0, idx.forwardLookup( "foo" ) );
+        assertTrue( idx.forward( "foo", UUID_0 ) );
+        assertTrue( idx.forward( "foo", UUID_1 ) );
+
+        idx.add( "bar", UUID_0 );
+        assertEquals( UUID_0, idx.forwardLookup( "bar" ) );
+        assertTrue( idx.forward( "bar", UUID_0 ) );
+        assertTrue( idx.forward( "foo", UUID_0 ) );
+        assertTrue( idx.forward( "foo", UUID_1 ) );
     }
 
 
@@ -398,26 +370,26 @@ public class MavibotIndexTest
         assertNull( idx.forwardLookup( "bar" ) );
 
         // test add/drop without adding any duplicates
-        idx.add( "foo", Strings.getUUID( 0L ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
+        idx.add( "foo", UUID_0 );
+        assertEquals( UUID_0, idx.forwardLookup( "foo" ) );
 
-        idx.drop( "foo", Strings.getUUID( 0L ) );
+        idx.drop( "foo", UUID_0 );
         assertNull( idx.forwardLookup( "foo" ) );
 
         // test add/drop with duplicates in bulk
-        idx.add( "foo", Strings.getUUID( 0L ) );
-        idx.add( "foo", Strings.getUUID( 1L ) );
-        idx.add( "bar", Strings.getUUID( 0L ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "bar" ) );
-
-        idx.drop( "foo", Strings.getUUID( 0L ) );
-        idx.drop( "bar", Strings.getUUID( 0L ) );
-        assertFalse( idx.forward( "bar", Strings.getUUID( 0L ) ) );
-        assertFalse( idx.forward( "foo", Strings.getUUID( 0L ) ) );
+        idx.add( "foo", UUID_0 );
+        idx.add( "foo", UUID_1 );
+        idx.add( "bar", UUID_0 );
+        assertEquals( UUID_0, idx.forwardLookup( "foo" ) );
+        assertEquals( UUID_0, idx.forwardLookup( "bar" ) );
+
+        idx.drop( "foo", UUID_0 );
+        idx.drop( "bar", UUID_0 );
+        assertFalse( idx.forward( "bar", UUID_0 ) );
+        assertFalse( idx.forward( "foo", UUID_0 ) );
 
-        idx.drop( "bar", Strings.getUUID( 1L ) );
-        idx.drop( "foo", Strings.getUUID( 1L ) );
+        idx.drop( "bar", UUID_1 );
+        idx.drop( "foo", UUID_1 );
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
         assertEquals( 0, idx.count() );
@@ -432,28 +404,28 @@ public class MavibotIndexTest
         assertNull( idx.forwardLookup( "bar" ) );
 
         // test add/drop without adding any duplicates
-        idx.add( "foo", Strings.getUUID( 0L ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
+        idx.add( "foo", UUID_0 );
+        assertEquals( UUID_0, idx.forwardLookup( "foo" ) );
 
-        idx.drop( "foo", Strings.getUUID( 0L ) );
+        idx.drop( "foo", UUID_0 );
         assertNull( idx.forwardLookup( "foo" ) );
 
         // test add/drop with duplicates but one at a time
-        idx.add( "foo", Strings.getUUID( 0L ) );
-        idx.add( "foo", Strings.getUUID( 1L ) );
-        idx.add( "bar", Strings.getUUID( 0L ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "bar" ) );
-
-        idx.drop( "bar", Strings.getUUID( 0L ) );
-        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( "foo" ) );
-        assertFalse( idx.forward( "bar", Strings.getUUID( 0L ) ) );
-
-        idx.drop( "foo", Strings.getUUID( 0L ) );
-        assertEquals( Strings.getUUID( 1L ), idx.forwardLookup( "foo" ) );
-        assertFalse( idx.forward( "foo", Strings.getUUID( 0L ) ) );
+        idx.add( "foo", UUID_0 );
+        idx.add( "foo", UUID_1 );
+        idx.add( "bar", UUID_0 );
+        assertEquals( UUID_0, idx.forwardLookup( "foo" ) );
+        assertEquals( UUID_0, idx.forwardLookup( "bar" ) );
+
+        idx.drop( "bar", UUID_0 );
+        assertEquals( UUID_0, idx.forwardLookup( "foo" ) );
+        assertFalse( idx.forward( "bar", UUID_0 ) );
+
+        idx.drop( "foo", UUID_0 );
+        assertEquals( UUID_1, idx.forwardLookup( "foo" ) );
+        assertFalse( idx.forward( "foo", UUID_0 ) );
 
-        idx.drop( "foo", Strings.getUUID( 1L ) );
+        idx.drop( "foo", UUID_1 );
         assertNull( idx.forwardLookup( "foo" ) );
         assertNull( idx.forwardLookup( "bar" ) );
         assertEquals( 0, idx.count() );
@@ -470,35 +442,35 @@ public class MavibotIndexTest
         initIndex();
         assertEquals( 0, idx.count() );
 
-        idx.add( "foo", Strings.getUUID( 1234L ) );
-        assertEquals( 1, idx.count() );
-
-        idx.add( "foo", Strings.getUUID( 333L ) );
+        idx.add( "foo", UUID_1234 );
         assertEquals( 1, idx.count() );
 
-        idx.add( "bar", Strings.getUUID( 555L ) );
+        idx.add( "foo", UUID_333 );
         assertEquals( 2, idx.count() );
 
+        idx.add( "bar", UUID_555 );
+        assertEquals( 3, idx.count() );
+
         // use forward index's cursor
         Cursor<IndexEntry<String, String>> cursor = idx.forwardCursor();
         cursor.beforeFirst();
 
-        assertEquals( 2, idx.count() );
+        assertEquals( 3, idx.count() );
 
         cursor.next();
         IndexEntry<String, String> e1 = cursor.get();
-        assertEquals( Strings.getUUID( 555L ), e1.getId() );
+        assertEquals( UUID_555, e1.getId() );
         assertEquals( "bar", e1.getKey() );
 
         cursor.next();
         IndexEntry<String, String> e2 = cursor.get();
-        assertEquals( Strings.getUUID( 333L ), e2.getId() );
-        //assertEquals( Strings.getUUID( 1234L ), e3.getId() );
+        assertEquals( UUID_333, e2.getId() );
+        //assertEquals( UUID_1234, e3.getId() );
         assertEquals( "foo", e2.getKey() );
 
         cursor.next();
         IndexEntry<String, String> e3 = cursor.get();
-        assertEquals( Strings.getUUID( 1234L ), e3.getId() );
+        assertEquals( UUID_1234, e3.getId() );
         assertEquals( "foo", e3.getKey() );
 
         cursor.close();

Modified: directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java?rev=1540319&r1=1540318&r2=1540319&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
(original)
+++ directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
Sat Nov  9 14:50:30 2013
@@ -656,9 +656,13 @@ public class MavibotStoreTest
             "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
             "entryUUID", UUID.randomUUID().toString() );
 
+        assertEquals( 3, store.getSubAliasIndex().count() );
+
         AddOperationContext addContext = new AddOperationContext( null, childEntry );
         store.add( addContext );
 
+        assertEquals( 3, store.getSubAliasIndex().count() );
+
         Dn parentDn = new Dn( schemaManager, "ou=Sales,o=Good Times Co." );
 
         Rdn rdn = new Rdn( "cn=Ryan" );



Mime
View raw message