directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1566659 [5/6] - in /directory/mavibot/branches/with-txns/mavibot: img/ src/main/java/org/apache/directory/mavibot/btree/ src/main/java/org/apache/directory/mavibot/btree/comparator/ src/main/java/org/apache/directory/mavibot/btree/exceptio...
Date Mon, 10 Feb 2014 15:35:20 GMT
Modified: directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java Mon Feb 10 15:35:18 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 );
     }
 
 

Added: directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/TransactionManager.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/TransactionManager.java?rev=1566659&view=auto
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/TransactionManager.java (added)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/TransactionManager.java Mon Feb 10 15:35:18 2014
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  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;
+
+/**
+ * An interface used to manage the transactions mechanism in B-trees. Transactions are cross
+ * B-trees.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface TransactionManager
+{
+    /**
+     * Starts a transaction
+     */
+    void beginTransaction();
+
+
+    /**
+     * Commits a transaction
+     */
+    void commit();
+
+
+    /**
+     * Rollback a transaction
+     */
+    void rollback();
+}

Modified: directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/WriteTransaction.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/WriteTransaction.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/WriteTransaction.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/WriteTransaction.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java Mon Feb 10 15:35:18 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

Added: directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/FileException.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/FileException.java?rev=1566659&view=auto
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/FileException.java (added)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/FileException.java Mon Feb 10 15:35:18 2014
@@ -0,0 +1,72 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  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.exception;
+
+
+/**
+ * An exception thrown when there is a problem writing data on disk
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class FileException extends RuntimeException
+{
+    /** The serial version UUID */
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * Creates a new instance of FileException.
+     */
+    public FileException()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of FileException.
+     *
+     * @param explanation The message associated with the exception
+     */
+    public FileException( String explanation )
+    {
+        super( explanation );
+    }
+
+
+    /**
+     * Creates a new instance of FileException.
+     */
+    public FileException( Throwable cause )
+    {
+        super( cause );
+    }
+
+
+    /**
+     * Creates a new instance of FileException.
+     *
+     * @param explanation The message associated with the exception
+     * @param cause The root cause for this exception
+     */
+    public FileException( String explanation, Throwable cause )
+    {
+        super( explanation, cause );
+    }
+}

Added: directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/InvalidOffsetException.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/InvalidOffsetException.java?rev=1566659&view=auto
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/InvalidOffsetException.java (added)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/InvalidOffsetException.java Mon Feb 10 15:35:18 2014
@@ -0,0 +1,72 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  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.exception;
+
+
+/**
+ * An exception thrown when the offset is incorrect
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class InvalidOffsetException extends RuntimeException
+{
+    /** The serial version UUID */
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * Creates a new instance of InvalidOffsetException.
+     */
+    public InvalidOffsetException()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of InvalidOffsetException.
+     *
+     * @param explanation The message associated with the exception
+     */
+    public InvalidOffsetException( String explanation )
+    {
+        super( explanation );
+    }
+
+
+    /**
+     * Creates a new instance of InvalidOffsetException.
+     */
+    public InvalidOffsetException( Throwable cause )
+    {
+        super( cause );
+    }
+
+
+    /**
+     * Creates a new instance of BTreeCreationException.
+     *
+     * @param explanation The message associated with the exception
+     * @param cause The root cause for this exception
+     */
+    public InvalidOffsetException( String explanation, Throwable cause )
+    {
+        super( explanation, cause );
+    }
+}

Modified: directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/AbstractElementSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/AbstractElementSerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/AbstractElementSerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/AbstractElementSerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteSerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteSerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteSerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharArraySerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharArraySerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharArraySerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharArraySerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharSerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharSerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharSerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/IntSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/IntSerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/IntSerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/IntSerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongArraySerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongArraySerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongArraySerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongArraySerializer.java Mon Feb 10 15:35:18 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 );
     }
 
 

Modified: directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongSerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongSerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongSerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ShortSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ShortSerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ShortSerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ShortSerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/StringSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/StringSerializer.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/StringSerializer.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/StringSerializer.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeBuilderTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeBuilderTest.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeBuilderTest.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeBuilderTest.java Mon Feb 10 15:35:18 2014
@@ -27,10 +27,6 @@ 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.serializer.IntSerializer;
 import org.junit.Test;
 
