ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [46/50] [abbrv] ignite git commit: ignite-db - refactor
Date Tue, 19 Apr 2016 12:59:03 GMT
ignite-db - refactor


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

Branch: refs/heads/ignite-db-x-10884
Commit: 335184057b07ceef6c458b3e4abf44808ec487df
Parents: 05ec378
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Mon Apr 18 05:10:33 2016 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Mon Apr 18 05:10:33 2016 +0300

----------------------------------------------------------------------
 .../cache/database/tree/BPlusTree.java          | 46 ++++++++++++++------
 .../processors/query/h2/database/H2Tree.java    | 25 +----------
 .../query/h2/database/freelist/FreeList.java    |  2 +-
 .../query/h2/database/freelist/FreeTree.java    | 40 +++--------------
 4 files changed, 41 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/33518405/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 e3dec3d..9d3c995 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
@@ -29,6 +29,8 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.IgniteInterruptedCheckedException;
 import org.apache.ignite.internal.pagemem.FullPageId;
 import org.apache.ignite.internal.pagemem.Page;
+import org.apache.ignite.internal.pagemem.PageIdAllocator;
+import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusInnerIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusLeafIO;
@@ -60,6 +62,12 @@ public abstract class BPlusTree<L, T extends L> {
     private static final byte DONE = 3;
 
     /** */
+    protected final int cacheId;
+
+    /** */
+    private final PageMemory pageMem;
+
+    /** */
     private final float minFill;
 
     /** */
@@ -465,14 +473,20 @@ public abstract class BPlusTree<L, T extends L> {
     };
 
     /**
+     * @param cacheId Cache ID.
+     * @param pageMem Page memory.
      * @param metaPageId Meta page ID.
      * @throws IgniteCheckedException If failed.
      */
-    public BPlusTree(FullPageId metaPageId) throws IgniteCheckedException {
+    public BPlusTree(int cacheId, PageMemory pageMem, FullPageId metaPageId) throws IgniteCheckedException
{
         // TODO make configurable: 0 <= minFill <= maxFill <= 1
         minFill = 0f; // Testing worst case when merge happens only on empty page.
         maxFill = 0f; // Avoiding random effects on testing.
 
+        assert pageMem != null;
+
+        this.pageMem = pageMem;
+        this.cacheId = cacheId;
         this.metaPageId = metaPageId.pageId();
     }
 
@@ -2243,6 +2257,24 @@ public abstract class BPlusTree<L, T extends L> {
     }
 
     /**
+     * @param pageId Page ID.
+     * @return Page.
+     * @throws IgniteCheckedException If failed.
+     */
+    private Page page(long pageId) throws IgniteCheckedException {
+        return pageMem.page(new FullPageId(pageId, cacheId));
+    }
+
+    /**
+     * @return Allocated page.
+     */
+    private Page allocatePage() throws IgniteCheckedException {
+        FullPageId pageId = pageMem.allocatePage(cacheId, -1, PageIdAllocator.FLAG_IDX);
+
+        return pageMem.page(pageId);
+    }
+
+    /**
      * @param type Page type.
      * @param ver Page version.
      * @return IO.
@@ -2280,18 +2312,6 @@ public abstract class BPlusTree<L, T extends L> {
     protected abstract T getRow(BPlusIO<L> io, ByteBuffer buf, int idx) throws IgniteCheckedException;
 
     /**
-     * @param pageId Page ID.
-     * @return Page.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected abstract Page page(long pageId) throws IgniteCheckedException;
-
-    /**
-     * @return Allocated page.
-     */
-    protected abstract Page allocatePage() throws IgniteCheckedException;
-
-    /**
      * Forward cursor.
      */
     protected class ForwardCursor implements GridCursor<T> {

http://git-wip-us.apache.org/repos/asf/ignite/blob/33518405/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
index 474b4b5..fdde460 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java
@@ -3,8 +3,6 @@ package org.apache.ignite.internal.processors.query.h2.database;
 import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.Page;
-import org.apache.ignite.internal.pagemem.PageIdAllocator;
 import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.processors.cache.database.tree.BPlusTree;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
@@ -20,14 +18,8 @@ import org.h2.result.SearchRow;
  */
 public abstract class H2Tree extends BPlusTree<SearchRow, GridH2Row> {
     /** */
-    private final int cacheId;
-
-    /** */
     private final H2RowStore rowStore;
 
-    /** */
-    private final PageMemory pageMem;
-
     /**
      * @param cacheId Cache ID.
      * @param pageMem Page memory.
@@ -38,13 +30,10 @@ public abstract class H2Tree extends BPlusTree<SearchRow, GridH2Row>
{
      */
     public H2Tree(int cacheId, PageMemory pageMem, H2RowStore rowStore, FullPageId metaPageId,
boolean initNew)
         throws IgniteCheckedException {
-        super(metaPageId);
+        super(cacheId, pageMem, metaPageId);
 
-        assert pageMem != null;
         assert rowStore != null;
 
-        this.cacheId = cacheId;
-        this.pageMem = pageMem;
         this.rowStore = rowStore;
 
         if (initNew)
@@ -59,18 +48,6 @@ public abstract class H2Tree extends BPlusTree<SearchRow, GridH2Row>
{
     }
 
     /** {@inheritDoc} */
-    @Override protected Page page(long pageId) throws IgniteCheckedException {
-        return pageMem.page(new FullPageId(pageId, cacheId));
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Page allocatePage() throws IgniteCheckedException {
-        FullPageId pageId = pageMem.allocatePage(cacheId, -1, PageIdAllocator.FLAG_IDX);
-
-        return pageMem.page(pageId);
-    }
-
-    /** {@inheritDoc} */
     @Override protected BPlusIO<SearchRow> io(int type, int ver) {
         if (type == PageIO.T_H2_REF_INNER)
             return H2InnerIO.VERSIONS.forVersion(ver);

http://git-wip-us.apache.org/repos/asf/ignite/blob/33518405/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeList.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeList.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeList.java
index dfde231..43b0dcc 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeList.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeList.java
@@ -119,7 +119,7 @@ public class FreeList {
                 IgniteBiTuple<FullPageId,Boolean> t = cctx.shared().database().meta()
                     .getOrAllocateForIndex(cctx.cacheId(), idxName);
 
-                fut.onDone(new FreeTree(pageMem, cctx.cacheId(), part, t.get1(), t.get2()));
+                fut.onDone(new FreeTree(cctx.cacheId(), pageMem, t.get1(), t.get2()));
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/33518405/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeTree.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeTree.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeTree.java
index a8a836b..8eccfd6 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeTree.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/freelist/FreeTree.java
@@ -20,49 +20,33 @@ package org.apache.ignite.internal.processors.query.h2.database.freelist;
 import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.Page;
-import org.apache.ignite.internal.pagemem.PageIdAllocator;
 import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.processors.query.h2.database.freelist.io.FreeIO;
-import org.apache.ignite.internal.processors.query.h2.database.freelist.io.FreeInnerIO;
-import org.apache.ignite.internal.processors.query.h2.database.freelist.io.FreeLeafIO;
 import org.apache.ignite.internal.processors.cache.database.tree.BPlusTree;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusInnerIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.BPlusLeafIO;
 import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
+import org.apache.ignite.internal.processors.query.h2.database.freelist.io.FreeIO;
+import org.apache.ignite.internal.processors.query.h2.database.freelist.io.FreeInnerIO;
+import org.apache.ignite.internal.processors.query.h2.database.freelist.io.FreeLeafIO;
 
 /**
  * Data structure for data pages and their free spaces.
  */
 public class FreeTree extends BPlusTree<FreeItem, FreeItem> {
-    /** */
-    private PageMemory pageMem;
-
-    /** */
-    private int cacheId;
-
-    /** */
-    private int part;
-
     /**
-     * @param pageMem Page memory.
      * @param cacheId Cache ID.
-     * @param part Partition.
+     * @param pageMem Page memory.
      * @param metaPageId Meta page ID.
      * @param initNew    Initialize new index.
      * @throws IgniteCheckedException If failed.
      */
-    public FreeTree(PageMemory pageMem, int cacheId, int part, FullPageId metaPageId, boolean
initNew)
+    public FreeTree(int cacheId, PageMemory pageMem, FullPageId metaPageId, boolean initNew)
         throws IgniteCheckedException {
-        super(metaPageId);
+        super(cacheId, pageMem, metaPageId);
 
         assert pageMem != null;
 
-        this.pageMem = pageMem;
-        this.cacheId = cacheId;
-        this.part = part;
-
         if (initNew)
             initNew();
     }
@@ -110,18 +94,6 @@ public class FreeTree extends BPlusTree<FreeItem, FreeItem> {
         return row;
     }
 
-    /** {@inheritDoc} */
-    @Override protected Page page(long pageId) throws IgniteCheckedException {
-        return pageMem.page(new FullPageId(pageId, cacheId));
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Page allocatePage() throws IgniteCheckedException {
-        FullPageId pageId = pageMem.allocatePage(cacheId, part, PageIdAllocator.FLAG_IDX);
-
-        return pageMem.page(pageId);
-    }
-
     /**
      * @return Cache ID.
      */


Mime
View raw message