Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 70EB819657 for ; Thu, 28 Apr 2016 08:52:34 +0000 (UTC) Received: (qmail 40885 invoked by uid 500); 28 Apr 2016 08:52:34 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 40661 invoked by uid 500); 28 Apr 2016 08:52:33 -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 39649 invoked by uid 99); 28 Apr 2016 08:52:32 -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, 28 Apr 2016 08:52:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 20F28E03CE; Thu, 28 Apr 2016 08:52:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Thu, 28 Apr 2016 08:53:05 -0000 Message-Id: In-Reply-To: <66d7caab4e4341d5854ef938544c84dd@git.apache.org> References: <66d7caab4e4341d5854ef938544c84dd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [35/50] ignite git commit: ignite-db - minor ignite-db - minor Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2b30543a Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2b30543a Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2b30543a Branch: refs/heads/ignite-db-x-10884 Commit: 2b30543aa5cf777cfb5e3c87fcbb4882254c2c2d Parents: 3daefae Author: S.Vladykin Authored: Wed Apr 27 01:08:35 2016 +0300 Committer: S.Vladykin Committed: Wed Apr 27 01:08:35 2016 +0300 ---------------------------------------------------------------------- .../cache/database/tree/BPlusTree.java | 51 +++++++++++--------- 1 file changed, 29 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/2b30543a/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 06649cf..70f1af5 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 @@ -965,20 +965,6 @@ public abstract class BPlusTree { } /** - * @param leftCnt Left count. - * @param rightCnt Right count. - * @param cap Capacity. - * @param leaf Is leaf pages. - * @return {@code true} If can merge these pages. - */ - private boolean canMerge(int leftCnt, int rightCnt, int cap, boolean leaf) { - cap -= leftCnt; - cap -= rightCnt; - - return cap > 0 || (cap == 0 && (leaf || leftCnt == 0 || rightCnt == 0)); - } - - /** * @param cnt Count. * @param cap Capacity. * @return {@code true} If may merge. @@ -1628,7 +1614,7 @@ public abstract class BPlusTree { Tail tail; /** */ - List emptyPages; // TODO May be use Object for single empty page + Object emptyPages; /** */ byte needReplaceInner = FALSE; @@ -1976,6 +1962,7 @@ public abstract class BPlusTree { * @param release Release write lock and release page. * @throws IgniteCheckedException If failed. */ + @SuppressWarnings("unchecked") private void freePage(Page page, ByteBuffer buf, BPlusIO io, int lvl, boolean release) throws IgniteCheckedException { if (getFirstPageId(meta, lvl) == page.id()) { @@ -1988,26 +1975,46 @@ public abstract class BPlusTree { // Mark removed. io.setRemoveId(buf, Long.MAX_VALUE); + if (release) + writeUnlockAndClose(page); + if (reuseList == null) return; // We are not allowed to reuse pages. - // We will reuse empty page. + // Reuse empty page. if (emptyPages == null) - emptyPages = new ArrayList<>(4); + emptyPages = page.fullId(); + else { + List list; - emptyPages.add(page.fullId()); + if (emptyPages.getClass() != ArrayList.class) { + list = new ArrayList<>(5); - if (release) - writeUnlockAndClose(page); + list.add((FullPageId)emptyPages); + + emptyPages = list; + } + else + list = (List)emptyPages; + + list.add(page.fullId()); + } } /** * @throws IgniteCheckedException If failed. */ + @SuppressWarnings("unchecked") private void reuseEmptyPages() throws IgniteCheckedException { if (emptyPages != null) { - for (int i = 0; i < emptyPages.size(); i++) - reuseList.put(BPlusTree.this, emptyPages.get(i)); + if (emptyPages.getClass() != ArrayList.class) + reuseList.put(BPlusTree.this, (FullPageId)emptyPages); + else { + List list = (List)emptyPages; + + for (int i = 0; i < list.size(); i++) + reuseList.put(BPlusTree.this, list.get(i)); + } } }