@@ -53,7 +49,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/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeConfigurationTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeConfigurationTest.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeConfigurationTest.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeConfigurationTest.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeDuplicateKeyTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeDuplicateKeyTest.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeDuplicateKeyTest.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeDuplicateKeyTest.java Mon Feb 10 15:35:18 2014
@@ -49,7 +49,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testInsertNullValue() throws IOException
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         BTree<Integer, Integer> btree = BTreeFactory.createInMemoryBTree( "master", serializer, serializer );
 
@@ -71,7 +71,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testBrowseEmptyTree() throws IOException
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         BTree<Integer, Integer> btree = BTreeFactory.createInMemoryBTree( "master", serializer, serializer );
 
@@ -107,7 +107,7 @@ public class InMemoryBTreeDuplicateKeyTe
     @Test
     public void testDuplicateKey() throws IOException
     {
-        IntSerializer serializer = new IntSerializer();
+        IntSerializer serializer = IntSerializer.INSTANCE;
 
         InMemoryBTreeConfiguration<Integer, Integer> config = new InMemoryBTreeConfiguration<Integer, Integer>();
         config.setAllowDuplicates( true );
@@ -163,7 +163,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 +199,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 +235,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 +298,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 +387,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 +433,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 +546,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 +621,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 +667,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 +706,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 +744,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/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeFlushTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeFlushTest.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeFlushTest.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeFlushTest.java Mon Feb 10 15:35:18 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/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTest.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTest.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTest.java Mon Feb 10 15:35:18 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++ )
@@ -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 );
@@ -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/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTestOps.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTestOps.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTestOps.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTestOps.java Mon Feb 10 15:35:18 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 );
     }
 
 

Modified: directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryLeafTest.java
URL: http://svn.apache.org/viewvc/directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryLeafTest.java?rev=1566659&r1=1566658&r2=1566659&view=diff
==============================================================================
--- directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryLeafTest.java (original)
+++ directory/mavibot/branches/with-txns/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryLeafTest.java Mon Feb 10 15:35:18 2014
@@ -26,18 +26,6 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 
-import org.apache.directory.mavibot.btree.BTree;
-import org.apache.directory.mavibot.btree.BorrowedFromLeftResult;
-import org.apache.directory.mavibot.btree.BorrowedFromRightResult;
-import org.apache.directory.mavibot.btree.DeleteResult;
-import org.apache.directory.mavibot.btree.InsertResult;
-import org.apache.directory.mavibot.btree.KeyHolder;
-import org.apache.directory.mavibot.btree.MergedWithSiblingResult;
-import org.apache.directory.mavibot.btree.NotPresentResult;
-import org.apache.directory.mavibot.btree.Page;
-import org.apache.directory.mavibot.btree.PageHolder;
-import org.apache.directory.mavibot.btree.RemoveResult;
-import org.apache.directory.mavibot.btree.Tuple;
 import org.apache.directory.mavibot.btree.exception.KeyNotFoundException;
 import org.apache.directory.mavibot.btree.serializer.LongSerializer;
 import org.apache.directory.mavibot.btree.serializer.StringSerializer;
@@ -48,7 +36,7 @@ import org.junit.Test;
 
 /**
  * A unit test class for Leaf
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class InMemoryLeafTest
@@ -62,7 +50,7 @@ public class InMemoryLeafTest
     @Before
     public void setup() throws IOException
     {
-        btree = BTreeFactory.createInMemoryBTree( "test", new LongSerializer(), new StringSerializer() );
+        btree = BTreeFactory.createInMemoryBTree( "test", LongSerializer.INSTANCE, StringSerializer.INSTANCE );
         btree.setPageSize( 8 );
     }
 
@@ -76,12 +64,12 @@ public class InMemoryLeafTest
 
     /**
      * A helper method to insert elements in a Leaf
-     * @throws IOException 
+     * @throws IOException
      */
     private InMemoryLeaf<Long, String> insert( InMemoryLeaf<Long, String> leaf, long key, String value )
         throws IOException
     {
-        InsertResult<Long, String> result = leaf.insert( 1L, key, value );
+        InsertResult<Long, String> result = leaf.insert( key, value, 1L );
 
         return ( InMemoryLeaf<Long, String> ) ( ( ModifyResult<Long, String> ) result ).getModifiedPage();
     }
@@ -96,7 +84,7 @@ public class InMemoryLeafTest
     {
         InMemoryLeaf<Long, String> leaf = new InMemoryLeaf<Long, String>( btree );
 
-        DeleteResult<Long, String> result = leaf.delete( 1L, 1L, null, null, -1 );
+        DeleteResult<Long, String> result = leaf.delete( 1L, null, 1L, null, -1 );
 
         assertEquals( NotPresentResult.NOT_PRESENT, result );
     }
