Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 89EE710CBB for ; Sun, 4 Aug 2013 09:23:37 +0000 (UTC) Received: (qmail 56462 invoked by uid 500); 4 Aug 2013 09:23:37 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 56425 invoked by uid 500); 4 Aug 2013 09:23:35 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 56418 invoked by uid 99); 4 Aug 2013 09:23:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Aug 2013 09:23:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Aug 2013 09:23:25 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5483C23888E4; Sun, 4 Aug 2013 09:23:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: kayyagari@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130804092303.5483C23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ 4.0.0 - org.apache.labs.mavibot + org.apache.directory.mavibot mavibot-parent 1.0.0-SNAPSHOT - org.apache.labs.mavibot - apache-mavibot + apacheds-mavibot ApacheDS MVCC BTree implementation bundle 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 The type for the Key + * @param The type for the stored value + + * @author Mavibot labs Project + */ +/* No qualifier */abstract class AbstractBorrowedFromSiblingResult extends AbstractDeleteResult implements + BorrowedFromSiblingResult +{ + /** The modified sibling reference */ + private Page 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 modifiedPage, Page modifiedSibling, + Tuple 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> copiedPages, Page modifiedPage, + Page modifiedSibling, + Tuple removedElement, SiblingPosition position ) + { + super( copiedPages, modifiedPage, removedElement ); + this.modifiedSibling = modifiedSibling; + this.position = position; + } + + + /** + * {@inheritDoc} + */ + public Page 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 The type for the Key + * @param The type for the stored value + + * @author Mavibot labs Project + */ +/* No qualifier */abstract class AbstractDeleteResult extends AbstractResult implements DeleteResult +{ + /** The modified page reference */ + private Page modifiedPage; + + /** The removed element if the key was found in the tree*/ + private Tuple 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 modifiedPage, Tuple 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> copiedPages, Page modifiedPage, + Tuple removedElement ) + { + super( copiedPages ); + this.modifiedPage = modifiedPage; + this.removedElement = removedElement; + } + + + /** + * {@inheritDoc} + */ + public Page getModifiedPage() + { + return modifiedPage; + } + + + /** + * {@inheritDoc} + */ + public Tuple getRemovedElement() + { + return removedElement; + } + + + /** + * @param modifiedPage the modifiedPage to set + */ + /* No qualifier */void setModifiedPage( Page 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 The type for the Key + * @param The type for the stored value + * + * @author Mavibot labs Project + */ +/* No qualifier */abstract class AbstractPage implements Page +{ + /** Parent B+Tree. */ + protected transient BTree 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 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 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 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 prevPage = parent.children[parentPos - 1].getValue( btree ); + Page 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. + *

+ * Assuming that the array is zero-indexed, the returned value will be :
+ * position = - ( position + 1) + *
+ * So for the following table of keys :
+ *

+     * +---+---+---+---+
+     * | b | d | f | h |
+     * +---+---+---+---+
+     *   0   1   2   3
+     * 
+ * looking for 'b' will return -1 (-(0+1)) and looking for 'f' will return -3 (-(2+1)).
+ * Computing the real position is just a matter to get -(position++). + *

+ * 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.
+ * For instance, looking for : + *

    + *
  • 'a' will return 0
  • + *
  • 'b' will return -1
  • + *
  • 'c' will return 1
  • + *
  • 'd' will return -2
  • + *
  • 'e' will return 2
  • + *
  • 'f' will return -3
  • + *
  • 'g' will return 3
  • + *
  • 'h' will return -4
  • + *
  • 'i' will return 4
  • + *
+ * + * + * @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 The type for the Key + * @param The type for the stored value + + * @author Mavibot labs Project + */ +/* No qualifier */abstract class AbstractResult implements Result +{ + /** The list of copied page reference */ + private List> copiedPage; + + + /** + * The default constructor for AbstractResult. + * + */ + /* No qualifier */AbstractResult() + { + copiedPage = new ArrayList>(); + } + + + /** + * 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> copiedPages ) + { + this.copiedPage = copiedPages; + } + + + /** + * {@inheritDoc} + */ + public List> getCopiedPages() + { + return copiedPage; + } + + + /** + * {@inheritDoc} + */ + public void addCopiedPage( Page page ) + { + copiedPage.add( page ); + } + + + public String toString() + { + StringBuilder sb = new StringBuilder(); + + sb.append( "\n copiedPage = <" ); + + boolean isFirst = true; + + for ( Page 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 Mavibot labs Project + * + * @param The key type + * @param The value type + */ +public class Addition extends Modification +{ + /** + * 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 ); + } +}