directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1510115 [1/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
Author: kayyagari
Date: Sun Aug  4 09:22:56 2013
New Revision: 1510115

URL: http://svn.apache.org/r1510115
Log:
renamed the package and the artifact id

Added:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractBorrowedFromSiblingResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractDeleteResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractPage.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Addition.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTree.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeBuilder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeConfiguration.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeFactory.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeHeader.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BTreeTypeEnum.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BorrowedFromLeftResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BorrowedFromRightResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/BorrowedFromSiblingResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Cursor.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/DeleteResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Deletion.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/DuplicateKeyMemoryHolder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ElementHolder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/InsertResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/InternalUtil.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Leaf.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/MemoryHolder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/MergedWithSiblingResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Modification.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ModifyResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Node.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/NotPresentResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Page.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/PageIO.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ParentPos.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/PoisonPill.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/ReferenceHolder.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RemoveResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Result.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionName.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RevisionNameSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/SplitResult.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Transaction.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Tuple.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/BooleanComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ByteComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/CharComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/IntComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/LongComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/StringComparator.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/BTreeAlreadyManagedException.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/EndOfFileExceededException.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/KeyNotFoundException.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/exception/PageSizeAlreadySetException.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/AbstractElementSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/BufferHandler.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ByteSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharArraySerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/CharSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ElementSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/IntSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongArraySerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/LongSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/Serializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/ShortSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/serializer/StringSerializer.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/BulkDataSorter.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/IntTupleReaderWriter.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/Strings.java
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/util/TupleReaderWriter.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/BTreeBuilderTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/BTreeConfigurationTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/BTreeDuplicateKeyTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/BTreeFlushTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/InMemoryBTreeTestOps.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/LeafTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/MultiThreadedBtreeTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/ReadTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/RecordManagerFreePageTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/RecordManagerPrivateMethodTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/RecordManagerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/RecordManagerWithDuplicatesTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/StoreTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanArrayComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/BooleanComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteArrayComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ByteComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharArrayComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/CharComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntArrayComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/IntComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongArrayComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/LongComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/RevisionNameComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/ShortComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/comparator/StringComparatorTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/BooleanSerializerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteArraySerializerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ByteSerializerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/CharSerializerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/IntSerializerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/LongSerializerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/RevisionNameSerializerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/ShortSerializerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/serializer/StringSerializerTest.java
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/util/
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/directory/mavibot/btree/util/BulkDataSorterTest.java
Removed:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/mavibot/
    directory/mavibot/trunk/mavibot/src/test/java/org/apache/mavibot/
Modified:
    directory/mavibot/trunk/mavibot/pom.xml
    directory/mavibot/trunk/mavibot/src/test/resources/log4j.properties
    directory/mavibot/trunk/pom.xml

Modified: directory/mavibot/trunk/mavibot/pom.xml
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/pom.xml?rev=1510115&r1=1510114&r2=1510115&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/pom.xml (original)
+++ directory/mavibot/trunk/mavibot/pom.xml Sun Aug  4 09:22:56 2013
@@ -21,13 +21,12 @@
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
-    <groupId>org.apache.labs.mavibot</groupId>
+    <groupId>org.apache.directory.mavibot</groupId>
     <artifactId>mavibot-parent</artifactId>
     <version>1.0.0-SNAPSHOT</version>
   </parent>
 
-  <groupId>org.apache.labs.mavibot</groupId>
-  <artifactId>apache-mavibot</artifactId>
+  <artifactId>apacheds-mavibot</artifactId>
   <name>ApacheDS MVCC BTree implementation</name>
   <packaging>bundle</packaging>
 

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractBorrowedFromSiblingResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractBorrowedFromSiblingResult.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractBorrowedFromSiblingResult.java
(added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractBorrowedFromSiblingResult.java
Sun Aug  4 09:22:56 2013
@@ -0,0 +1,127 @@
+/*
+ *  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, and when
+ * we have borrowed an element from the left sibling. 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 */abstract class AbstractBorrowedFromSiblingResult<K, V> extends AbstractDeleteResult<K,
V> implements
+    BorrowedFromSiblingResult<K, V>
+{
+    /** The modified sibling reference */
+    private Page<K, V> modifiedSibling;
+
+    /** Tells if the sibling is the left or right one */
+    protected SiblingPosition position;
+
+    /** The two possible position for the sibling */
+    protected enum SiblingPosition
+    {
+        LEFT,
+        RIGHT
+    }
+
+
+    /**
+     * The default constructor for RemoveResult.
+     * 
+     * @param modifiedPage The modified page
+     * @param modifiedSibling The modified sibling
+     * @param removedElement The removed element (can be null if the key wasn't present in
the tree)
+     */
+    /* No qualifier */AbstractBorrowedFromSiblingResult( Page<K, V> modifiedPage, Page<K,
V> modifiedSibling,
+        Tuple<K, V> removedElement, SiblingPosition position )
+    {
+        super( modifiedPage, removedElement );
+        this.modifiedSibling = modifiedSibling;
+        this.position = position;
+    }
+
+
+    /**
+     * A constructor for RemoveResult with a list of copied pages.
+     * 
+     * @param copiedPages the list of copied pages
+     * @param modifiedPage The modified page
+     * @param modifiedSibling The modified sibling
+     * @param removedElement The removed element (can be null if the key wasn't present in
the tree)
+     */
+    /* No qualifier */AbstractBorrowedFromSiblingResult( List<Page<K, V>> copiedPages,
Page<K, V> modifiedPage,
+        Page<K, V> modifiedSibling,
+        Tuple<K, V> removedElement, SiblingPosition position )
+    {
+        super( copiedPages, modifiedPage, removedElement );
+        this.modifiedSibling = modifiedSibling;
+        this.position = position;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Page<K, V> getModifiedSibling()
+    {
+        return modifiedSibling;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isFromLeft()
+    {
+        return position == SiblingPosition.LEFT;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isFromRight()
+    {
+        return position == SiblingPosition.RIGHT;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "\n    removed element : " ).append( getRemovedElement() );
+        sb.append( "\n    modifiedPage : " ).append( getModifiedPage() );
+        sb.append( "\n    modifiedSibling : " ).append( getModifiedSibling() );
+
+        return sb.toString();
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractDeleteResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractDeleteResult.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractDeleteResult.java
(added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractDeleteResult.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;
+
+
+import java.util.List;
+
+
+/**
+ * An abstract class to gather common elements of the DeleteResult
+ * 
+ * @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 */abstract class AbstractDeleteResult<K, V> extends AbstractResult<K,
V> implements DeleteResult<K, V>
+{
+    /** The modified page reference */
+    private Page<K, V> modifiedPage;
+
+    /** The removed element if the key was found in the tree*/
+    private Tuple<K, V> removedElement;
+
+
+    /**
+     * The default constructor for AbstractDeleteResult.
+     * 
+     * @param modifiedPage The modified page
+     * @param removedElement The removed element (can be null if the key wasn't present in
the tree)
+     */
+    /* No qualifier */AbstractDeleteResult( Page<K, V> modifiedPage, Tuple<K, V>
removedElement )
+    {
+        super();
+        this.modifiedPage = modifiedPage;
+        this.removedElement = removedElement;
+    }
+
+
+    /**
+     * The default constructor for AbstractDeleteResult.
+     * 
+     * @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 */AbstractDeleteResult( List<Page<K, V>> copiedPages, Page<K,
V> modifiedPage,
+        Tuple<K, V> removedElement )
+    {
+        super( copiedPages );
+        this.modifiedPage = modifiedPage;
+        this.removedElement = removedElement;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Page<K, V> getModifiedPage()
+    {
+        return modifiedPage;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Tuple<K, V> getRemovedElement()
+    {
+        return removedElement;
+    }
+
+
+    /**
+     * @param modifiedPage the modifiedPage to set
+     */
+    /* No qualifier */void setModifiedPage( Page<K, V> modifiedPage )
+    {
+        this.modifiedPage = modifiedPage;
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractPage.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractPage.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractPage.java
(added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractPage.java
Sun Aug  4 09:22:56 2013
@@ -0,0 +1,357 @@
+/*
+ *  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.reflect.Array;
+
+
+/**
+ * A MVCC abstract Page. It stores the field and the methods shared by the Node and Leaf
+ * classes.
+ * 
+ * @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 */abstract class AbstractPage<K, V> implements Page<K, V>
+{
+    /** Parent B+Tree. */
+    protected transient BTree<K, V> btree;
+
+    /** This BPage's revision */
+    protected long revision;
+
+    /** Keys of children nodes */
+    protected K[] keys;
+
+    /** The number of current values in the Page */
+    protected int nbElems;
+
+    /** The first {@link PageIO} storing the serialized Page on disk */
+    private long offset = -1L;
+
+    /** The last {@link PageIO} storing the serialized Page on disk */
+    private long lastOffset = -1L;
+
+
+    /**
+     * Creates a default empty AbstractPage
+     * 
+     * @param btree The associated BTree
+     */
+    protected AbstractPage( BTree<K, V> btree )
+    {
+        this.btree = btree;
+    }
+
+
+    /**
+     * Internal constructor used to create Page instance used when a page is being copied
or overflow
+     */
+    @SuppressWarnings("unchecked")
+    // Cannot create an array of generic objects
+    protected AbstractPage( BTree<K, V> btree, long revision, int nbElems )
+    {
+        this.btree = btree;
+        this.revision = revision;
+        this.nbElems = nbElems;
+
+        // We get the type of array to create from the btree
+        // Yes, this is an hack...
+        Class<?> keyType = btree.getKeyType();
+        this.keys = ( K[] ) Array.newInstance( keyType, nbElems );
+    }
+
+
+    /**
+     * Selects the sibling (the previous or next page with the same parent) which has
+     * the more element assuming it's above N/2
+     * 
+     * @param parent The parent of the current page
+     * @param The position of the current page reference in its parent
+     * @return The position of the sibling, or -1 if we have'nt found any sibling
+     * @throws IOException If we have an error while trying to access the page
+     */
+    protected int selectSibling( Node<K, V> parent, int parentPos ) throws IOException
+    {
+        if ( parentPos == 0 )
+        {
+            // The current page is referenced on the left of its parent's page :
+            // we will not have a previous page with the same parent
+            return 1;
+        }
+
+        if ( parentPos == parent.getNbElems() )
+        {
+            // The current page is referenced on the right of its parent's page :
+            // we will not have a next page with the same parent
+            return parentPos - 1;
+        }
+
+        Page<K, V> prevPage = parent.children[parentPos - 1].getValue( btree );
+        Page<K, V> nextPage = parent.children[parentPos + 1].getValue( btree );
+
+        int prevPageSize = prevPage.getNbElems();
+        int nextPageSize = nextPage.getNbElems();
+
+        if ( prevPageSize >= nextPageSize )
+        {
+            return parentPos - 1;
+        }
+        else
+        {
+            return parentPos + 1;
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getNbElems()
+    {
+        return nbElems;
+    }
+
+
+    /**
+     * Finds the position of the given key in the page. If we have found the key,
+     * we will return its position as a negative value.
+     * <p/>
+     * Assuming that the array is zero-indexed, the returned value will be : <br/>
+     *   position = - ( position + 1)
+     * <br/>
+     * So for the following table of keys : <br/>
+     * <pre>
+     * +---+---+---+---+
+     * | b | d | f | h |
+     * +---+---+---+---+
+     *   0   1   2   3
+     * </pre>
+     * looking for 'b' will return -1 (-(0+1)) and looking for 'f' will return -3 (-(2+1)).<br/>
+     * Computing the real position is just a matter to get -(position++).
+     * <p/>
+     * If we don't find the key in the table, we will return the position of the key
+     * immediately above the key we are looking for. <br/>
+     * For instance, looking for :
+     * <ul>
+     * <li>'a' will return 0</li>
+     * <li>'b' will return -1</li>
+     * <li>'c' will return 1</li>
+     * <li>'d' will return -2</li>
+     * <li>'e' will return 2</li>
+     * <li>'f' will return -3</li>
+     * <li>'g' will return 3</li>
+     * <li>'h' will return -4</li>
+     * <li>'i' will return 4</li>
+     * </ul>
+     * 
+     * 
+     * @param key The key to find
+     * @return The position in the page.
+     */
+    public int findPos( K key )
+    {
+        // Deal with the special key where we have an empty page
+        if ( nbElems == 0 )
+        {
+            return 0;
+        }
+
+        int min = 0;
+        int max = nbElems - 1;
+
+        // binary search
+        while ( min < max )
+        {
+            int middle = ( min + max + 1 ) >> 1;
+
+            int comp = compare( keys[middle], key );
+
+            if ( comp < 0 )
+            {
+                min = middle + 1;
+            }
+            else if ( comp > 0 )
+            {
+                max = middle - 1;
+            }
+            else
+            {
+                // Special case : the key already exists,
+                // we can return immediately. The value will be
+                // negative, and as the index may be 0, we subtract 1
+                return -( middle + 1 );
+            }
+        }
+
+        // Special case : we don't know if the key is present
+        int comp = compare( keys[max], key );
+
+        if ( comp == 0 )
+        {
+            return -( max + 1 );
+        }
+        else
+        {
+            if ( comp < 0 )
+            {
+                return max + 1;
+            }
+            else
+            {
+                return max;
+            }
+        }
+    }
+
+
+    /**
+     * Compares two keys
+     * 
+     * @param key1 The first key
+     * @param key2 The second key
+     * @return -1 if the first key is above the second one, 1 if it's below, and 0
+     * if the two keys are equal
+     */
+    private final int compare( K key1, K key2 )
+    {
+        if ( key1 == key2 )
+        {
+            return 0;
+        }
+
+        if ( key1 == null )
+        {
+            return 1;
+        }
+
+        if ( key2 == null )
+        {
+            return -1;
+        }
+
+        return btree.getComparator().compare( key1, key2 );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public long getRevision()
+    {
+        return revision;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public K getKey( int pos )
+    {
+        if ( pos < nbElems )
+        {
+            return keys[pos];
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Sets the key at a give position
+     * 
+     * @param pos The position in the keys array
+     * @param key the key to inject
+     */
+    /* No qualifier*/void setKey( int pos, K key )
+    {
+        keys[pos] = key;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public long getOffset()
+    {
+        return offset;
+    }
+
+
+    /**
+     * @param offset the offset to set
+     */
+    /* No qualifier */void setOffset( long offset )
+    {
+        this.offset = offset;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public long getLastOffset()
+    {
+        return lastOffset;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    /* No qualifier */void setLastOffset( long lastOffset )
+    {
+        this.lastOffset = lastOffset;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "r" ).append( revision );
+        sb.append( ", nbElems:" ).append( nbElems );
+
+        if ( offset > 0 )
+        {
+            sb.append( ", offset:" ).append( offset );
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String dumpPage( String tabs )
+    {
+        return "";
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractResult.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractResult.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractResult.java
(added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/AbstractResult.java
Sun Aug  4 09:22:56 2013
@@ -0,0 +1,106 @@
+/*
+ *  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.ArrayList;
+import java.util.List;
+
+
+/**
+ * An abstract class to gather common elements of the Result classes
+ * 
+ * @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 */abstract class AbstractResult<K, V> implements Result<K, V>
+{
+    /** The list of copied page reference */
+    private List<Page<K, V>> copiedPage;
+
+
+    /**
+     * The default constructor for AbstractResult.
+     * 
+     */
+    /* No qualifier */AbstractResult()
+    {
+        copiedPage = new ArrayList<Page<K, V>>();
+    }
+
+
+    /**
+     * Creates an instance of AbstractResult with an initialized list of copied pages.
+     * 
+     * @param copiedPages The list of copied pages to store in this result
+     */
+    /* No qualifier */AbstractResult( List<Page<K, V>> copiedPages )
+    {
+        this.copiedPage = copiedPages;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Page<K, V>> getCopiedPages()
+    {
+        return copiedPage;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addCopiedPage( Page<K, V> page )
+    {
+        copiedPage.add( page );
+    }
+
+
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( "\n    copiedPage = <" );
+
+        boolean isFirst = true;
+
+        for ( Page<K, V> copiedPage : getCopiedPages() )
+        {
+            if ( isFirst )
+            {
+                isFirst = false;
+            }
+            else
+            {
+                sb.append( ", " );
+            }
+
+            sb.append( copiedPage.getOffset() );
+        }
+
+        sb.append( ">" );
+
+        return sb.toString();
+    }
+}

Added: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Addition.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Addition.java?rev=1510115&view=auto
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Addition.java
(added)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/Addition.java
Sun Aug  4 09:22:56 2013
@@ -0,0 +1,43 @@
+/*
+ *  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 class used to store an Addition modification done on a BTree.
+ *  
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ *
+ * @param <K> The key type
+ * @param <V> The value type
+ */
+public class Addition<K, V> extends Modification<K, V>
+{
+    /**
+     * Create a new Addition instance.
+     * 
+     * @param key The key being added
+     * @param value The value being added
+     */
+    public Addition( K key, V value )
+    {
+        super( key, value );
+    }
+}



Mime
View raw message