Repository: ignite
Updated Branches:
  refs/heads/ignite-db-x-10884 ce4698f2d -> fc7e0630b


ignite-db - minor refactor


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

Branch: refs/heads/ignite-db-x-10884
Commit: 14ffbf0bcc48ffa4a652e523da74e29d53c7ead3
Parents: 213fc70
Author: S.Vladykin <[email protected]>
Authored: Wed Apr 20 21:10:41 2016 +0300
Committer: S.Vladykin <[email protected]>
Committed: Wed Apr 20 21:10:41 2016 +0300

----------------------------------------------------------------------
 .../cache/database/tree/BPlusTree.java          | 72 ++++++++++----------
 1 file changed, 36 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/14ffbf0b/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 864dae8..37d6d06 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
@@ -621,41 +621,12 @@ public abstract class BPlusTree<L, T extends L> {
     }
 
     /**
-     * Initialize the given operation.
-     *
-     * !!! Symmetrically with this method must be called {@link 
Get#releaseMeta()} in {@code finally} block.
-     *
-     * @param g Operation.
-     */
-    private void initOperation(Get g) throws IgniteCheckedException {
-        if (g.meta == null)
-            g.meta = page(metaPageId);
-
-        int rootLvl;
-        long rootId;
-
-        ByteBuffer buf = g.meta.getForRead();
-
-        try {
-            BPlusMetaIO io = BPlusMetaIO.VERSIONS.forPage(buf);
-
-            rootLvl = io.getRootLevel(buf);
-            rootId = io.getLeftmostPageId(buf, rootLvl);
-        }
-        finally {
-            g.meta.releaseRead();
-        }
-
-        g.restartFromRoot(rootId, rootLvl, globalRmvId.get());
-    }
-
-    /**
      * @param g Get.
      */
     private void doFind(Get g) throws IgniteCheckedException {
         try {
             for (;;) { // Go down with retries.
-                initOperation(g);
+                g.initOperation();
 
                 switch (findDown(g, g.rootId, 0L, g.rootLvl)) {
                     case Get.RETRY:
@@ -860,7 +831,7 @@ public abstract class BPlusTree<L, T extends L> {
 
         try {
             for (;;) {
-                initOperation(r);
+                r.initOperation();
 
                 switch (removeDown(r, r.rootId, 0L, 0L, r.rootLvl)) {
                     case Remove.RETRY:
@@ -1039,7 +1010,7 @@ public abstract class BPlusTree<L, T extends L> {
 
         try {
             for (;;) { // Go down with retries.
-                initOperation(p);
+                p.initOperation();
 
                 switch (putDown(p, p.rootId, 0L, p.rootLvl)) {
                     case Put.RETRY:
@@ -1361,13 +1332,13 @@ public abstract class BPlusTree<L, T extends L> {
         /** */
         long rmvId;
 
-        /** Starting point root level. May be outdated. Must be modified only 
in {@link #initOperation(Get)}. */
+        /** Starting point root level. May be outdated. Must be modified only 
in {@link Get#initOperation()}. */
         int rootLvl;
 
-        /** Starting point root ID. May be outdated. Must be modified only in 
{@link #initOperation(Get)}. */
+        /** Starting point root ID. May be outdated. Must be modified only in 
{@link Get#initOperation()}. */
         long rootId;
 
-        /** Meta page. Initialized by {@link #initOperation(Get)}, released by 
{@link Get#releaseMeta()}. */
+        /** Meta page. Initialized by {@link Get#initOperation()}, released by 
{@link Get#releaseMeta()}. */
         Page meta;
 
         /** */
@@ -1392,11 +1363,40 @@ public abstract class BPlusTree<L, T extends L> {
         }
 
         /**
+         * Initialize the given operation.
+         *
+         * !!! Symmetrically with this method must be called {@link 
Get#releaseMeta()} in {@code finally} block.
+         *
+         * @throws IgniteCheckedException If failed.
+         */
+        final void initOperation() throws IgniteCheckedException {
+            if (meta == null)
+                meta = page(metaPageId);
+
+            int rootLvl;
+            long rootId;
+
+            ByteBuffer buf = meta.getForRead();
+
+            try {
+                BPlusMetaIO io = BPlusMetaIO.VERSIONS.forPage(buf);
+
+                rootLvl = io.getRootLevel(buf);
+                rootId = io.getLeftmostPageId(buf, rootLvl);
+            }
+            finally {
+                meta.releaseRead();
+            }
+
+            restartFromRoot(rootId, rootLvl, globalRmvId.get());
+        }
+
+        /**
          * @param rootId Root page ID.
          * @param rootLvl Root level.
          * @param rmvId Remove ID to be afraid of.
          */
-        void restartFromRoot(long rootId, int rootLvl, long rmvId) {
+        final void restartFromRoot(long rootId, int rootLvl, long rmvId) {
             this.rootId = rootId;
             this.rootLvl = rootLvl;
             this.rmvId = rmvId;

Reply via email to