@@ -115,7 +103,7 @@ public class InMemoryLeafTest
         leaf = insert( leaf, 3L, "v3" );
         leaf = insert( leaf, 4L, "v4" );
 
-        DeleteResult<Long, String> result = leaf.delete( 2L, 5L, null, null, -1 );
+        DeleteResult<Long, String> result = leaf.delete( 5L, null, 2L, null, -1 );
 
         assertEquals( NotPresentResult.NOT_PRESENT, result );
     }
@@ -134,7 +122,7 @@ public class InMemoryLeafTest
         leaf = insert( leaf, 3L, "v3" );
         leaf = insert( leaf, 4L, "v4" );
 
-        DeleteResult<Long, String> result = leaf.delete( 4L, 3L, null, null, -1 );
+        DeleteResult<Long, String> result = leaf.delete( 3L, null, 4L, null, -1 );
 
         assertTrue( result instanceof RemoveResult );
 
@@ -181,7 +169,7 @@ public class InMemoryLeafTest
         leaf = insert( leaf, 3L, "v3" );
         leaf = insert( leaf, 4L, "v4" );
 
-        DeleteResult<Long, String> result = leaf.delete( 4L, 1L, null, null, -1 );
+        DeleteResult<Long, String> result = leaf.delete( 1L, null, 4L, null, -1 );
 
         assertTrue( result instanceof RemoveResult );
 
@@ -224,7 +212,7 @@ public class InMemoryLeafTest
      *            +--[1, 2, 3, 4, 5]
      * [6, 10]-+--[6, 7, 8, 9]
      *            +--[10, 11, 12, 13]
-     * @throws IOException 
+     * @throws IOException
      */
     @Test
     public void testDeleteBorrowingFromLeftSibling() throws IOException
@@ -262,7 +250,7 @@ public class InMemoryLeafTest
         parent.setKey( 1, new KeyHolder<Long>( 10L ) );
 
         // Now, delete the element from the target page
-        DeleteResult<Long, String> result = target.delete( 2L, 7L, null, parent, 1 );
+        DeleteResult<Long, String> result = target.delete( 7L, null, 2L, parent, 1 );
 
         assertTrue( result instanceof BorrowedFromLeftResult );
 
@@ -294,7 +282,7 @@ public class InMemoryLeafTest
     /**
      * Check that deleting an element from a leaf with N/2 element works when we borrow
      * an element in a right page with more than N/2 elements
-     * @throws IOException 
+     * @throws IOException
      */
     @Test
     public void testDeleteBorrowingFromRightSibling() throws IOException
@@ -332,7 +320,7 @@ public class InMemoryLeafTest
         parent.setKey( 1, new KeyHolder<Long>( 10L ) );
 
         // Now, delete the element from the target page
-        DeleteResult<Long, String> result = target.delete( 2L, 7L, null, parent, 1 );
+        DeleteResult<Long, String> result = target.delete( 7L, null, 2L, parent, 1 );
 
         assertTrue( result instanceof BorrowedFromRightResult );
 
@@ -365,7 +353,7 @@ public class InMemoryLeafTest
     /**
      * Check that deleting an element from a leaf with N/2 element works when we merge
      * it with one of its sibling, if both has N/2 elements
-     * @throws IOException 
+     * @throws IOException
      */
     @Test
     public void testDeleteMergeWithSibling() throws IOException
@@ -402,7 +390,7 @@ public class InMemoryLeafTest
         parent.setKey( 1, new KeyHolder<Long>( 9L ) );
 
         // Now, delete the element from the target page
-        DeleteResult<Long, String> result = target.delete( 2L, 7L, null, parent, 1 );
+        DeleteResult<Long, String> result = target.delete( 7L, null, 2L, parent, 1 );
 
         assertTrue( result instanceof MergedWithSiblingResult );
 
@@ -438,7 +426,7 @@ public class InMemoryLeafTest
         for ( long i = 0; i < 8; i++ )
         {
             long value = i + i + 1;
-            leaf = ( InMemoryLeaf<Long, String> ) ( ( ModifyResult<Long, String> ) leaf.insert( 0L, value, "V" + value ) )
+            leaf = ( InMemoryLeaf<Long, String> ) ( ( ModifyResult<Long, String> ) leaf.insert( value, "V" + value, 0L ) )
                 .getModifiedPage();
         }
 



Mime
View raw message