You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2014/05/17 15:31:25 UTC

svn commit: r1595477 [6/8] - in /directory/mavibot/trunk: ./ mavibot/img/ mavibot/src/main/java/org/apache/directory/mavibot/btree/ mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ mavibot/src/main/java/org/apache/directory/mavibot/...

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java Sat May 17 13:31:23 2014
@@ -30,6 +30,17 @@ import java.util.Comparator;
  */
 /* no qualifier*/class RevisionNameComparator implements Comparator<RevisionName>
 {
+    /** A static instance of a RevisionNameComparator */
+    public static final RevisionNameComparator INSTANCE = new RevisionNameComparator();
+
+    /**
+     * A private constructor of the RevisionNameComparator class
+     */
+    private RevisionNameComparator()
+    {
+    }
+
+
     /**
      * {@inheritDoc}
      */

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java Sat May 17 13:31:23 2014
@@ -41,12 +41,15 @@ import org.apache.directory.mavibot.btre
  */
 /* no qualifier*/class RevisionNameSerializer extends AbstractElementSerializer<RevisionName>
 {
+    /** A static instance of a RevisionNameSerializer */
+    /*No qualifier*/ final static RevisionNameSerializer INSTANCE = new RevisionNameSerializer();
+
     /**
      * Create a new instance of a RevisionNameSerializer
      */
-    /* no qualifier*/RevisionNameSerializer()
+    private RevisionNameSerializer()
     {
-        super( new RevisionNameComparator() );
+        super( RevisionNameComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/TupleCursor.java Sat May 17 13:31:23 2014
@@ -34,7 +34,7 @@ import org.apache.directory.mavibot.btre
  *
  * @param <K> The type for the Key
  * @param <V> The type for the stored value
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class TupleCursor<K, V>
@@ -59,8 +59,16 @@ public class TupleCursor<K, V>
 
 
     /**
+     * Creates a new instance of Cursor.
+     */
+    protected TupleCursor()
+    {
+    }
+
+
+    /**
      * Creates a new instance of Cursor, starting on a page at a given position.
-     * 
+     *
      * @param transaction The transaction this operation is protected by
      * @param stack The stack of parent's from root to this page
      */
@@ -167,10 +175,10 @@ public class TupleCursor<K, V>
 
     /**
      * Tells if the cursor can return a next element
-     * 
+     *
      * @return true if there are some more elements
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     public boolean hasNext() throws EndOfFileExceededException, IOException
     {
@@ -207,7 +215,7 @@ public class TupleCursor<K, V>
                 return true;
             }
 
-            // Ok, here, we have reached the last value in the leaf. We have to go up and 
+            // Ok, here, we have reached the last value in the leaf. We have to go up and
             // see if we have some remaining values
             int currentDepth = depth - 1;
 
@@ -234,10 +242,10 @@ public class TupleCursor<K, V>
 
     /**
      * Find the next key/value
-     * 
+     *
      * @return A Tuple containing the found key and value
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     public Tuple<K, V> next() throws EndOfFileExceededException, IOException
     {
@@ -324,7 +332,7 @@ public class TupleCursor<K, V>
     /**
      * Get the next non-duplicate key.
      * If the BTree contains :
-     * 
+     *
      *  <ul>
      *    <li><1,0></li>
      *    <li><1,1></li>
@@ -332,9 +340,9 @@ public class TupleCursor<K, V>
      *    <li><2,0></li>
      *    <li><2,1></li>
      *  </ul>
-     *   
+     *
      *  and cursor is present at <1,1> then the returned tuple will be <2,0> (not <1,2>)
-     *  
+     *
      * @return A Tuple containing the found key and value
      * @throws EndOfFileExceededException
      * @throws IOException
@@ -402,10 +410,10 @@ public class TupleCursor<K, V>
 
     /**
      * Tells if the cursor can return a next key
-     * 
+     *
      * @return true if there are some more keys
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     public boolean hasNextKey() throws EndOfFileExceededException, IOException
     {
@@ -439,10 +447,10 @@ public class TupleCursor<K, V>
 
     /**
      * Tells if the cursor can return a previous element
-     * 
+     *
      * @return true if there are some more elements
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     public boolean hasPrev() throws EndOfFileExceededException, IOException
     {
@@ -480,7 +488,7 @@ public class TupleCursor<K, V>
                 return true;
             }
 
-            // Ok, here, we have reached the first value in the leaf. We have to go up and 
+            // Ok, here, we have reached the first value in the leaf. We have to go up and
             // see if we have some remaining values
             int currentDepth = depth - 1;
 
@@ -506,10 +514,10 @@ public class TupleCursor<K, V>
 
     /**
      * Find the previous key/value
-     * 
+     *
      * @return A Tuple containing the found key and value
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     public Tuple<K, V> prev() throws EndOfFileExceededException, IOException
     {
@@ -597,7 +605,7 @@ public class TupleCursor<K, V>
     /**
      * Get the previous non-duplicate key.
      * If the BTree contains :
-     * 
+     *
      *  <ul>
      *    <li><1,0></li>
      *    <li><1,1></li>
@@ -605,9 +613,9 @@ public class TupleCursor<K, V>
      *    <li><2,0></li>
      *    <li><2,1></li>
      *  </ul>
-     *   
+     *
      *  and cursor is present at <2,1> then the returned tuple will be <1,0> (not <2,0>)
-     *  
+     *
      * @return A Tuple containing the found key and value
      * @throws EndOfFileExceededException
      * @throws IOException
@@ -653,7 +661,7 @@ public class TupleCursor<K, V>
             }
         }
 
-        // Update the Tuple 
+        // Update the Tuple
         AbstractPage<K, V> leaf = ( AbstractPage<K, V> ) ( parentPos.page );
 
         // The key
@@ -671,10 +679,10 @@ public class TupleCursor<K, V>
 
     /**
      * Tells if the cursor can return a previous key
-     * 
+     *
      * @return true if there are some more keys
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     public boolean hasPrevKey() throws EndOfFileExceededException, IOException
     {
@@ -693,25 +701,30 @@ public class TupleCursor<K, V>
             return false;
         }
 
-        if ( parentPos.pos == 0 )
+        switch ( parentPos.pos )
         {
-            // Beginning of the leaf. We have to go back into the stack up to the
-            // parent, and down to the leaf
-            return hasPrevParentPos();
-        }
-        else
-        {
-            return true;
+            case 0 :
+                // Beginning of the leaf. We have to go back into the stack up to the
+                // parent, and down to the leaf
+                return hasPrevParentPos();
+                
+            case -1 :
+                // no previous key
+                return false;
+                
+            default :
+                // we have a previous key
+                return true;
         }
     }
 
 
     /**
      * Tells if there is a next ParentPos
-     * 
+     *
      * @return the new ParentPos instance, or null if we have no following leaf
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     private boolean hasNextParentPos() throws EndOfFileExceededException, IOException
     {
@@ -758,10 +771,10 @@ public class TupleCursor<K, V>
 
     /**
      * Find the leaf containing the following elements.
-     * 
+     *
      * @return the new ParentPos instance, or null if we have no following leaf
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     private ParentPos<K, V> findNextParentPos() throws EndOfFileExceededException, IOException
     {
@@ -818,10 +831,10 @@ public class TupleCursor<K, V>
 
     /**
      * Find the leaf containing the previous elements.
-     * 
+     *
      * @return the new ParentPos instance, or null if we have no previous leaf
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     private ParentPos<K, V> findPrevParentPos() throws EndOfFileExceededException, IOException
     {
@@ -880,10 +893,10 @@ public class TupleCursor<K, V>
 
     /**
      * Tells if there is a prev ParentPos
-     * 
+     *
      * @return the new ParentPos instance, or null if we have no previous leaf
-     * @throws IOException 
-     * @throws EndOfFileExceededException 
+     * @throws IOException
+     * @throws EndOfFileExceededException
      */
     private boolean hasPrevParentPos() throws EndOfFileExceededException, IOException
     {
@@ -949,7 +962,7 @@ public class TupleCursor<K, V>
 
     /**
      * Get the current revision
-     * 
+     *
      * @return The revision this cursor is based on
      */
     public long getRevision()

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ValueBTreeCursor.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ValueBTreeCursor.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ValueBTreeCursor.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ValueBTreeCursor.java Sat May 17 13:31:23 2014
@@ -23,6 +23,7 @@ package org.apache.directory.mavibot.btr
 import java.io.IOException;
 
 import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
+import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 import org.apache.directory.mavibot.btree.BTree;
 
 
@@ -60,6 +61,11 @@ import org.apache.directory.mavibot.btre
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
+        catch ( KeyNotFoundException knfe )
+        {
+            // TODO Auto-generated catch block
+            knfe.printStackTrace();
+        }
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/WriteTransaction.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/WriteTransaction.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/WriteTransaction.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/WriteTransaction.java Sat May 17 13:31:23 2014
@@ -19,8 +19,6 @@
  */
 package org.apache.directory.mavibot.btree;
 
-import java.io.IOException;
-import java.util.Map;
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.directory.mavibot.btree.exception.BadTransactionStateException;
@@ -32,28 +30,29 @@ import org.apache.directory.mavibot.btre
  */
 /* no qualifier */ class WriteTransaction
 {
-    /** The recordManager on which this transaction is applied */
-    private RecordManager recordManager;
-
     /** A lock used to protect the write operation against concurrent access */
     protected ReentrantLock writeLock;
 
-    /* no qualifier */WriteTransaction( RecordManager recordManager )
+    /* no qualifier */WriteTransaction()
     {
-        System.out.println( "Creating the transaction oject" );
-        this.recordManager = recordManager;
+        //System.out.println( "Creating the transaction oject" );
         writeLock = new ReentrantLock();
     }
 
 
     /* no qualifier */ void start()
     {
+        /*
         if ( writeLock.isLocked() )
         {
             throw new BadTransactionStateException( "Cannot start a write transaction when it's already started" );
         }
+        */
+
+        //System.out.println( "Start a TXN [" + Thread.currentThread().getName() + "]" );
 
         writeLock.lock();
+        //System.out.println( "WriteTransaction " + Thread.currentThread().getName() );
     }
 
 
@@ -64,37 +63,7 @@ import org.apache.directory.mavibot.btre
             throw new BadTransactionStateException( "Cannot commit a write transaction when it's not started" );
         }
 
-        Map<?, ?> pendingPages = recordManager.getPendingPages();
-
-        for ( Object object : pendingPages.keySet() )
-        {
-            BTree btree = (BTree)pendingPages.get( object );
-
-            try
-            {
-                recordManager.writePage( btree, (Page)object, ((Page)object).getRevision() );
-            }
-            catch ( IOException e )
-            {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            }
-        }
-
-        /*
-        recordManager.updateRecordManagerHeader();
-
-        // Update the BTree header now
-        recordManager.updateBtreeHeader( btree, ( ( AbstractPage<K, V> ) rootPage ).getOffset() );
-
-        // Moved the free pages into the list of free pages
-        recordManager.addFreePages( this, result.getCopiedPages() );
-
-        // Store the created rootPage into the revision BTree, this will be stored in RecordManager only if revisions are set to keep
-        recordManager.storeRootPage( this, rootPage );
-        */
-
-        pendingPages.clear();
+        //System.out.println( "Commit a TXN[" + Thread.currentThread().getName() + "]" );
 
         writeLock.unlock();
     }
@@ -107,6 +76,7 @@ import org.apache.directory.mavibot.btre
             throw new BadTransactionStateException( "Cannot commit a write transaction when it's not started" );
         }
 
+        //System.out.println( "Rollback a TXN" );
         writeLock.unlock();
     }
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -26,14 +26,25 @@ import java.util.Comparator;
 /**
  * Compares boolean arrays. A boolean is considered as below the other one if the first boolean
  * is false when the second one is true.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class BooleanArrayComparator implements Comparator<boolean[]>
 {
+    /** A static instance of a BooleanArrayComparator */
+    public static final BooleanArrayComparator INSTANCE = new BooleanArrayComparator();
+
+    /**
+     * A private constructor of the BooleanArrayComparator class
+     */
+    private BooleanArrayComparator()
+    {
+    }
+
+
     /**
      * Compare two boolean arrays.
-     * 
+     *
      * @param booleanArray1 First boolean array
      * @param booleanArray2 Second boolean array
      * @return 1 if booleanArray1 > booleanArray2, 0 if booleanArray1 == booleanArray2, -1 if booleanArray1 < booleanArray2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares booleans
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class BooleanComparator implements Comparator<Boolean>
 {
+    /** A static instance of a BooleanComparator */
+    public static final BooleanComparator INSTANCE = new BooleanComparator();
+
+    /**
+     * A private constructor of the BooleanComparator class
+     */
+    private BooleanComparator()
+    {
+    }
+
+
     /**
      * Compare two booleans.
-     * 
+     *
      * @param boolean1 First boolean
      * @param boolean2 Second boolean
      * @return 1 if boolean1 > boolean2, 0 if boolean1 == boolean2, -1 if boolean1 < boolean2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares byte arrays.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class ByteArrayComparator implements Comparator<byte[]>
 {
+    /** A static instance of a ByteArrayComparator */
+    public static final ByteArrayComparator INSTANCE = new ByteArrayComparator();
+
+    /**
+     * A private constructor of the ByteArrayComparator class
+     */
+    private ByteArrayComparator()
+    {
+    }
+
+
     /**
      * Compare two byte arrays.
-     * 
+     *
      * @param byteArray1 First byteArray
      * @param byteArray2 Second byteArray
      * @return 1 if byteArray1 > byteArray2, 0 if byteArray1 == byteArray2, -1 if byteArray1 < byteArray2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares bytes
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class ByteComparator implements Comparator<Byte>
 {
+    /** A static instance of a ByteComparator */
+    public static final ByteComparator INSTANCE = new ByteComparator();
+
+    /**
+     * A private constructor of the ByteComparator class
+     */
+    private ByteComparator()
+    {
+    }
+
+
     /**
      * Compare two bytes.
-     * 
+     *
      * @param byte1 First byte
      * @param byte2 Second byte
      * @return 1 if byte1 > byte2, 0 if byte1 == byte2, -1 if byte1 < byte2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares char arrays
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class CharArrayComparator implements Comparator<char[]>
 {
+    /** A static instance of a CharArrayComparator */
+    public static final CharArrayComparator INSTANCE = new CharArrayComparator();
+
+    /**
+     * A private constructor of the CharArrayComparator class
+     */
+    private CharArrayComparator()
+    {
+    }
+
+
     /**
      * Compare two char arrays.
-     * 
+     *
      * @param charArray1 First char array
      * @param charArray2 Second char array
      * @return 1 if charArray1 > charArray2, 0 if charArray1 == charArray2, -1 if charArray1 < charArray2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares chars
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class CharComparator implements Comparator<Character>
 {
+    /** A static instance of a CharComparator */
+    public static final CharComparator INSTANCE = new CharComparator();
+
+    /**
+     * A private constructor of the CharComparator class
+     */
+    private CharComparator()
+    {
+    }
+
+
     /**
      * Compare two chars.
-     * 
+     *
      * @param char1 First char
      * @param char2 Second char
      * @return 1 if char1 > char2, 0 if char1 == char2, -1 if char1 < char2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares int arrays
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class IntArrayComparator implements Comparator<int[]>
 {
+    /** A static instance of a IntArrayComparator */
+    public static final IntArrayComparator INSTANCE = new IntArrayComparator();
+
+    /**
+     * A private constructor of the IntArrayComparator class
+     */
+    private IntArrayComparator()
+    {
+    }
+
+
     /**
      * Compare two long arrays.
-     * 
+     *
      * @param intArray1 First int array
      * @param intArray2 Second int array
      * @return 1 if intArray1 > intArray2, 0 if intArray1 == intArray2, -1 if intArray1 < intArray2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares integers
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class IntComparator implements Comparator<Integer>
 {
+    /** A static instance of a IntComparator */
+    public static final IntComparator INSTANCE = new IntComparator();
+
+    /**
+     * A private constructor of the IntComparator class
+     */
+    private IntComparator()
+    {
+    }
+
+
     /**
      * Compare two integers.
-     * 
+     *
      * @param integer1 First integer
      * @param integer2 Second integer
      * @return 1 if integer1 > integer2, 0 if integer1 == integer2, -1 if integer1 < integer2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares long arrays
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class LongArrayComparator implements Comparator<long[]>
 {
+    /** A static instance of a LongArrayComparator */
+    public static final LongArrayComparator INSTANCE = new LongArrayComparator();
+
+    /**
+     * A private constructor of the LongArrayComparator class
+     */
+    private LongArrayComparator()
+    {
+    }
+
+
     /**
      * Compare two long arrays.
-     * 
+     *
      * @param longArray1 First long array
      * @param longArray2 Second long array
      * @return 1 if longArray1 > longArray2, 0 if longArray1 == longArray2, -1 if longArray1 < longArray2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,23 @@ import java.util.Comparator;
 
 /**
  * Compares Longs
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class LongComparator implements Comparator<Long>
 {
+    /** A static instance of a LongComparator */
+    public static final LongComparator INSTANCE = new LongComparator();
+
+    /**
+     * A private constructor of the BooleanArrayComparator class
+     */
+    private LongComparator()
+    {
+    }
     /**
      * Compare two longs.
-     * 
+     *
      * @param long1 First long
      * @param long2 Second long
      * @return 1 if long1 > long2, 0 if long1 == long2, -1 if long1 < long2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares short arrays
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class ShortArrayComparator implements Comparator<short[]>
 {
+    /** A static instance of a ShortArrayComparator */
+    public static final ShortArrayComparator INSTANCE = new ShortArrayComparator();
+
+    /**
+     * A private constructor of the ShortArrayComparator class
+     */
+    private ShortArrayComparator()
+    {
+    }
+
+
     /**
      * Compare two short arrays.
-     * 
+     *
      * @param shortArray1 First short array
      * @param shortArray2 Second short array
      * @return 1 if shortArray1 > shortArray2, 0 if shortArray1 == shortArray2, -1 if shortArray1 < shortArray2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares shorts
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class ShortComparator implements Comparator<Short>
 {
+    /** A static instance of a ShortComparator */
+    public static final ShortComparator INSTANCE = new ShortComparator();
+
+    /**
+     * A private constructor of the ShortComparator class
+     */
+    private ShortComparator()
+    {
+    }
+
+
     /**
      * Compare two shorts.
-     * 
+     *
      * @param short1 First short
      * @param short2 Second short
      * @return 1 if short1 > short2, 0 if short1 == short2, -1 if short1 < short2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java Sat May 17 13:31:23 2014
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- * 
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
  *  under the License.
- * 
+ *
  */
 package org.apache.directory.mavibot.btree.comparator;
 
@@ -25,14 +25,25 @@ import java.util.Comparator;
 
 /**
  * Compares Strings
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class StringComparator implements Comparator<String>
 {
+    /** A static instance of a StringComparator */
+    public static final StringComparator INSTANCE = new StringComparator();
+
+    /**
+     * A private constructor of the StringComparator class
+     */
+    private StringComparator()
+    {
+    }
+
+
     /**
      * Compare two Strings.
-     * 
+     *
      * @param string1 First String
      * @param string2 Second String
      * @return 1 if string1 > String2, 0 if string1 == String2, -1 if string1 < String2

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/KeyNotFoundException.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/KeyNotFoundException.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/KeyNotFoundException.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/KeyNotFoundException.java Sat May 17 13:31:23 2014
@@ -29,6 +29,10 @@ public class KeyNotFoundException extend
 {
     /** The serial version UUID */
     private static final long serialVersionUID = 1L;
+    
+    /** A static Exception used to avoid creating a new one every time */
+    public static final KeyNotFoundException INSTANCE = new KeyNotFoundException(
+        "Cannot find an entry associated with this key" );
 
 
     /**

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/AbstractElementSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/AbstractElementSerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/AbstractElementSerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/AbstractElementSerializer.java Sat May 17 13:31:23 2014
@@ -29,7 +29,7 @@ import java.util.Comparator;
 
 /**
  * An abstract ElementSerializer that implements comon methods
- * 
+ *
  * @param <T> The type for the element to serialize and compare
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializer.java Sat May 17 13:31:23 2014
@@ -34,12 +34,15 @@ import org.apache.directory.mavibot.btre
  */
 public class BooleanSerializer extends AbstractElementSerializer<Boolean>
 {
+    /** A static instance of a BooleanSerializer */
+    public static final BooleanSerializer INSTANCE = new BooleanSerializer();
+
     /**
      * Create a new instance of BooleanSerializer
      */
-    public BooleanSerializer()
+    private BooleanSerializer()
     {
-        super( new BooleanComparator() );
+        super( BooleanComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializer.java Sat May 17 13:31:23 2014
@@ -35,12 +35,15 @@ import org.apache.directory.mavibot.btre
  */
 public class ByteArraySerializer extends AbstractElementSerializer<byte[]>
 {
+    /** A static instance of a BytearraySerializer */
+    public static final ByteArraySerializer INSTANCE = new ByteArraySerializer();
+
     /**
      * Create a new instance of ByteArraySerializer
      */
-    public ByteArraySerializer()
+    private ByteArraySerializer()
     {
-        super( new ByteArrayComparator() );
+        super( ByteArrayComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteSerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteSerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteSerializer.java Sat May 17 13:31:23 2014
@@ -34,12 +34,15 @@ import org.apache.directory.mavibot.btre
  */
 public class ByteSerializer extends AbstractElementSerializer<Byte>
 {
+    /** A static instance of a ByteSerializer */
+    public static final ByteSerializer INSTANCE = new ByteSerializer();
+
     /**
      * Create a new instance of ByteSerializer
      */
-    public ByteSerializer()
+    private ByteSerializer()
     {
-        super( new ByteComparator() );
+        super( ByteComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharArraySerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharArraySerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharArraySerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharArraySerializer.java Sat May 17 13:31:23 2014
@@ -34,12 +34,15 @@ import org.apache.directory.mavibot.btre
  */
 public class CharArraySerializer extends AbstractElementSerializer<char[]>
 {
+    /** A static instance of a CharArraySerializer */
+    public static final CharArraySerializer INSTANCE = new CharArraySerializer();
+
     /**
      * Create a new instance of CharArraySerializer
      */
-    public CharArraySerializer()
+    private CharArraySerializer()
     {
-        super( new CharArrayComparator() );
+        super( CharArrayComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharSerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharSerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharSerializer.java Sat May 17 13:31:23 2014
@@ -34,12 +34,15 @@ import org.apache.directory.mavibot.btre
  */
 public class CharSerializer extends AbstractElementSerializer<Character>
 {
+    /** A static instance of a CharSerializer */
+    public static final CharSerializer INSTANCE = new CharSerializer();
+
     /**
      * Create a new instance of CharSerializer
      */
-    public CharSerializer()
+    private CharSerializer()
     {
-        super( new CharComparator() );
+        super( CharComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/IntSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/IntSerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/IntSerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/IntSerializer.java Sat May 17 13:31:23 2014
@@ -34,12 +34,15 @@ import org.apache.directory.mavibot.btre
  */
 public class IntSerializer extends AbstractElementSerializer<Integer>
 {
+    /** A static instance of a IntSerializer */
+    public static final IntSerializer INSTANCE = new IntSerializer();
+
     /**
      * Create a new instance of IntSerializer
      */
-    public IntSerializer()
+    private IntSerializer()
     {
-        super( new IntComparator() );
+        super( IntComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongArraySerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongArraySerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongArraySerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongArraySerializer.java Sat May 17 13:31:23 2014
@@ -28,17 +28,20 @@ import org.apache.directory.mavibot.btre
 
 /**
  * A serializer for a Long[].
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class LongArraySerializer extends AbstractElementSerializer<long[]>
 {
+    /** A static instance of a LongArraySerializer */
+    public static final LongArraySerializer INSTANCE = new LongArraySerializer();
+
     /**
      * Create a new instance of LongSerializer
      */
-    public LongArraySerializer()
+    private LongArraySerializer()
     {
-        super( new LongArrayComparator() );
+        super( LongArrayComparator.INSTANCE );
     }
 
 
@@ -55,32 +58,35 @@ public class LongArraySerializer extends
         }
 
         byte[] bytes = null;
+        int pos = 0;
 
         switch ( len )
         {
             case 0:
                 bytes = new byte[4];
 
-                bytes[0] = 0x00;
-                bytes[1] = 0x00;
-                bytes[2] = 0x00;
-                bytes[3] = 0x00;
+                // The number of Long. Here, 0
+                bytes[pos++] = 0x00;
+                bytes[pos++] = 0x00;
+                bytes[pos++] = 0x00;
+                bytes[pos++] = 0x00;
 
                 break;
 
             case -1:
                 bytes = new byte[4];
 
-                bytes[0] = ( byte ) 0xFF;
-                bytes[1] = ( byte ) 0xFF;
-                bytes[2] = ( byte ) 0xFF;
-                bytes[3] = ( byte ) 0xFF;
+                // The number of Long. Here, null
+                bytes[pos++] = ( byte ) 0xFF;
+                bytes[pos++] = ( byte ) 0xFF;
+                bytes[pos++] = ( byte ) 0xFF;
+                bytes[pos++] = ( byte ) 0xFF;
 
                 break;
 
             default:
-                bytes = new byte[len * 8 + 4];
-                int pos = 0;
+                int dataLen = len * 8 + 4;
+                bytes = new byte[dataLen];
 
                 // The number of longs
                 bytes[pos++] = ( byte ) ( len >>> 24 );
@@ -111,11 +117,17 @@ public class LongArraySerializer extends
      */
     public long[] deserialize( BufferHandler bufferHandler ) throws IOException
     {
+        // Read the DataLength first. Note that we don't use it here.
         byte[] in = bufferHandler.read( 4 );
 
-        int len = IntSerializer.deserialize( in );
+        IntSerializer.deserialize( in );
 
-        switch ( len )
+        // Now, read the number of Longs
+        in = bufferHandler.read( 4 );
+
+        int nbLongs = IntSerializer.deserialize( in );
+
+        switch ( nbLongs )
         {
             case 0:
                 return new long[]
@@ -125,11 +137,12 @@ public class LongArraySerializer extends
                 return null;
 
             default:
-                long[] longs = new long[len];
+                long[] longs = new long[nbLongs];
+                in = bufferHandler.read( nbLongs * 8 );
 
-                int pos = 4;
+                int pos = 0;
 
-                for ( int i = 0; i < len; i++ )
+                for ( int i = 0; i < nbLongs; i++ )
                 {
                     longs[i] = ( ( long ) in[pos++] << 56 ) +
                         ( ( in[pos++] & 0xFFL ) << 48 ) +
@@ -151,9 +164,13 @@ public class LongArraySerializer extends
      */
     public long[] deserialize( ByteBuffer buffer ) throws IOException
     {
-        int len = buffer.getInt();
+        // Read the dataLength. Note that we don't use it here.
+        buffer.getInt();
+        
+        // The number of longs
+        int nbLongs = buffer.getInt();
 
-        switch ( len )
+        switch ( nbLongs )
         {
             case 0:
                 return new long[]
@@ -163,9 +180,9 @@ public class LongArraySerializer extends
                 return null;
 
             default:
-                long[] longs = new long[len];
+                long[] longs = new long[nbLongs];
 
-                for ( int i = 0; i < len; i++ )
+                for ( int i = 0; i < nbLongs; i++ )
                 {
                     longs[i] = buffer.getLong();
                 }

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongSerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongSerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongSerializer.java Sat May 17 13:31:23 2014
@@ -34,12 +34,15 @@ import org.apache.directory.mavibot.btre
  */
 public class LongSerializer extends AbstractElementSerializer<Long>
 {
+    /** A static instance of a LongSerializer */
+    public final static LongSerializer INSTANCE = new LongSerializer();
+
     /**
      * Create a new instance of LongSerializer
      */
-    public LongSerializer()
+    private LongSerializer()
     {
-        super( new LongComparator() );
+        super( LongComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ShortSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ShortSerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ShortSerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ShortSerializer.java Sat May 17 13:31:23 2014
@@ -34,12 +34,15 @@ import org.apache.directory.mavibot.btre
  */
 public class ShortSerializer extends AbstractElementSerializer<Short>
 {
+    /** A static instance of a ShortSerializer */
+    public final static ShortSerializer INSTANCE = new ShortSerializer();
+
     /**
      * Create a new instance of ShortSerializer
      */
-    public ShortSerializer()
+    private ShortSerializer()
     {
-        super( new ShortComparator() );
+        super( ShortComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/StringSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/StringSerializer.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/StringSerializer.java (original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/StringSerializer.java Sat May 17 13:31:23 2014
@@ -37,15 +37,15 @@ import org.apache.directory.mavibot.btre
  */
 public class StringSerializer extends AbstractElementSerializer<String>
 {
+    /** A static instance of a StringSerializer */
     public static final StringSerializer INSTANCE = new StringSerializer();
 
-
     /**
      * Create a new instance of StringSerializer
      */
-    public StringSerializer()
+    private StringSerializer()
     {
-        super( new StringComparator() );
+        super( StringComparator.INSTANCE );
     }
 
 

Modified: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeBuilderTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeBuilderTest.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeBuilderTest.java (original)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeBuilderTest.java Sat May 17 13:31:23 2014
@@ -27,10 +27,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.directory.mavibot.btree.BTree;
-import org.apache.directory.mavibot.btree.InMemoryBTreeBuilder;
-import org.apache.directory.mavibot.btree.Tuple;
-import org.apache.directory.mavibot.btree.TupleCursor;
+import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 import org.apache.directory.mavibot.btree.serializer.IntSerializer;
 import org.junit.Test;
 
@@ -43,7 +40,7 @@ import org.junit.Test;
 public class InMemoryBTreeBuilderTest
 {
     @Test
-    public void testIntegerTree() throws IOException
+    public void testIntegerTree() throws IOException, KeyNotFoundException
     {
         List<Tuple<Integer, Integer>> sortedTuple = new ArrayList<Tuple<Integer, Integer>>();
 
@@ -53,7 +50,7 @@ public class InMemoryBTreeBuilderTest
             sortedTuple.add( t );
         }
 
-        IntSerializer ser = new IntSerializer();
+        IntSerializer ser = IntSerializer.INSTANCE;
         InMemoryBTreeBuilder<Integer, Integer> bb = new InMemoryBTreeBuilder<Integer, Integer>( "master", 4, ser, ser );
 
         // contains 1, 2, 3, 4, 5, 6, 7

Modified: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeConfigurationTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeConfigurationTest.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeConfigurationTest.java (original)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeConfigurationTest.java Sat May 17 13:31:23 2014
@@ -25,8 +25,6 @@ import static org.junit.Assert.assertNot
 import java.io.File;
 import java.io.IOException;
 
-import org.apache.directory.mavibot.btree.BTree;
-import org.apache.directory.mavibot.btree.InMemoryBTree;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 import org.apache.directory.mavibot.btree.serializer.IntSerializer;
 import org.apache.directory.mavibot.btree.serializer.StringSerializer;
@@ -37,7 +35,7 @@ import org.junit.rules.TemporaryFolder;
 
 /**
  * Test the creation of a BTree with a configuration.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class InMemoryBTreeConfigurationTest
@@ -123,7 +121,7 @@ public class InMemoryBTreeConfigurationT
         InMemoryBTreeConfiguration<Integer, String> config = new InMemoryBTreeConfiguration<Integer, String>();
         config.setName( "basic" );
         config.setPageSize( 32 );
-        config.setSerializers( new IntSerializer(), new StringSerializer() );
+        config.setSerializers( IntSerializer.INSTANCE, StringSerializer.INSTANCE );
 
         try
         {
@@ -170,7 +168,7 @@ public class InMemoryBTreeConfigurationT
 
 
     /**
-     * Test the creation of a BTree using the BTreeConfiguration, flushing the 
+     * Test the creation of a BTree using the BTreeConfiguration, flushing the
      * tree on disk, then reloading it in another BTree.
      */
     @Test
@@ -184,7 +182,7 @@ public class InMemoryBTreeConfigurationT
         {
             InMemoryBTreeConfiguration<Integer, String> config = new InMemoryBTreeConfiguration<Integer, String>();
             config.setPageSize( 32 );
-            config.setSerializers( new IntSerializer(), new StringSerializer() );
+            config.setSerializers( IntSerializer.INSTANCE, StringSerializer.INSTANCE );
 
             config.setFilePath( parent );
             config.setName( "mavibot" );

Modified: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeDuplicateKeyTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeDuplicateKeyTest.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeDuplicateKeyTest.java (original)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeDuplicateKeyTest.java Sat May 17 13:31:23 2014
@@ -33,6 +33,7 @@ import java.util.UUID;
 
 import org.apache.directory.mavibot.btree.exception.BTreeAlreadyManagedException;
 import org.apache.directory.mavibot.btree.exception.DuplicateValueNotAllowedException;
+import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 import org.apache.directory.mavibot.btree.serializer.IntSerializer;
 import org.apache.directory.mavibot.btree.serializer.LongSerializer;
 import org.apache.directory.mavibot.btree.serializer.StringSerializer;
@@ -47,9 +48,9 @@ import org.junit.Test;
 public class InMemoryBTreeDuplicateKeyTest
 {
     @Test
-    public void testInsertNullValue() throws IOException
+    public void testInsertNullValue() throws IOException, KeyNotFoundException
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         BTree<Integer, Integer> btree = BTreeFactory.createInMemoryBTree( "master", serializer, serializer );
 
@@ -69,9 +70,9 @@ public class InMemoryBTreeDuplicateKeyTe
 
 
     @Test
-    public void testBrowseEmptyTree() throws IOException
+    public void testBrowseEmptyTree() throws IOException, KeyNotFoundException
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         BTree<Integer, Integer> btree = BTreeFactory.createInMemoryBTree( "master", serializer, serializer );
 
@@ -105,9 +106,9 @@ public class InMemoryBTreeDuplicateKeyTe
 
 
     @Test
-    public void testDuplicateKey() throws IOException
+    public void testDuplicateKey() throws IOException, KeyNotFoundException
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<Integer, Integer> config = new InMemoryBTreeConfiguration<Integer, Integer>();
         config.setAllowDuplicates( true );
@@ -163,7 +164,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testGetDuplicateKey() throws Exception
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<Integer, Integer> config = new InMemoryBTreeConfiguration<Integer, Integer>();
         config.setAllowDuplicates( true );
@@ -199,7 +200,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testRemoveDuplicateKey() throws Exception
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<Integer, Integer> config = new InMemoryBTreeConfiguration<Integer, Integer>();
         config.setAllowDuplicates( true );
@@ -235,7 +236,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testFullPage() throws Exception
     {
-        StringSerializer serializer = new StringSerializer();
+        StringSerializer serializer = StringSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<String, String> config = new InMemoryBTreeConfiguration<String, String>();
         config.setAllowDuplicates( true );
@@ -298,7 +299,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testMoveFirst() throws Exception
     {
-        StringSerializer serializer = new StringSerializer();
+        StringSerializer serializer = StringSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<String, String> config = new InMemoryBTreeConfiguration<String, String>();
         config.setAllowDuplicates( true );
@@ -387,7 +388,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test(expected = NoSuchElementException.class)
     public void testMoveLast() throws Exception
     {
-        StringSerializer serializer = new StringSerializer();
+        StringSerializer serializer = StringSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<String, String> config = new InMemoryBTreeConfiguration<String, String>();
         config.setAllowDuplicates( true );
@@ -433,7 +434,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test(expected = NoSuchElementException.class)
     public void testNextPrevKey() throws Exception
     {
-        StringSerializer serializer = new StringSerializer();
+        StringSerializer serializer = StringSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<String, String> config = new InMemoryBTreeConfiguration<String, String>();
         config.setAllowDuplicates( true );
@@ -546,7 +547,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testMoveToNextAndPrevWithPageBoundaries() throws Exception
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<Integer, Integer> config = new InMemoryBTreeConfiguration<Integer, Integer>();
         config.setAllowDuplicates( true );
@@ -621,7 +622,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testNextAfterPrev() throws Exception
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<Integer, Integer> config = new InMemoryBTreeConfiguration<Integer, Integer>();
         config.setAllowDuplicates( true );
@@ -667,7 +668,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testMoveToNextAndTraverseBackward() throws Exception
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<Integer, Integer> config = new InMemoryBTreeConfiguration<Integer, Integer>();
         config.setAllowDuplicates( true );
@@ -706,7 +707,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testMoveToPrevAndTraverseForward() throws Exception
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<Integer, Integer> config = new InMemoryBTreeConfiguration<Integer, Integer>();
         config.setAllowDuplicates( true );
@@ -744,8 +745,8 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test(expected = DuplicateValueNotAllowedException.class)
     public void testBTreeForbidDups() throws IOException, BTreeAlreadyManagedException
     {
-        BTree<Long, String> singleValueBtree = BTreeFactory.createInMemoryBTree( "test2", new LongSerializer(),
-            new StringSerializer(), BTree.FORBID_DUPLICATES );
+        BTree<Long, String> singleValueBtree = BTreeFactory.createInMemoryBTree( "test2", LongSerializer.INSTANCE,
+            StringSerializer.INSTANCE, BTree.FORBID_DUPLICATES );
 
         for ( long i = 0; i < 64; i++ )
         {

Modified: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeFlushTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeFlushTest.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeFlushTest.java (original)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeFlushTest.java Sat May 17 13:31:23 2014
@@ -29,10 +29,6 @@ import java.io.IOException;
 import java.util.Random;
 import java.util.Set;
 
-import org.apache.directory.mavibot.btree.BTree;
-import org.apache.directory.mavibot.btree.InMemoryBTree;
-import org.apache.directory.mavibot.btree.Tuple;
-import org.apache.directory.mavibot.btree.TupleCursor;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 import org.apache.directory.mavibot.btree.serializer.IntSerializer;
 import org.apache.directory.mavibot.btree.serializer.LongSerializer;
@@ -44,7 +40,7 @@ import org.junit.rules.TemporaryFolder;
 
 /**
  * A unit test class for BTree flush() operation
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class InMemoryBTreeFlushTest
@@ -132,8 +128,8 @@ public class InMemoryBTreeFlushTest
         long delta = l1;
         int nbElems = 100000;
 
-        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", new LongSerializer(),
-            new StringSerializer() );
+        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", LongSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 32 );
 
         for ( int i = 0; i < nbElems; i++ )
@@ -224,8 +220,8 @@ public class InMemoryBTreeFlushTest
         // Create a BTree with pages containing 8 elements
         String path = tempFolder.getRoot().getCanonicalPath();
 
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", path, new IntSerializer(),
-            new StringSerializer() );
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", path, IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 8 );
 
         File journal = ( ( InMemoryBTree<Integer, String> ) btree ).getJournal();
@@ -251,8 +247,8 @@ public class InMemoryBTreeFlushTest
             assertEquals( 0, journal.length() );
 
             // Load the data into a new tree
-            BTree<Integer, String> btreeLoaded = BTreeFactory.createInMemoryBTree( "test", path, new IntSerializer(),
-                new StringSerializer() );
+            BTree<Integer, String> btreeLoaded = BTreeFactory.createInMemoryBTree( "test", path, IntSerializer.INSTANCE,
+                StringSerializer.INSTANCE );
             btree.setPageSize( 8 );
 
             TupleCursor<Integer, String> cursor1 = btree.browse();
@@ -294,8 +290,8 @@ public class InMemoryBTreeFlushTest
         BTree<Long, String> btree = BTreeFactory.createInMemoryBTree(
             "test",
             dataFile.getParent(),
-            new LongSerializer(),
-            new StringSerializer() );
+            LongSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 32 );
         btree.close();
     }

Modified: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTest.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTest.java (original)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTest.java Sat May 17 13:31:23 2014
@@ -168,8 +168,8 @@ public class InMemoryBTreeTest
 
         for ( int j = 0; j < nbTrees; j++ )
         {
-            BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", new LongSerializer(),
-                new StringSerializer() );
+            BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", LongSerializer.INSTANCE,
+                StringSerializer.INSTANCE );
             btree.setPageSize( 32 );
 
             for ( int i = 0; i < nbElems; i++ )
@@ -271,8 +271,8 @@ public class InMemoryBTreeTest
 
         for ( int j = 0; j < nbTrees; j++ )
         {
-            BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", new LongSerializer(),
-                new StringSerializer() );
+            BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", LongSerializer.INSTANCE,
+                StringSerializer.INSTANCE );
             btree.setPageSize( 8 );
 
             for ( int i = 0; i < nbElems; i++ )
@@ -387,8 +387,8 @@ public class InMemoryBTreeTest
                 368, 245, 1005, 226, 939, 320, 396, 437, 373, 61
         };
 
-        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", new LongSerializer(),
-            new StringSerializer() );
+        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", LongSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 8 );
 
         for ( long value : values )
@@ -447,8 +447,8 @@ public class InMemoryBTreeTest
 
         Random random = new Random( System.nanoTime() );
 
-        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", new LongSerializer(),
-            new StringSerializer() );
+        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", LongSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 8 );
 
         // Insert some values
@@ -508,8 +508,8 @@ public class InMemoryBTreeTest
     @Ignore("This is a debug test")
     public void testPageInsertDebug() throws Exception
     {
-        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", new LongSerializer(),
-            new StringSerializer() );
+        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", LongSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 4 );
 
         Long[] elems = new Long[]
@@ -615,8 +615,8 @@ public class InMemoryBTreeTest
     public void testBrowseForward() throws Exception
     {
         // Create a BTree with pages containing 8 elements
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", new IntSerializer(),
-            new StringSerializer() );
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 8 );
 
         // Inject the values
@@ -700,8 +700,8 @@ public class InMemoryBTreeTest
     public void testBrowseBackward() throws Exception
     {
         // Create a BTree with pages containing 8 elements
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", new IntSerializer(),
-            new StringSerializer() );
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 8 );
 
         // Inject the values
@@ -776,8 +776,8 @@ public class InMemoryBTreeTest
     public void testBrowseEmptyTree() throws Exception
     {
         // Create a BTree with pages containing 8 elements
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", new IntSerializer(),
-            new StringSerializer() );
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 8 );
 
         TupleCursor<Integer, String> cursor = btree.browse();
@@ -797,8 +797,8 @@ public class InMemoryBTreeTest
     public void testBrowseForwardBackward() throws Exception
     {
         // Create a BTree with pages containing 4 elements
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", new IntSerializer(),
-            new StringSerializer() );
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 4 );
 
         for ( int i = 0; i < 16; i++ )
@@ -911,7 +911,7 @@ public class InMemoryBTreeTest
      * Test the exist() method
      */
     @Test
-    public void testExist() throws IOException
+    public void testExist() throws IOException, KeyNotFoundException
     {
         // Create a BTree with pages containing 4 elements
         BTree<Integer, String> btree = createTwoLevelBTreeFullLeaves();
@@ -1026,8 +1026,8 @@ public class InMemoryBTreeTest
     public void testBrowseNonExistingKey() throws Exception
     {
         // Create a BTree with pages containing 8 elements
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", new IntSerializer(),
-            new StringSerializer() );
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 8 );
         for ( int i = 0; i < 11; i++ )
         {
@@ -1091,8 +1091,8 @@ public class InMemoryBTreeTest
      */
     private BTree<Integer, String> createTwoLevelBTreeFullLeaves() throws IOException
     {
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", new IntSerializer(),
-            new StringSerializer() );
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 4 );
 
         // Create a tree with 5 children containing 4 elements each. The tree is full.
@@ -1114,8 +1114,8 @@ public class InMemoryBTreeTest
      */
     private BTree<Integer, String> createTwoLevelBTreeHalfFullLeaves() throws IOException
     {
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", new IntSerializer(),
-            new StringSerializer() );
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 4 );
 
         // Create a tree with 5 children containing 4 elements each. The tree is full.
@@ -1146,8 +1146,8 @@ public class InMemoryBTreeTest
         // Create a BTree with pages containing 4 elements
         int pageSize = 4;
 
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", new IntSerializer(),
-            new StringSerializer(),
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE,
             pageSize );
 
         InMemoryNode<Integer, String> root = new InMemoryNode<Integer, String>( btree, 1L, pageSize );
@@ -1193,7 +1193,7 @@ public class InMemoryBTreeTest
      * @param element The removed element
      * @param expected The expected set of elements
      */
-    private void checkRemoval( BTree<Integer, String> btree, int element, Set<Integer> expected ) throws IOException
+    private void checkRemoval( BTree<Integer, String> btree, int element, Set<Integer> expected ) throws IOException, KeyNotFoundException
     {
         Tuple<Integer, String> removed = btree.delete( element );
         assertEquals( element, removed.getKey().intValue() );
@@ -1213,7 +1213,7 @@ public class InMemoryBTreeTest
      * @param btree The tree to check
      * @param expected The set with the expected elements
      */
-    private void checkTree( BTree<Integer, String> btree, Set<Integer> expected )
+    private void checkTree( BTree<Integer, String> btree, Set<Integer> expected ) throws KeyNotFoundException
     {
         try
         {
@@ -1723,7 +1723,7 @@ public class InMemoryBTreeTest
      * Test the addition of elements with null values
      */
     @Test
-    public void testAdditionNullValues() throws IOException
+    public void testAdditionNullValues() throws IOException, KeyNotFoundException
     {
         BTree<Integer, String> btree = createMultiLevelBTreeLeavesHalfFull();
 
@@ -1766,8 +1766,8 @@ public class InMemoryBTreeTest
         long delta = System.currentTimeMillis();
 
         // Create a BTree with 5 million entries
-        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", new LongSerializer(),
-            new StringSerializer() );
+        BTree<Long, String> btree = BTreeFactory.createInMemoryBTree( "test", LongSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 32 );
 
         for ( int i = 0; i < nbElems; i++ )
@@ -1869,8 +1869,8 @@ public class InMemoryBTreeTest
     public void testBrowseForwardBackwardExtremes() throws Exception
     {
         // Create a BTree with pages containing 4 elements
-        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", new IntSerializer(),
-            new StringSerializer() );
+        BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", IntSerializer.INSTANCE,
+            StringSerializer.INSTANCE );
         btree.setPageSize( 4 );
 
         for ( int i = 8; i < 13; i++ )
@@ -1925,7 +1925,7 @@ public class InMemoryBTreeTest
     @Test
     public void testNextAfterPrev() throws Exception
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<Integer, Integer> config = new InMemoryBTreeConfiguration<Integer, Integer>();
         config.setName( "master" );
@@ -1965,7 +1965,7 @@ public class InMemoryBTreeTest
     @Test
     public void testCheckRootPageContents() throws Exception
     {
-        IntSerializer ser = new IntSerializer();
+        IntSerializer ser = IntSerializer.INSTANCE;
         BTree<Integer, Integer> btree = BTreeFactory.createInMemoryBTree( "master1", ser, ser, 4 );
 
         for ( int i = 1; i < 8; i++ )

Modified: directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTestOps.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTestOps.java?rev=1595477&r1=1595476&r2=1595477&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTestOps.java (original)
+++ directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTestOps.java Sat May 17 13:31:23 2014
@@ -23,7 +23,6 @@ package org.apache.directory.mavibot.btr
 import java.io.IOException;
 import java.util.Random;
 
-import org.apache.directory.mavibot.btree.BTree;
 import org.apache.directory.mavibot.btree.serializer.LongSerializer;
 import org.apache.directory.mavibot.btree.serializer.StringSerializer;
 import org.junit.AfterClass;
@@ -33,7 +32,7 @@ import org.junit.Test;
 
 /**
  * A class to test multi-threaded operations on the btree
- *  
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class InMemoryBTreeTestOps
@@ -49,7 +48,7 @@ public class InMemoryBTreeTestOps
     @BeforeClass
     public static void setup() throws IOException
     {
-        btree = BTreeFactory.createInMemoryBTree( "test", new LongSerializer(), new StringSerializer() );
+        btree = BTreeFactory.createInMemoryBTree( "test", LongSerializer.INSTANCE, StringSerializer.INSTANCE );
     }
 
 
@@ -71,7 +70,7 @@ public class InMemoryBTreeTestOps
     {
         Random random = new Random( System.nanoTime() );
 
-        int nbElems = 500000;
+        int nbElems = 50000;
 
         // Create a BTree with 500 000 entries
         btree.setPageSize( 32 );