directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1510115 [7/13] - in /directory/mavibot/trunk: ./ mavibot/ mavibot/src/main/java/org/apache/directory/ mavibot/src/main/java/org/apache/directory/mavibot/ mavibot/src/main/java/org/apache/directory/mavibot/btree/ mavibot/src/main/java/org/a...
Date Sun, 04 Aug 2013 09:22:58 GMT
Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ReferenceHolder.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ReferenceHolder.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ReferenceHolder.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ReferenceHolder.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,143 @@
+/*
+ *  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;
+
+
+import java.io.IOException;
+import java.lang.ref.SoftReference;
+
+import org.apache.directory.mavibot.btree.exception.EndOfFileExceededException;
+
+
+/**
+ * A Value holder. As we may not store all the values in memory (except for an in-memory
+ * BTree), we will use a SoftReference to keep a reference to a Value, and if it's null,
+ * then we will load the Value from the underlying physical support, using the offset. 
+ * 
+ * @param <E> The type for the stored element (either a value or a page)
+ * @param <K> The type of the BTree key
+ * @param <V> The type of the BTree value
+ *
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ReferenceHolder<E, K, V> implements ElementHolder<E, K, V>
+{
+    /** The BTree */
+    private BTree<K, V> btree;
+
+    /** The offset of the first {@link PageIO} storing the page on disk */
+    private long offset;
+
+    /** The offset of the last {@link PageIO} storing the page on disk */
+    private long lastOffset;
+
+    /** The reference to the element instance, or null if it's not present */
+    private SoftReference<E> reference;
+
+
+    /**
+     * Create a new holder storing an offset and a SoftReference containing the element.
+     * 
+     * @param offset The offset in disk for this value
+     * @param element The element to store into a SoftReference
+     */
+    public ReferenceHolder( BTree<K, V> btree, E element, long offset, long lastOffset )
+    {
+        this.btree = btree;
+        this.offset = offset;
+        this.lastOffset = lastOffset;
+        this.reference = new SoftReference<E>( element );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
+     */
+    @Override
+    public E getValue( BTree<K, V> btree ) throws EndOfFileExceededException, IOException
+    {
+        E element = reference.get();
+
+        if ( element == null )
+        {
+            // We have to fetch the element from disk, using the offset now
+            element = fetchElement( btree );
+            reference = new SoftReference( element );
+        }
+
+        return element;
+    }
+
+
+    /**
+     * Retrieve the value from the disk, using the BTree and offset
+     * @return The deserialized element (
+     * @throws IOException 
+     * @throws EndOfFileExceededException 
+     */
+    private E fetchElement( BTree<K, V> btree ) throws EndOfFileExceededException, IOException
+    {
+        E element = ( E ) btree.getRecordManager().deserialize( btree, offset );
+
+        return element;
+    }
+
+
+    /**
+     * @return The offset of the first {@link PageIO} storing the data on disk
+     */
+    /* No qualifier */long getOffset()
+    {
+        return offset;
+    }
+
+
+    /**
+     * @return The offset of the last {@link PageIO} storing the data on disk
+     */
+    /* No qualifier */long getLastOffset()
+    {
+        return lastOffset;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        E element = reference.get();
+
+        if ( element != null )
+        {
+            sb.append( btree.getName() ).append( "[" ).append( offset ).append( "]:" ).append( element );
+        }
+        else
+        {
+            sb.append( btree.getName() ).append( "[" ).append( offset ).append( "]" );
+        }
+
+        return sb.toString();
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RemoveResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RemoveResult.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RemoveResult.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RemoveResult.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,75 @@
+/*
+ *  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;
+
+
+import java.util.List;
+
+
+/**
+ * The result of a delete operation, when the child has not been merged. It contains the
+ * reference to the modified page, and the removed element.
+ * 
+ * @param <K> The type for the Key
+ * @param <V> The type for the stored value
+
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+/* No qualifier */class RemoveResult<K, V> extends AbstractDeleteResult<K, V>
+{
+    /**
+     * The default constructor for RemoveResult.
+     * 
+     * @param modifiedPage The modified page
+     * @param removedElement The removed element (can be null if the key wasn't present in the tree)
+     */
+    /* No qualifier */RemoveResult( Page<K, V> modifiedPage, Tuple<K, V> removedElement )
+    {
+        super( modifiedPage, removedElement );
+    }
+
+
+    /**
+     * A constructor for RemoveResult which takes a list of copied pages.
+     * 
+     * @param copiedPages the list of copied pages
+     * @param modifiedPage The modified page
+     * @param removedElement The removed element (can be null if the key wasn't present in the tree)
+     */
+    /* No qualifier */RemoveResult( List<Page<K, V>> copiedPages, Page<K, V> modifiedPage, Tuple<K, V> removedElement )
+    {
+        super( copiedPages, modifiedPage, removedElement );
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "RemoveResult :" );
+        sb.append( "\n    removed element = " ).append( getRemovedElement() );
+        sb.append( "\n    modifiedPage = " ).append( getModifiedPage() );
+
+        return sb.toString();
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Result.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Result.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Result.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Result.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,47 @@
+/*
+ *  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;
+
+
+import java.util.List;
+
+
+/**
+ * The result of an insert or delete operation.
+ * 
+ * @param <K> The type for the Key
+ * @param <V> The type for the stored value
+
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+/* No qualifier */interface Result<K, V>
+{
+    /**
+     * @return the copiedPage
+     */
+    /* No qualifier */List<Page<K, V>> getCopiedPages();
+
+
+    /**
+     * Add a new copied page
+     * @param copiedPage the added page
+     */
+    /* No qualifier */void addCopiedPage( Page<K, V> copiedPage );
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionName.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionName.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionName.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionName.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,136 @@
+/*
+ *  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;
+
+
+/**
+ * A data structure that stores a revision associated to a BTree name. We use
+ * it to allow the access to old revisions.
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class RevisionName
+{
+    /** The revision number on the BTree */
+    private long revision;
+
+    /** The BTree name */
+    private String name;
+
+
+    /**
+     * A constructor for the RevisionName class
+     * @param revision The revision
+     * @param name The BTree name
+     */
+    public RevisionName( long revision, String name )
+    {
+        this.revision = revision;
+        this.name = name;
+    }
+
+
+    /**
+     * @return the revision
+     */
+    public long getRevision()
+    {
+        return revision;
+    }
+
+
+    /**
+     * @param revision the revision to set
+     */
+    public void setRevision( long revision )
+    {
+        this.revision = revision;
+    }
+
+
+    /**
+     * @return the btree name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    /**
+     * @param name the btree name to set
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object that )
+    {
+        if ( this == that )
+        {
+            return true;
+        }
+
+        if ( !( that instanceof RevisionName ) )
+        {
+            return false;
+        }
+
+        RevisionName revisionName = ( RevisionName ) that;
+
+        if ( revision != revisionName.revision )
+        {
+            return false;
+        }
+
+        if ( name == null )
+        {
+            return revisionName.name == null;
+        }
+
+        return ( name.equals( revisionName.name ) );
+
+    }
+
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( name == null ) ? 0 : name.hashCode() );
+        result = prime * result + ( int ) ( revision ^ ( revision >>> 32 ) );
+        return result;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "[" + name + ":" + revision + "]";
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,56 @@
+/*
+ *  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;
+
+
+import java.util.Comparator;
+
+
+/**
+ * A comparator for the RevisionName class
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class RevisionNameComparator implements Comparator<RevisionName>
+{
+    /**
+     * {@inheritDoc}
+     */
+    public int compare( RevisionName rn1, RevisionName rn2 )
+    {
+        if ( rn1 == rn2 )
+        {
+            return 0;
+        }
+
+        // First compare the revisions
+        if ( rn1.getRevision() < rn2.getRevision() )
+        {
+            return -1;
+        }
+        else if ( rn1.getRevision() > rn2.getRevision() )
+        {
+            return 1;
+        }
+
+        // The revision are equal : check the name
+        return rn1.getName().compareTo( rn2.getName() );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,208 @@
+/*
+ *  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;
+
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.directory.mavibot.btree.serializer.AbstractElementSerializer;
+import org.apache.directory.mavibot.btree.serializer.BufferHandler;
+import org.apache.directory.mavibot.btree.serializer.ByteArraySerializer;
+import org.apache.directory.mavibot.btree.serializer.IntSerializer;
+import org.apache.directory.mavibot.btree.serializer.LongSerializer;
+import org.apache.directory.mavibot.btree.serializer.StringSerializer;
+import org.apache.directory.mavibot.btree.util.Strings;
+
+
+/**
+ * A serializer for the RevisionName object. The RevisionName will be serialized 
+ * as a long (the revision), followed by the String.
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class RevisionNameSerializer extends AbstractElementSerializer<RevisionName>
+{
+    /**
+     * Create a new instance of a RevisionNameSerializer
+     */
+    public RevisionNameSerializer()
+    {
+        super( new RevisionNameComparator() );
+    }
+
+
+    /**
+     * A static method used to deserialize a RevisionName from a byte array.
+     * 
+     * @param in The byte array containing the RevisionName
+     * @return A RevisionName instance
+     */
+    public static RevisionName deserialize( byte[] in )
+    {
+        return deserialize( in, 0 );
+    }
+
+
+    /**
+     * A static method used to deserialize a RevisionName from a byte array.
+     * 
+     * @param in The byte array containing the RevisionName
+     * @param start the position in the byte[] we will deserialize the RevisionName from
+     * @return A RevisionName instance
+     */
+    public static RevisionName deserialize( byte[] in, int start )
+    {
+        // The buffer must be 8 bytes plus 4 bytes long (the revision is a long, and the name is a String
+        if ( ( in == null ) || ( in.length < 12 + start ) )
+        {
+            throw new RuntimeException( "Cannot extract a RevisionName from a buffer with not enough bytes" );
+        }
+
+        long revision = LongSerializer.deserialize( in, start );
+        String name = StringSerializer.deserialize( in, 8 + start );
+
+        RevisionName revisionName = new RevisionName( revision, name );
+
+        return revisionName;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public byte[] serialize( RevisionName revisionName )
+    {
+        if ( revisionName == null )
+        {
+            throw new RuntimeException( "The revisionName instance should not be null " );
+        }
+
+        byte[] result = null;
+
+        if ( revisionName.getName() != null )
+        {
+            byte[] stringBytes = Strings.getBytesUtf8( revisionName.getName() );
+            int stringLen = stringBytes.length;
+            result = new byte[8 + 4 + stringBytes.length];
+            LongSerializer.serialize( result, 0, revisionName.getRevision() );
+
+            if ( stringLen > 0 )
+            {
+                ByteArraySerializer.serialize( result, 8, stringBytes );
+            }
+        }
+        else
+        {
+            result = new byte[8 + 4];
+            LongSerializer.serialize( result, 0, revisionName.getRevision() );
+            StringSerializer.serialize( result, 8, null );
+        }
+
+        return result;
+    }
+
+
+    /**
+     * Serialize a RevisionName
+     * 
+     * @param buffer the Buffer that will contain the serialized value
+     * @param start the position in the buffer we will store the serialized RevisionName
+     * @param value the value to serialize
+     * @return The byte[] containing the serialized RevisionName
+     */
+    public static byte[] serialize( byte[] buffer, int start, RevisionName revisionName )
+    {
+        if ( revisionName.getName() != null )
+        {
+            byte[] stringBytes = Strings.getBytesUtf8( revisionName.getName() );
+            int stringLen = stringBytes.length;
+            LongSerializer.serialize( buffer, start, revisionName.getRevision() );
+            IntSerializer.serialize( buffer, 8 + start, stringLen );
+            ByteArraySerializer.serialize( buffer, 12 + start, stringBytes );
+        }
+        else
+        {
+            LongSerializer.serialize( buffer, start, revisionName.getRevision() );
+            StringSerializer.serialize( buffer, 8, null );
+        }
+
+        return buffer;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public RevisionName deserialize( BufferHandler bufferHandler ) throws IOException
+    {
+        byte[] revisionBytes = bufferHandler.read( 8 );
+        long revision = LongSerializer.deserialize( revisionBytes );
+
+        byte[] lengthBytes = bufferHandler.read( 4 );
+
+        int len = IntSerializer.deserialize( lengthBytes );
+
+        switch ( len )
+        {
+            case 0:
+                return new RevisionName( revision, "" );
+
+            case -1:
+                return new RevisionName( revision, null );
+
+            default:
+                byte[] nameBytes = bufferHandler.read( len );
+
+                return new RevisionName( revision, Strings.utf8ToString( nameBytes ) );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public RevisionName deserialize( ByteBuffer buffer ) throws IOException
+    {
+        // The revision
+        long revision = buffer.getLong();
+
+        // The name's length
+        int len = buffer.getInt();
+
+        switch ( len )
+        {
+            case 0:
+                return new RevisionName( revision, "" );
+
+            case -1:
+                return new RevisionName( revision, null );
+
+            default:
+                byte[] nameBytes = new byte[len];
+                buffer.get( nameBytes );
+
+                return new RevisionName( revision, Strings.utf8ToString( nameBytes ) );
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/SplitResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/SplitResult.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/SplitResult.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/SplitResult.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,119 @@
+/*
+ *  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;
+
+
+import java.util.List;
+
+
+/**
+ * The result of an insert operation, when the page has been split. It contains
+ * the new pivotal value, plus the reference on the two new pages.
+ * 
+ * @param <K> The type for the Key
+ * @param <V> The type for the stored value
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+/* No qualifier */class SplitResult<K, V> extends AbstractResult<K, V> implements InsertResult<K, V>
+{
+    /** The left child */
+    protected Page<K, V> leftPage;
+
+    /** The right child */
+    protected Page<K, V> rightPage;
+
+    /** The key pivot */
+    protected K pivot;
+
+
+    /**
+     * The default constructor for SplitResult.
+     * @param pivot The new key to insert into the parent
+     * @param leftPage The new left page
+     * @param rightPage The new right page
+     */
+    /* No qualifier */SplitResult( K pivot, Page<K, V> leftPage, Page<K, V> rightPage )
+    {
+        super();
+        this.pivot = pivot;
+        this.leftPage = leftPage;
+        this.rightPage = rightPage;
+    }
+
+
+    /**
+     * A constructor for SplitResult with copied pages.
+     * 
+     * @param copiedPages the list of copied pages
+     * @param pivot The new key to insert into the parent
+     * @param leftPage The new left page
+     * @param rightPage The new right page
+     */
+    /* No qualifier */SplitResult( List<Page<K, V>> copiedPages, K pivot, Page<K, V> leftPage, Page<K, V> rightPage )
+    {
+        super( copiedPages );
+        this.pivot = pivot;
+        this.leftPage = leftPage;
+        this.rightPage = rightPage;
+    }
+
+
+    /**
+     * @return the leftPage
+     */
+    /* No qualifier */Page<K, V> getLeftPage()
+    {
+        return leftPage;
+    }
+
+
+    /**
+     * @return the rightPage
+     */
+    /* No qualifier */Page<K, V> getRightPage()
+    {
+        return rightPage;
+    }
+
+
+    /**
+     * @return the pivot
+     */
+    /* No qualifier */K getPivot()
+    {
+        return pivot;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "SplitResult, new pivot = " ).append( pivot );
+        sb.append( "\n    leftPage = " ).append( leftPage );
+        sb.append( "\n    rightPage = " ).append( rightPage );
+        sb.append( super.toString() );
+
+        return sb.toString();
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,128 @@
+/*
+ *  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;
+
+
+import java.util.Date;
+
+
+/**
+ * The Transaction is used to protect the BTree against concurrent modifcation,
+ * and insure that a read is always done against one single revision. It's also
+ * used to gather many modifications under one single revision, if needed.
+ * <p/>
+ * A Transaction should be closed when the user is done with it, otherwise the
+ * pages associated with the given revision, and all the referenced pages, will
+ * remain on the storage.
+ * <p/>
+ * A Transaction can be hold for quite a long time, for instance while doing
+ * a browse against a big BTree. At some point, transactions which are pending
+ * for too long will be closed by the transaction manager.
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ *
+ * @param <K> The type for the Key
+ * @param <V> The type for the stored value
+ */
+public class Transaction<K, V>
+{
+    /** The associated revision */
+    private long revision;
+
+    /** The date of creation */
+    private long creationDate;
+
+    /** The revision on which we are having a transaction */
+    private volatile Page<K, V> root;
+
+    /** A flag used to tell if a transaction is closed ot not */
+    private volatile boolean closed;
+
+
+    /**
+     * Creates a new transaction instance
+     * 
+     * @param root The associated root
+     * @param revision The revision this transaction is using
+     * @param creationDate The creation date for this transaction
+     */
+    public Transaction( Page<K, V> root, long revision, long creationDate )
+    {
+        this.revision = revision;
+        this.creationDate = creationDate;
+        this.root = root;
+        closed = false;
+    }
+
+
+    /**
+     * @return the associated revision
+     */
+    public long getRevision()
+    {
+        return revision;
+    }
+
+
+    /**
+     * @return the associated root
+     */
+    public Page<K, V> getRoot()
+    {
+        return root;
+    }
+
+
+    /**
+     * @return the creationDate
+     */
+    public long getCreationDate()
+    {
+        return creationDate;
+    }
+
+
+    /**
+     * Close the transaction, releasing the revision it was using.
+     */
+    public void close()
+    {
+        root = null;
+        closed = true;
+    }
+
+
+    /**
+     * @return true if this transaction has been closed
+     */
+    public boolean isClosed()
+    {
+        return closed;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "Transaction[" + revision + ":" + new Date( creationDate ) + ", closed :" + closed + "]";
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Tuple.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Tuple.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Tuple.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Tuple.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,104 @@
+/*
+ *  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;
+
+
+/**
+ * The Tuple class is used when we browse a btree, it will contain the results
+ * fetched from the btree.
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ *
+ * @param <K> The type for the Key
+ * @param <V> The type for the stored value
+ */
+public class Tuple<K, V>
+{
+    /** The key */
+    private K key;
+
+    /** The value */
+    private V value;
+
+
+    /**
+     * Creates a Tuple with no content
+     */
+    public Tuple()
+    {
+    }
+
+
+    /**
+     * Creates a Tuple containing a key and its associated value.
+     * @param key The key
+     * @param value The associated value
+     */
+    public Tuple( K key, V value )
+    {
+        this.key = key;
+        this.value = value;
+    }
+
+
+    /**
+     * @return the key
+     */
+    public K getKey()
+    {
+        return key;
+    }
+
+
+    /**
+     * @param key the key to set
+     */
+    /* No qualifier*/void setKey( K key )
+    {
+        this.key = key;
+    }
+
+
+    /**
+     * @return the value
+     */
+    public V getValue()
+    {
+        return value;
+    }
+
+
+    /**
+     * @param value the value to set
+     */
+    /* No qualifier*/void setValue( V value )
+    {
+        this.value = value;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "<" + key + "," + value + ">";
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,98 @@
+/*
+ *  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.comparator;
+
+
+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:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class BooleanArrayComparator implements Comparator<boolean[]>
+{
+    /**
+     * 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
+     */
+    public int compare( boolean[] booleanArray1, boolean[] booleanArray2 )
+    {
+        if ( booleanArray1 == booleanArray2 )
+        {
+            return 0;
+        }
+
+        if ( booleanArray1 == null )
+        {
+            return -1;
+        }
+
+        if ( booleanArray2 == null )
+        {
+            return 1;
+        }
+
+        if ( booleanArray1.length < booleanArray2.length )
+        {
+            return -1;
+        }
+
+        if ( booleanArray1.length > booleanArray2.length )
+        {
+            return 1;
+        }
+
+        for ( int pos = 0; pos < booleanArray1.length; pos++ )
+        {
+            int comp = compare( booleanArray1[pos], booleanArray2[pos] );
+
+            if ( comp != 0 )
+            {
+                return comp;
+            }
+        }
+
+        return 0;
+    }
+
+
+    private int compare( boolean boolean1, boolean boolean2 )
+    {
+        if ( boolean1 == boolean2 )
+        {
+            return 0;
+        }
+
+        if ( boolean1 )
+        {
+            return 1;
+        }
+        else
+        {
+            return -1;
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,59 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares booleans
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class BooleanComparator implements Comparator<Boolean>
+{
+    /**
+     * Compare two booleans.
+     * 
+     * @param boolean1 First boolean
+     * @param boolean2 Second boolean
+     * @return 1 if boolean1 > boolean2, 0 if boolean1 == boolean2, -1 if boolean1 < boolean2
+     */
+    public int compare( Boolean boolean1, Boolean boolean2 )
+    {
+        if ( boolean1 == boolean2 )
+        {
+            return 0;
+        }
+
+        if ( boolean1 == null )
+        {
+            return -1;
+        }
+
+        if ( boolean2 == null )
+        {
+            return 1;
+        }
+
+        return boolean1.compareTo( boolean2 );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,124 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares byte arrays.
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ByteArrayComparator implements Comparator<byte[]>
+{
+    /**
+     * 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
+     */
+    public int compare( byte[] byteArray1, byte[] byteArray2 )
+    {
+        if ( byteArray1 == byteArray2 )
+        {
+            return 0;
+        }
+
+        if ( byteArray1 == null )
+        {
+            if ( byteArray2 == null )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else
+        {
+            if ( byteArray2 == null )
+            {
+                return 1;
+            }
+            else
+            {
+                if ( byteArray1.length < byteArray2.length )
+                {
+                    int pos = 0;
+
+                    for ( byte b1 : byteArray1 )
+                    {
+                        byte b2 = byteArray2[pos];
+
+                        if ( b1 == b2 )
+                        {
+                            pos++;
+                        }
+                        else if ( b1 < b2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    return -1;
+                }
+                else
+                {
+                    int pos = 0;
+
+                    for ( byte b2 : byteArray2 )
+                    {
+                        byte b1 = byteArray1[pos];
+
+                        if ( b1 == b2 )
+                        {
+                            pos++;
+                        }
+                        else if ( b1 < b2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    if ( pos < byteArray1.length )
+                    {
+                        return 1;
+                    }
+                    else
+                    {
+                        return 0;
+                    }
+                }
+            }
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,70 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares bytes
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ByteComparator implements Comparator<Byte>
+{
+    /**
+     * Compare two bytes.
+     * 
+     * @param byte1 First byte
+     * @param byte2 Second byte
+     * @return 1 if byte1 > byte2, 0 if byte1 == byte2, -1 if byte1 < byte2
+     */
+    public int compare( Byte byte1, Byte byte2 )
+    {
+        if ( byte1 == byte2 )
+        {
+            return 0;
+        }
+
+        if ( byte1 == null )
+        {
+            return -1;
+        }
+
+        if ( byte2 == null )
+        {
+            return 1;
+        }
+
+        if ( byte1 < byte2 )
+        {
+            return -1;
+        }
+        else if ( byte1 > byte2 )
+        {
+            return 1;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,125 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares char arrays
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class CharArrayComparator implements Comparator<char[]>
+{
+    /**
+     * 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
+     */
+    public int compare( char[] charArray1, char[] charArray2 )
+    {
+        if ( charArray1 == charArray2 )
+        {
+            return 0;
+        }
+
+        if ( charArray1 == null )
+        {
+            if ( charArray2 == null )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else
+        {
+            if ( charArray2 == null )
+            {
+                return 1;
+            }
+            else
+            {
+                if ( charArray1.length < charArray2.length )
+                {
+                    int pos = 0;
+
+                    for ( char char1 : charArray1 )
+                    {
+                        char char2 = charArray2[pos];
+
+                        if ( char1 == char2 )
+                        {
+                            pos++;
+                        }
+                        else if ( char1 < char2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    return -1;
+                }
+                else
+                {
+                    int pos = 0;
+
+                    for ( char char2 : charArray2 )
+                    {
+                        char char1 = charArray1[pos];
+
+                        if ( char1 == char2 )
+                        {
+                            pos++;
+                        }
+                        else if ( char1 < char2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    if ( pos < charArray1.length )
+                    {
+                        return 1;
+                    }
+                    else
+                    {
+                        return 0;
+                    }
+                }
+            }
+        }
+
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,81 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares chars
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class CharComparator implements Comparator<Character>
+{
+    /**
+     * Compare two chars.
+     * 
+     * @param char1 First char
+     * @param char2 Second char
+     * @return 1 if char1 > char2, 0 if char1 == char2, -1 if char1 < char2
+     */
+    public int compare( Character char1, Character char2 )
+    {
+        if ( char1 == char2 )
+        {
+            return 0;
+        }
+
+        if ( char1 == null )
+        {
+            if ( char2 == null )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else
+        {
+            if ( char2 == null )
+            {
+                return 1;
+            }
+            else
+            {
+                if ( char1 < char2 )
+                {
+                    return -1;
+                }
+                else if ( char1 > char2 )
+                {
+                    return 1;
+                }
+                else
+                {
+                    return 0;
+                }
+            }
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,124 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares int arrays
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class IntArrayComparator implements Comparator<int[]>
+{
+    /**
+     * 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
+     */
+    public int compare( int[] intArray1, int[] intArray2 )
+    {
+        if ( intArray1 == intArray2 )
+        {
+            return 0;
+        }
+
+        if ( intArray1 == null )
+        {
+            if ( intArray2 == null )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else
+        {
+            if ( intArray2 == null )
+            {
+                return 1;
+            }
+            else
+            {
+                if ( intArray1.length < intArray2.length )
+                {
+                    int pos = 0;
+
+                    for ( int int1 : intArray1 )
+                    {
+                        int int2 = intArray2[pos];
+
+                        if ( int1 == int2 )
+                        {
+                            pos++;
+                        }
+                        else if ( int1 < int2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    return -1;
+                }
+                else
+                {
+                    int pos = 0;
+
+                    for ( int int2 : intArray2 )
+                    {
+                        int int1 = intArray1[pos];
+
+                        if ( int1 == int2 )
+                        {
+                            pos++;
+                        }
+                        else if ( int1 < int2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    if ( pos < intArray1.length )
+                    {
+                        return 1;
+                    }
+                    else
+                    {
+                        return 0;
+                    }
+                }
+            }
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,70 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares integers
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class IntComparator implements Comparator<Integer>
+{
+    /**
+     * Compare two integers.
+     * 
+     * @param integer1 First integer
+     * @param integer2 Second integer
+     * @return 1 if integer1 > integer2, 0 if integer1 == integer2, -1 if integer1 < integer2
+     */
+    public int compare( Integer integer1, Integer integer2 )
+    {
+        if ( integer1 == integer2 )
+        {
+            return 0;
+        }
+
+        if ( integer1 == null )
+        {
+            if ( integer2 == null )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else
+        {
+            if ( integer2 == null )
+            {
+                return 1;
+            }
+            else
+            {
+                return integer1.compareTo( integer2 );
+            }
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,124 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares long arrays
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class LongArrayComparator implements Comparator<long[]>
+{
+    /**
+     * 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
+     */
+    public int compare( long[] longArray1, long[] longArray2 )
+    {
+        if ( longArray1 == longArray2 )
+        {
+            return 0;
+        }
+
+        if ( longArray1 == null )
+        {
+            if ( longArray2 == null )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else
+        {
+            if ( longArray2 == null )
+            {
+                return 1;
+            }
+            else
+            {
+                if ( longArray1.length < longArray2.length )
+                {
+                    int pos = 0;
+
+                    for ( long long1 : longArray1 )
+                    {
+                        long long2 = longArray2[pos];
+
+                        if ( long1 == long2 )
+                        {
+                            pos++;
+                        }
+                        else if ( long1 < long2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    return -1;
+                }
+                else
+                {
+                    int pos = 0;
+
+                    for ( long long2 : longArray2 )
+                    {
+                        long long1 = longArray1[pos];
+
+                        if ( long1 == long2 )
+                        {
+                            pos++;
+                        }
+                        else if ( long1 < long2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    if ( pos < longArray1.length )
+                    {
+                        return 1;
+                    }
+                    else
+                    {
+                        return 0;
+                    }
+                }
+            }
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,81 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares Longs
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class LongComparator implements Comparator<Long>
+{
+    /**
+     * 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 long1, Long long2 )
+    {
+        if ( long1 == long2 )
+        {
+            return 0;
+        }
+
+        if ( long1 == null )
+        {
+            if ( long2 == null )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else
+        {
+            if ( long2 == null )
+            {
+                return 1;
+            }
+            else
+            {
+                if ( long1 < long2 )
+                {
+                    return -1;
+                }
+                else if ( long1 > long2 )
+                {
+                    return 1;
+                }
+                else
+                {
+                    return 0;
+                }
+            }
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,124 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares short arrays
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ShortArrayComparator implements Comparator<short[]>
+{
+    /**
+     * 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
+     */
+    public int compare( short[] shortArray1, short[] shortArray2 )
+    {
+        if ( shortArray1 == shortArray2 )
+        {
+            return 0;
+        }
+
+        if ( shortArray1 == null )
+        {
+            if ( shortArray2 == null )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else
+        {
+            if ( shortArray2 == null )
+            {
+                return 1;
+            }
+            else
+            {
+                if ( shortArray1.length < shortArray2.length )
+                {
+                    int pos = 0;
+
+                    for ( short short1 : shortArray1 )
+                    {
+                        short short2 = shortArray2[pos];
+
+                        if ( short1 == short2 )
+                        {
+                            pos++;
+                        }
+                        else if ( short1 < short2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    return -1;
+                }
+                else
+                {
+                    int pos = 0;
+
+                    for ( short short2 : shortArray2 )
+                    {
+                        short short1 = shortArray1[pos];
+
+                        if ( short1 == short2 )
+                        {
+                            pos++;
+                        }
+                        else if ( short1 < short2 )
+                        {
+                            return -1;
+                        }
+                        else
+                        {
+                            return 1;
+                        }
+                    }
+
+                    if ( pos < shortArray1.length )
+                    {
+                        return 1;
+                    }
+                    else
+                    {
+                        return 0;
+                    }
+                }
+            }
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,81 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares shorts
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class ShortComparator implements Comparator<Short>
+{
+    /**
+     * Compare two shorts.
+     * 
+     * @param short1 First short
+     * @param short2 Second short
+     * @return 1 if short1 > short2, 0 if short1 == short2, -1 if short1 < short2
+     */
+    public int compare( Short short1, Short short2 )
+    {
+        if ( short1 == short2 )
+        {
+            return 0;
+        }
+
+        if ( short1 == null )
+        {
+            if ( short2 == null )
+            {
+                return 0;
+            }
+            else
+            {
+                return -1;
+            }
+        }
+        else
+        {
+            if ( short2 == null )
+            {
+                return 1;
+            }
+            else
+            {
+                if ( short1 < short2 )
+                {
+                    return -1;
+                }
+                else if ( short1 > short2 )
+                {
+                    return 1;
+                }
+                else
+                {
+                    return 0;
+                }
+            }
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,71 @@
+/*
+ *  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.comparator;
+
+
+import java.util.Comparator;
+
+
+/**
+ * Compares Strings
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class StringComparator implements Comparator<String>
+{
+    /**
+     * Compare two Strings.
+     * 
+     * @param string1 First String
+     * @param string2 Second String
+     * @return 1 if string1 > String2, 0 if string1 == String2, -1 if string1 < String2
+     */
+    public int compare( String string1, String string2 )
+    {
+        if ( string1 == string2 )
+        {
+            return 0;
+        }
+
+        if ( string1 == null )
+        {
+            return -1;
+        }
+        else if ( string2 == null )
+        {
+            return 1;
+        }
+
+        int result = string1.compareTo( string2 );
+
+        if ( result < 0 )
+        {
+            return -1;
+        }
+        else if ( result > 0 )
+        {
+            return 1;
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/BTreeAlreadyManagedException.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/BTreeAlreadyManagedException.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/BTreeAlreadyManagedException.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/BTreeAlreadyManagedException.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,73 @@
+/*
+ *  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 we try to manage a BTree which name is
+ * already managed by the RecordManager
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class BTreeAlreadyManagedException extends Exception
+{
+    /** The serial version UUID */
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * Creates a new instance of BtreeAlreadyManagedException.
+     */
+    public BTreeAlreadyManagedException()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of BtreeAlreadyManagedException.
+     *
+     * @param explanation The message associated with the exception
+     */
+    public BTreeAlreadyManagedException( String explanation )
+    {
+        super( explanation );
+    }
+
+
+    /**
+     * Creates a new instance of BtreeAlreadyManagedException.
+     */
+    public BTreeAlreadyManagedException( Throwable cause )
+    {
+        super( cause );
+    }
+
+
+    /**
+     * Creates a new instance of KeyNotFoundException.
+     *
+     * @param explanation The message associated with the exception
+     * @param cause The root cause for this exception
+     */
+    public BTreeAlreadyManagedException( String explanation, Throwable cause )
+    {
+        super( explanation, cause );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/EndOfFileExceededException.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/EndOfFileExceededException.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/EndOfFileExceededException.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/EndOfFileExceededException.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,75 @@
+/*
+ *  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;
+
+
+import java.io.IOException;
+
+
+/**
+ * An exception thrown when we try to access a page beyond the file's size.
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class EndOfFileExceededException extends IOException
+{
+    /** The serial version UUID */
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * Creates a new instance of EndOfFileExceededException.
+     */
+    public EndOfFileExceededException()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of EndOfFileExceededException.
+     *
+     * @param explanation The message associated with the exception
+     */
+    public EndOfFileExceededException( String explanation )
+    {
+        super( explanation );
+    }
+
+
+    /**
+     * Creates a new instance of EndOfFileExceededException.
+     */
+    public EndOfFileExceededException( Throwable cause )
+    {
+        super( cause );
+    }
+
+
+    /**
+     * Creates a new instance of EndOfFileExceededException.
+     *
+     * @param explanation The message associated with the exception
+     * @param cause The root cause for this exception
+     */
+    public EndOfFileExceededException( String explanation, Throwable cause )
+    {
+        super( explanation, cause );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/KeyNotFoundException.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/KeyNotFoundException.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/KeyNotFoundException.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/KeyNotFoundException.java Sun Aug  4 09:22:56 2013
@@ -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 we can't find a key in the BTree.
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class KeyNotFoundException extends Exception
+{
+    /** The serial version UUID */
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * Creates a new instance of KeyNotFoundException.
+     */
+    public KeyNotFoundException()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of KeyNotFoundException.
+     *
+     * @param explanation The message associated with the exception
+     */
+    public KeyNotFoundException( String explanation )
+    {
+        super( explanation );
+    }
+
+
+    /**
+     * Creates a new instance of KeyNotFoundException.
+     */
+    public KeyNotFoundException( Throwable cause )
+    {
+        super( cause );
+    }
+
+
+    /**
+     * Creates a new instance of KeyNotFoundException.
+     *
+     * @param explanation The message associated with the exception
+     * @param cause The root cause for this exception
+     */
+    public KeyNotFoundException( String explanation, Throwable cause )
+    {
+        super( explanation, cause );
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/PageSizeAlreadySetException.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/PageSizeAlreadySetException.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/PageSizeAlreadySetException.java (added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/PageSizeAlreadySetException.java Sun Aug  4 09:22:56 2013
@@ -0,0 +1,74 @@
+/*
+ *  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 we try to change the RecordManager Page Size
+ * when it's already set.
+ * already managed by the RecordManager
+ * 
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class PageSizeAlreadySetException extends Exception
+{
+    /** The serial version UUID */
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * Creates a new instance of PageSizeAlreadySetException.
+     */
+    public PageSizeAlreadySetException()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of PageSizeAlreadySetException.
+     *
+     * @param explanation The message associated with the exception
+     */
+    public PageSizeAlreadySetException( String explanation )
+    {
+        super( explanation );
+    }
+
+
+    /**
+     * Creates a new instance of PageSizeAlreadySetException.
+     */
+    public PageSizeAlreadySetException( Throwable cause )
+    {
+        super( cause );
+    }
+
+
+    /**
+     * Creates a new instance of PageSizeAlreadySetException.
+     *
+     * @param explanation The message associated with the exception
+     * @param cause The root cause for this exception
+     */
+    public PageSizeAlreadySetException( String explanation, Throwable cause )
+    {
+        super( explanation, cause );
+    }
+}



Mime
View raw message