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 2012/01/19 15:14:11 UTC

svn commit: r1233385 - in /directory/sandbox/elecharny/shared-mvbt: ./ src/main/java/org/apache/directory/btree/ src/main/java/org/apache/directory/btree/helper/ src/test/java/org/apache/directory/btree/

Author: elecharny
Date: Thu Jan 19 14:14:10 2012
New Revision: 1233385

URL: http://svn.apache.org/viewvc?rev=1233385&view=rev
Log:
o Fixed dependencies
o Removed JDBM code and replaced it by ADS code
o Added ASL 2.0 headers

(this is a complete rewrite, JDBM has *not* been copied. The initial headers were present because the classes BTree and such were used as a place holder with the same classes and methods name, for compatibility sake, and I forgot to get rid of them)

Removed:
    directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/helper/Serializer.java
Modified:
    directory/sandbox/elecharny/shared-mvbt/pom.xml
    directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/BTree.java
    directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Find.java
    directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Page.java
    directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/PageInsert.java
    directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/helper/LongComparator.java
    directory/sandbox/elecharny/shared-mvbt/src/test/java/org/apache/directory/btree/PageTest.java

Modified: directory/sandbox/elecharny/shared-mvbt/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/elecharny/shared-mvbt/pom.xml?rev=1233385&r1=1233384&r2=1233385&view=diff
==============================================================================
--- directory/sandbox/elecharny/shared-mvbt/pom.xml (original)
+++ directory/sandbox/elecharny/shared-mvbt/pom.xml Thu Jan 19 14:14:10 2012
@@ -33,12 +33,18 @@
 
   <description>A MVCC BTree Implementation</description>
 
-  <!-- dependencies>
+  <properties>
+    <junit.version>4.10</junit.version>
+  </properties>
+
+  <dependencies>
     <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>apacheds-i18n</artifactId>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit.version}</version>
+      <scope>test</scope>
     </dependency>
-  </dependencies -->
+  </dependencies>
   
   <build>
     <pluginManagement>

Modified: directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/BTree.java
URL: http://svn.apache.org/viewvc/directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/BTree.java?rev=1233385&r1=1233384&r2=1233385&view=diff
==============================================================================
--- directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/BTree.java (original)
+++ directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/BTree.java Thu Jan 19 14:14:10 2012
@@ -1,88 +1,36 @@
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- *    statements and notices.  Redistributions must also contain a
- *    copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- *    above copyright notice, this list of conditions and the
- *    following disclaimer in the documentation and/or other
- *    materials provided with the distribution.
+/*
+ *  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
  *
- * 3. The name "JDBM" must not be used to endorse or promote
- *    products derived from this Software without prior written
- *    permission of Cees de Groot.  For written permission,
- *    please contact cg@cdegroot.com.
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
- * 4. Products derived from this Software may not be called "JDBM"
- *    nor may "JDBM" appear in their names without prior written
- *    permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- *    (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2001 by their associated contributors.
+ *  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.btree;
 
 
 import java.io.IOException;
-import java.io.Serializable;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
 import org.apache.directory.btree.Page.OverflowResult;
 import org.apache.directory.btree.Page.PageResult;
-import org.apache.directory.btree.helper.Serializer;
-import org.apache.directory.server.i18n.I18n;
 
 
 /**
- * B+Tree persistent indexing data structure.  B+Trees are optimized for
- * block-based, random I/O storage because they store multiple keys on
- * one tree node (called <code>Page</code>).  In addition, the leaf nodes
- * directly contain (inline) the values associated with the keys, allowing a
- * single (or sequential) disk read of all the values on the page.
- * <p>
- * B+Trees are n-airy, yeilding log(N) search cost.  They are self-balancing,
- * preventing search performance degradation when the size of the tree grows.
- * <p>
- * Keys and associated values must be <code>Serializable</code> objects. The
- * user is responsible to supply a serializable <code>Comparator</code> object
- * to be used for the ordering of entries, which are also called <code>Tuple</code>.
- * The B+Tree allows traversing the keys in forward and reverse order using a
- * <p>
- * This implementation does not directly support duplicate keys, but it is
- * possible to handle duplicates by inlining or referencing an object collection
- * as a value.
- * <p>
- * There is no limit on key size or value size, but it is recommended to keep
- * both as small as possible to reduce disk I/O.   This is especially true for
- * the key size, which impacts all non-leaf <code>Page</code> objects.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class BTree<K, V>
 {
@@ -92,7 +40,7 @@ public class BTree<K, V>
     final static long serialVersionUID = 1L;
 
     /** Default page size (number of entries per node) */
