ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [06/17] ignite git commit: ignite-db-x - tryReplaceInner
Date Thu, 16 Feb 2017 14:40:58 GMT
ignite-db-x - tryReplaceInner


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

Branch: refs/heads/ignite-4652
Commit: 97e9bd96028651e8deb4873c71a7a91cd40b91c4
Parents: 7689b36
Author: Sergi Vladykin <sergi.vladykin@gmail.com>
Authored: Mon Feb 13 17:57:13 2017 +0300
Committer: Sergi Vladykin <sergi.vladykin@gmail.com>
Committed: Mon Feb 13 17:57:13 2017 +0300

----------------------------------------------------------------------
 .../cache/database/tree/BPlusTree.java          | 63 ++++++++++++--------
 1 file changed, 39 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/97e9bd96/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 e126923..f87ba2b 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
@@ -2055,31 +2055,10 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
                         assert p.pageId != pageId;
                         assert p.fwdId != fwdId || fwdId == 0;
 
-                        // Need to replace key in inner page. There is no race because we
keep tail lock after split.
-                        if (p.needReplaceInner == TRUE) {
-                            p.needReplaceInner = FALSE; // Protect from retries.
+                        res = p.tryReplaceInner(page, pageId, fwdId, lvl);
 
-                            long oldFwdId = p.fwdId;
-                            long oldPageId = p.pageId;
-
-                            // Set old args.
-                            p.fwdId = fwdId;
-                            p.pageId = pageId;
-
-                            res = writePage(pageMem, page, this, replace, p, lvl, RETRY);
-
-                            // Restore args.
-                            p.pageId = oldPageId;
-                            p.fwdId = oldFwdId;
-
-                            if (res != FOUND)
-                                return res; // Need to retry.
-
-                            p.needReplaceInner = DONE; // We can have only single matching
inner key.
-                        }
-
-                        // Go down recursively.
-                        res = putDown(p, p.pageId, p.fwdId, lvl - 1);
+                        if (res != RETRY) // Go down recursively.
+                            res = putDown(p, p.pageId, p.fwdId, lvl - 1);
 
                         if (res == RETRY_ROOT || p.isFinished())
                             return res;
@@ -2595,6 +2574,42 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
                 }
             }
         }
+
+        /**
+         * @param page Page.
+         * @param pageId Page ID.
+         * @param fwdId Forward ID.
+         * @param lvl Level.
+         * @return Result.
+         * @throws IgniteCheckedException If failed.
+         */
+        private Result tryReplaceInner(Page page, long pageId, long fwdId, int lvl)
+            throws IgniteCheckedException {
+            // Need to replace key in inner page. There is no race because we keep tail lock
after split.
+            if (needReplaceInner == TRUE) {
+                needReplaceInner = FALSE; // Protect from retries.
+
+                long oldFwdId = this.fwdId;
+                long oldPageId = this.pageId;
+
+                // Set old args.
+                this.fwdId = fwdId;
+                this.pageId = pageId;
+
+                Result res = writePage(pageMem, page, BPlusTree.this, replace, this, lvl,
RETRY);
+
+                // Restore args.
+                this.pageId = oldPageId;
+                this.fwdId = oldFwdId;
+
+                if (res == RETRY)
+                    return res;
+
+                needReplaceInner = DONE; // We can have only a single matching inner key.
+            }
+
+            return FOUND;
+        }
     }
 
     /**


Mime
View raw message