ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [30/50] ignite git commit: ignite-db - fixes
Date Thu, 28 Apr 2016 08:53:00 GMT
ignite-db - fixes


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3166aeb5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3166aeb5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3166aeb5

Branch: refs/heads/ignite-db-x-10884
Commit: 3166aeb5b7661f1207d825b198e2fd54d87bcb56
Parents: b0cab0c
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Tue Apr 26 07:59:32 2016 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Tue Apr 26 07:59:32 2016 +0300

----------------------------------------------------------------------
 .../cache/database/tree/BPlusTree.java          | 19 ++--
 .../processors/database/BPlusTreeSelfTest.java  | 99 +++++++++++++++++++-
 2 files changed, 104 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3166aeb5/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 6173d72..b90c5b2 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
@@ -1762,8 +1762,9 @@ public abstract class BPlusTree<L, T extends L> {
                 boolean mergeMore = mergeDown(tail);
 
                 if (needReplaceInner == READY) {
-                    // Need to replace inner key with new max key for the left subtree.
-                    replaceInner(needMergeEmptyBranch == DONE);
+                    // If we've merged empty branch then the inner key was dropped.
+                    if (needMergeEmptyBranch != DONE)
+                        replaceInner(); // Need to replace inner key with new max key for
the left subtree.
 
                     needReplaceInner = DONE;
                 }
@@ -2007,10 +2008,9 @@ public abstract class BPlusTree<L, T extends L> {
         }
 
         /**
-         * @param emptyBranchMerged If empty branch was merged.
          * @throws IgniteCheckedException If failed.
          */
-        private void replaceInner(boolean emptyBranchMerged) throws IgniteCheckedException
{
+        private void replaceInner() throws IgniteCheckedException {
             assert needReplaceInner == READY: needReplaceInner;
             assert tail.lvl > 0: "leaf";
             assert innerIdx >= 0: innerIdx;
@@ -2025,21 +2025,14 @@ public abstract class BPlusTree<L, T extends L> {
 
             assert leafCnt > 0: leafCnt; // Leaf must be merged at this point already
if it was empty.
 
-            if (innerIdx == innerCnt) {
-                if (emptyBranchMerged)
-                    return; // Our inner key was dropped.
-
-                throw new IllegalStateException();
-            }
-
-            if (innerIdx < inner.getCount()) {
+            if (innerIdx < innerCnt) {
                 // Update inner key with the new biggest key of left subtree.
                 inner.io.store(inner.buf, innerIdx, leaf.io, leaf.buf, leafCnt - 1);
                 leaf.io.setRemoveId(leaf.buf, globalRmvId.get());
             }
             else {
                 // If after leaf merge parent have lost inner key, we don't need to update
it anymore.
-                assert innerIdx == inner.getCount();
+                assert innerIdx == innerCnt;
                 assert inner(inner.io).getLeft(inner.buf, innerIdx) == leaf.page.id();
             }
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3166aeb5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
index ce3840a..c2b7a0b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java
@@ -207,6 +207,103 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
         doTestPutRemove(false);
     }
 
+    // ------- 2 - 40
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    public void testPutRemove_2_40_mm_1() throws IgniteCheckedException {
+        MAX_ITEMS_COUNT = 2;
+        CNT = 40;
+        PUT_INC = -1;
+        RMV_INC = -1;
+
+        doTestPutRemove(true);
+    }
+
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    public void testPutRemove_2_40_mm_0() throws IgniteCheckedException {
+        MAX_ITEMS_COUNT = 2;
+        CNT = 40;
+        PUT_INC = -1;
+        RMV_INC = -1;
+
+        doTestPutRemove(false);
+    }
+
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    public void testPutRemove_2_40_pm_1() throws IgniteCheckedException {
+        MAX_ITEMS_COUNT = 2;
+        CNT = 40;
+        PUT_INC = 1;
+        RMV_INC = -1;
+
+        doTestPutRemove(true);
+    }
+
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    public void testPutRemove_2_40_pm_0() throws IgniteCheckedException {
+        MAX_ITEMS_COUNT = 2;
+        CNT = 40;
+        PUT_INC = 1;
+        RMV_INC = -1;
+
+        doTestPutRemove(false);
+    }
+
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    public void testPutRemove_2_40_pp_1() throws IgniteCheckedException {
+        MAX_ITEMS_COUNT = 2;
+        CNT = 40;
+        PUT_INC = 1;
+        RMV_INC = 1;
+
+        doTestPutRemove(true);
+    }
+
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    public void testPutRemove_2_40_pp_0() throws IgniteCheckedException {
+        MAX_ITEMS_COUNT = 2;
+        CNT = 40;
+        PUT_INC = 1;
+        RMV_INC = 1;
+
+        doTestPutRemove(false);
+    }
+
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    public void testPutRemove_2_40_mp_1() throws IgniteCheckedException {
+        MAX_ITEMS_COUNT = 2;
+        CNT = 40;
+        PUT_INC = -1;
+        RMV_INC = 1;
+
+        doTestPutRemove(true);
+    }
+
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    public void testPutRemove_2_40_mp_0() throws IgniteCheckedException {
+        MAX_ITEMS_COUNT = 2;
+        CNT = 40;
+        PUT_INC = -1;
+        RMV_INC = 1;
+
+        doTestPutRemove(false);
+    }
+
     /**
      * @param canGetRow Can get row from inner page.
      * @throws IgniteCheckedException If failed.
@@ -214,7 +311,7 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest {
     private void doTestPutRemove(boolean canGetRow) throws IgniteCheckedException {
         TestTree tree = createTestTree(canGetRow);
 
-        long cnt = 10;
+        long cnt = CNT;
 
         for (long x = PUT_INC > 0 ? 0 : cnt - 1; x >= 0 && x < cnt; x +=
PUT_INC) {
             assertNull(tree.findOne(x));


Mime
View raw message