-    public static final int DEFAULT_SIZE = 16;
+    public static final int DEFAULT_PAGE_SIZE = 16;
 
     /** This BTree's record ID in the PageManager. */
     private transient long recordId;
@@ -102,12 +50,6 @@ public class BTree<K, V>
     /** Comparator used to index entries. */
     Comparator<K> comparator;
 
-    /** Serializer used to serialize index keys (optional) */
-    protected Serializer keySerializer;
-
-    /** Serializer used to serialize index values (optional) */
-    protected Serializer valueSerializer;
-    
     protected Page<K, V> rootPage;
     
     private Map<Long, Page<K, V>> roots = new HashMap<Long, Page<K, V>>();
@@ -124,83 +66,28 @@ public class BTree<K, V>
     /** Number of entries in each Page. */
     protected int pageSize;
 
-    /**
-     * No-argument constructor used by serialization.
-     */
-    public BTree()
-    {
-        // empty
-    }
-
 
     /**
-     * Create a new persistent BTree, with 16 entries per node.
-     *
-     * @param recman Record manager used for persistence.
-     * @param comparator Comparator used to order index entries
+     * 
      */
     public BTree( Comparator<K> comparator ) throws IOException
     {
-        createInstance( comparator, null, null, DEFAULT_SIZE );
-    }
-
-
-    /**
-     * Create a new persistent BTree, with 16 entries per node.
-     *
-     * @param recman Record manager used for persistence.
-     * @param keySerializer Serializer used to serialize index keys (optional)
-     * @param valueSerializer Serializer used to serialize index values (optional)
-     * @param comparator Comparator used to order index entries
-     */
-    public BTree( Comparator<K> comparator, Serializer keySerializer, Serializer valueSerializer ) throws IOException
-    {
-        createInstance( comparator, keySerializer, valueSerializer, DEFAULT_SIZE );
-    }
-
-
-    /**
-     * Create a new persistent BTree with the given number of entries per node.
-     *
-     * @param recman Record manager used for persistence.
-     * @param comparator Comparator used to order index entries
-     * @param keySerializer Serializer used to serialize index keys (optional)
-     * @param valueSerializer Serializer used to serialize index values (optional)
-     * @param pageSize Number of entries per page (must be even).
-     */
-    public BTree( Comparator<K> comparator, Serializer keySerializer,
-        Serializer valueSerializer, int pageSize ) throws IOException
-    {
-        createInstance( comparator, keySerializer, valueSerializer, pageSize );
+        this( comparator, DEFAULT_PAGE_SIZE );
     }
     
     
     /**
-     * The real BTree constructor.
+     * 
      */
-    private void createInstance( Comparator<K> comparator, Serializer keySerializer,
-        Serializer valueSerializer, int pageSize) throws IOException
+    public BTree( Comparator<K> comparator, int pageSize ) throws IOException
     {
         if ( comparator == null )
         {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_518 ) );
-        }
-
-        if ( !( comparator instanceof Serializable ) )
-        {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_519 ) );
-        }
-
-        // make sure there's an even number of entries per Page
-        if ( ( pageSize & 1 ) != 0 )
-        {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_522 ) );
+            throw new IllegalArgumentException( "Comparator should not be null" );
         }
 
         this.comparator = comparator;
-        this.keySerializer = keySerializer;
-        this.valueSerializer = valueSerializer;
-        this.pageSize = pageSize;
+        setPageSize( pageSize );
         
         // Now create the MetaRoot and store it into the map with a first revision
         //roots = new HashMap<Long, BTree<K,V>.MetaRoot>();
@@ -214,7 +101,7 @@ public class BTree<K, V>
 
         if ( pageSize <= 0 )
         {
-            this.pageSize = DEFAULT_SIZE;
+            this.pageSize = DEFAULT_PAGE_SIZE;
         }
     }
 
