ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: fix treeMeta initialization after start
Date Wed, 18 Jan 2017 08:56:08 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-gg-11810-1 9134452f5 -> aa70af0cf


fix treeMeta initialization after start


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

Branch: refs/heads/ignite-gg-11810-1
Commit: aa70af0cfc338fc1db3aac74b3d8dff1840d7bfe
Parents: 9134452
Author: sboikov <sboikov@gridgain.com>
Authored: Wed Jan 18 11:54:29 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Wed Jan 18 11:54:29 2017 +0300

----------------------------------------------------------------------
 .../cache/database/tree/BPlusTree.java          | 47 +++++++++++++-------
 1 file changed, 30 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/aa70af0c/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 7cf829e..09d68da 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
@@ -675,33 +675,46 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
                 assert res == TRUE: res;
             }
         }
-        else {
-            try (Page meta = page(metaPageId)) {
-                long pageAddr = readLock(meta); // Meta can't be removed.
+    }
 
-                assert pageAddr != 0 : "Failed to read lock meta page [page=" + meta + ",
metaPageId=" +
-                    U.hexLong(metaPageId) + ']';
+    /**
+     * @return Tree meta data.
+     * @throws IgniteCheckedException If failed.
+     */
+    private TreeMetaData treeMeta() throws IgniteCheckedException {
+        TreeMetaData meta0 = treeMeta;
 
-                try {
-                    BPlusMetaIO io = BPlusMetaIO.VERSIONS.forPage(pageAddr);
+        if (meta0 != null)
+            return meta0;
 
-                    int rootLvl = io.getRootLevel(pageAddr);
-                    long rootId = io.getFirstPageId(pageAddr, rootLvl);
+        try (Page meta = page(metaPageId)) {
+            long pageAddr = readLock(meta); // Meta can't be removed.
 
-                    treeMeta = new TreeMetaData(rootLvl, rootId);
-                }
-                finally {
-                    readUnlock(meta, pageAddr);
-                }
+            assert pageAddr != 0 : "Failed to read lock meta page [page=" + meta + ", metaPageId="
+
+                U.hexLong(metaPageId) + ']';
+
+            try {
+                BPlusMetaIO io = BPlusMetaIO.VERSIONS.forPage(pageAddr);
+
+                int rootLvl = io.getRootLevel(pageAddr);
+                long rootId = io.getFirstPageId(pageAddr, rootLvl);
+
+                treeMeta = meta0 = new TreeMetaData(rootLvl, rootId);
+            }
+            finally {
+                readUnlock(meta, pageAddr);
             }
         }
+
+        return meta0;
     }
 
     /**
      * @return Root level.
+     * @throws IgniteCheckedException If failed.
      */
-    private int getRootLevel() {
-        TreeMetaData meta0 = treeMeta;
+    private int getRootLevel() throws IgniteCheckedException {
+        TreeMetaData meta0 = treeMeta();
 
         assert meta0 != null;
 
@@ -1956,7 +1969,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
          * @throws IgniteCheckedException If failed.
          */
         final void init() throws IgniteCheckedException {
-            TreeMetaData meta0 = treeMeta;
+            TreeMetaData meta0 = treeMeta();
 
             assert meta0 != null;
 


Mime
View raw message