Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9B543200C1D for ; Thu, 16 Feb 2017 15:40:55 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9A2E3160B82; Thu, 16 Feb 2017 14:40:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C14EB160B57 for ; Thu, 16 Feb 2017 15:40:54 +0100 (CET) Received: (qmail 72933 invoked by uid 500); 16 Feb 2017 14:40:54 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 72923 invoked by uid 99); 16 Feb 2017 14:40:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2017 14:40:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D0FF6DFC2F; Thu, 16 Feb 2017 14:40:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergi@apache.org To: commits@ignite.apache.org Date: Thu, 16 Feb 2017 14:40:53 -0000 Message-Id: <2ba0991f13044afca76204addb519d1c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/17] ignite git commit: ignite-4652 - minor archived-at: Thu, 16 Feb 2017 14:40:55 -0000 Repository: ignite Updated Branches: refs/heads/ignite-4652 8b68231e0 -> affadf3bb ignite-4652 - minor Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1fd247f7 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1fd247f7 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1fd247f7 Branch: refs/heads/ignite-4652 Commit: 1fd247f712f00d56132c8259386f28c8430053ba Parents: 42b7f47 Author: Sergi Vladykin Authored: Mon Feb 6 16:42:28 2017 +0300 Committer: Sergi Vladykin Committed: Mon Feb 6 16:42:28 2017 +0300 ---------------------------------------------------------------------- .../cache/database/tree/BPlusTree.java | 44 ++++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/1fd247f7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java index 78ebb3b..39b8b10 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java @@ -68,9 +68,9 @@ import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTre import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.Bool.FALSE; import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.Bool.READY; import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.Bool.TRUE; -import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.InvokeType.DELETE; import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.InvokeType.INSERT; import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.InvokeType.NOOP; +import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.InvokeType.REMOVE; import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.InvokeType.REPLACE; import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.Result.FOUND; import static org.apache.ignite.internal.processors.cache.database.tree.BPlusTree.Result.GO_DOWN; @@ -82,7 +82,6 @@ import static org.apache.ignite.internal.processors.cache.database.tree.util.Pag import static org.apache.ignite.internal.processors.cache.database.tree.util.PageHandler.isWalDeltaRecordNeeded; import static org.apache.ignite.internal.processors.cache.database.tree.util.PageHandler.readPage; import static org.apache.ignite.internal.processors.cache.database.tree.util.PageHandler.writePage; -import static org.apache.ignite.internal.util.IgniteTree.OperationType.REMOVE; /** * Abstract B+Tree. @@ -1563,13 +1562,30 @@ public abstract class BPlusTree extends DataStructure implements case FOUND: // We must be at the bottom here, just need to remove row from the current page. assert lvl == 0 : lvl; - assert r.invokeType != null; - res = r.removeFromLeaf(pageId, page, backId, fwdId); + switch (r.invokeType) { + case REPLACE: { + // TODO replace + break; + } - if (res == FOUND && r.tail == null) { - // Finish if we don't need to do any merges. - r.finish(); + case REMOVE: { + res = r.removeFromLeaf(pageId, page, backId, fwdId); + + if (res == FOUND && r.tail == null) { + // Finish if we don't need to do any merges. + r.finish(); + } + + break; + } + + case NOOP: + break; + + case INSERT: // We can not have INSERT here since we have found a row. + default: + throw new IllegalStateException("Type: " + r.invokeType); } return res; @@ -2506,10 +2522,13 @@ public abstract class BPlusTree extends DataStructure implements } /** - * @return Operation type or {@code null} if it is unknown yet. + * @return Operation type or {@code null} if it is unknown yet. When the closure is invoked + * we must know exact operation type. Note that even if the operation type is known + * from the beginning it is allowed to change after the closure invocation, for example + * initially it was {@code PUT} but became {@code NOOP}. */ private OperationType getOperationType() { - return c == null ? REMOVE : c.operationType(); + return c == null ? OperationType.REMOVE : c.operationType(); } /** @@ -2521,8 +2540,7 @@ public abstract class BPlusTree extends DataStructure implements OperationType opType = getOperationType(); - if (opType == null) - return; + assert opType != null; // We do this always after the closure has been invoked. switch (opType) { case NOOP: @@ -2534,7 +2552,7 @@ public abstract class BPlusTree extends DataStructure implements break; case REMOVE: - invokeType = DELETE; + invokeType = REMOVE; break; default: @@ -4063,7 +4081,7 @@ public abstract class BPlusTree extends DataStructure implements REPLACE, /** */ - DELETE, + REMOVE, /** */ NOOP