@@ -235,12 +122,12 @@ public class BTree<K, V>
     {
         if ( key == null )
         {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_523 ) );
+            throw new IllegalArgumentException( "Key must not be null" );
         }
         
         if ( value == null )
         {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_524 ) );
+            throw new IllegalArgumentException( "Value must not be null" );
         }
         
         //acquireWriteLock();
@@ -292,6 +179,8 @@ public class BTree<K, V>
             //releaseWriteLock()
         }
     }
+    
+    
     /**
      * Find the value associated with the given key.
      *
@@ -302,7 +191,7 @@ public class BTree<K, V>
     {
         if ( key == null )
         {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_523 ) );
+            throw new IllegalArgumentException( "Key must not be null" );
         }
 
         if ( rootPage == null )
@@ -323,12 +212,6 @@ public class BTree<K, V>
     }
 
 
-    public void setValueSerializer( Serializer valueSerializer )
-    {
-        this.valueSerializer = valueSerializer;
-    }
-
-    
     /**
      * @return the comparator
      */
@@ -369,28 +252,6 @@ public class BTree<K, V>
         {
             sb.append( comparator.getClass().getSimpleName() );
         }
-
-        sb.append( ", keySerializer:" );
-        
-        if ( keySerializer == null )
-        {
-            sb.append( "null" );
-        }
-        else
-        {
-            sb.append( keySerializer.getClass().getSimpleName() );
-        }
-
-        sb.append( ", valueSerializer:" );
-
-        if ( valueSerializer == null )
-        {
-            sb.append( "null" );
-        }
-        else
-        {
-            sb.append( valueSerializer.getClass().getSimpleName() );
-        }
         
         sb.append( ") : " );
         sb.append( rootPage );

Modified: directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Find.java
URL: http://svn.apache.org/viewvc/directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Find.java?rev=1233385&r1=1233384&r2=1233385&view=diff
==============================================================================
--- directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Find.java (original)
+++ directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Find.java Thu Jan 19 14:14:10 2012
@@ -1,5 +1,27 @@
+/*
+ *  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.btree;
 
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
 public class Find
 {
     private static int nbCompare = 0;

Modified: directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Page.java
URL: http://svn.apache.org/viewvc/directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Page.java?rev=1233385&r1=1233384&r2=1233385&view=diff
==============================================================================
--- directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Page.java (original)
+++ directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/Page.java Thu Jan 19 14:14:10 2012
@@ -1,68 +1,27 @@
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- *    statements and notices.  Redistributions must also contain a
- *    copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- *    above copyright notice, this list of conditions and the
- *    following disclaimer in the documentation and/or other
- *    materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- *    products derived from this Software without prior written
- *    permission of Cees de Groot.  For written permission,
- *    please contact cg@cdegroot.com.
+/*
+ *  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
  *
- * 4. Products derived from this Software may not be called "JDBM"
- *    nor may "JDBM" appear in their names without prior written
- *    permission of Cees de Groot.
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
- * 5. Due credit should be given to the JDBM Project
- *    (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2001 by their associated contributors.
+ *  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.btree;
 
 
 /**
- * Page of a Btree.
- * <p>
- * The page contains a number of key-value pairs. Keys are ordered to allow
- * dichotomic search.
- * <p>
- * If the page is a leaf page, the keys and values are user-defined and
- * represent entries inserted by the user.
- * <p>
- * If the page is non-leaf, each key represents the greatest key in the
- * underlying BPages and the values are recids pointing to the children BPages.
- * The only exception is the rightmost BPage, which is considered to have an
- * "infinite" key value, meaning that any insert will be to the left of this
- * pseudo-key
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class Page<K, V> implements Cloneable
 {

Modified: directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/PageInsert.java
URL: http://svn.apache.org/viewvc/directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/PageInsert.java?rev=1233385&r1=1233384&r2=1233385&view=diff
==============================================================================
--- directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/PageInsert.java (original)
+++ directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/PageInsert.java Thu Jan 19 14:14:10 2012
@@ -1,7 +1,29 @@
+/*
+ *  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.btree;
 
 import java.util.Random;
 
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
 public class PageInsert
 {
     private static int nbCompare = 0;

Modified: directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/helper/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/helper/LongComparator.java?rev=1233385&r1=1233384&r2=1233385&view=diff
==============================================================================
--- directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/helper/LongComparator.java (original)
+++ directory/sandbox/elecharny/shared-mvbt/src/main/java/org/apache/directory/btree/helper/LongComparator.java Thu Jan 19 14:14:10 2012
@@ -1,99 +1,58 @@
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- *    statements and notices.  Redistributions must also contain a
- *    copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- *    above copyright notice, this list of conditions and the
- *    following disclaimer in the documentation and/or other
- *    materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- *    products derived from this Software without prior written
- *    permission of Cees de Groot.  For written permission,
- *    please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- *    nor may "JDBM" appear in their names without prior written
- *    permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- *    (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2001 by their associated contributors.
- *
+/*
+ *  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.btree.helper;
 
-import java.io.Serializable;
-import java.util.Comparator;
 
-import org.apache.directory.server.i18n.I18n;
+import java.util.Comparator;
 
 /**
- * Comparator for java.lang.Long objects.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
+ * Compares Longs
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class LongComparator
-    implements Comparator<Long>, Serializable
+public class LongComparator implements Comparator<Long>
 {
-
-    /**
-     * Version id for serialization.
-     */
-    final static long serialVersionUID = 1L;
-
-
     /**
-     * Compare two objects.
-     *
-     * @param obj1 First object
-     * @param obj2 Second object
-     * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2,
-     *         and a negative integer if obj1 < obj2
+     * Compare two longs.
+     * 
+     * @param long1 First long
+     * @param long2 Second long
+     * @return 1 if long1 > long2, 0 if long1 == long2, -1 if long1 < long2
      */
-     public int compare( Long obj1, Long obj2 )
-     {
-        if ( obj1 == null ) {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_525 ) );
+    public int compare( Long long1, Long long2 )
+    {
+        if ( long1 == long2 )
+        {
+            return 0;
         }
 
-        if ( obj2 == null ) {
-            throw new IllegalArgumentException( I18n.err( I18n.ERR_526 ) );
+        if ( long1 == null )
+        {
+            throw new IllegalArgumentException( "The first object to compare must not be null" );
         }
 
-        long l1 = obj1.longValue();
-        long l2 = obj2.longValue();
-
-        if ( l1 > l2 ) {
-            return 1;
-        } else if ( l1 == l2 ) {
-            return 0;
-        } else {
-            return -1;
+        if ( long2 == null )
+        {
+            throw new IllegalArgumentException( "The second object to compare must not be null" );
         }
-     }
 
+        return long1.compareTo( long2 );
+    }
 }

Modified: directory/sandbox/elecharny/shared-mvbt/src/test/java/org/apache/directory/btree/PageTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/elecharny/shared-mvbt/src/test/java/org/apache/directory/btree/PageTest.java?rev=1233385&r1=1233384&r2=1233385&view=diff
==============================================================================
--- directory/sandbox/elecharny/shared-mvbt/src/test/java/org/apache/directory/btree/PageTest.java (original)
+++ directory/sandbox/elecharny/shared-mvbt/src/test/java/org/apache/directory/btree/PageTest.java Thu Jan 19 14:14:10 2012
@@ -1,3 +1,22 @@
+/*
+ *  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.btree;
 
 import java.io.IOException;
@@ -9,6 +28,10 @@ import org.apache.directory.btree.helper
 import org.junit.Test;
 import static org.junit.Assert.assertTrue;
 
+/**
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
 public class PageTest
 {
     private boolean checkTree( Set<Long> expected, BTree<Long, String> btree ) throws IOException
@@ -31,8 +54,7 @@ public class PageTest
 
     private BTree<Long, String> loadTree( Long[] keys, String[] values ) throws IOException
     {
-        BTree<Long, String> btree = new BTree<Long, String>( new LongComparator() );
-        btree.setPageSize( 4 );
+        BTree<Long, String> btree = new BTree<Long, String>( new LongComparator(), 4 );
 
         for ( int i = 0; i < keys.length; i++ )
         {