ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [09/16] ignite git commit: ignite-db - minor refactoring
Date Wed, 04 May 2016 06:01:47 GMT
ignite-db - minor refactoring


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

Branch: refs/heads/ignite-db-x-10884
Commit: 9a307f13d6c4d4f03d52d4df191034b7de715234
Parents: 86b9fa8
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Fri Apr 29 04:44:28 2016 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Fri Apr 29 04:44:28 2016 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/pagemem/PageIdUtils.java | 16 ++++++++--------
 .../internal/pagemem/impl/PageMemoryImpl.java       |  2 +-
 .../cache/database/freelist/FreeTree.java           |  2 +-
 .../cache/database/freelist/io/FreeInnerIO.java     |  2 +-
 .../cache/database/freelist/io/FreeLeafIO.java      |  2 +-
 .../cache/database/tree/reuse/ReuseTree.java        |  4 ++--
 .../cache/database/tree/reuse/io/ReuseInnerIO.java  |  4 ++--
 .../cache/database/tree/reuse/io/ReuseLeafIO.java   |  2 +-
 8 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9a307f13/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java
index 956634a..c5130f5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdUtils.java
@@ -50,14 +50,14 @@ public final class PageIdUtils {
     private static final long OFFSET_MASK = ~(-1 << OFFSET_SIZE);
 
     /** */
-    private static final int PART_ID_MASK = ~(-1 << PART_ID_SIZE);
+    private static final long PART_ID_MASK = ~(-1 << PART_ID_SIZE);
 
     /** */
-    private static final int FLAG_MASK = ~(-1 << FLAG_SIZE);
+    private static final long FLAG_MASK = ~(-1 << FLAG_SIZE);
 
     /** */
     private static final long EFFECTIVE_NON_DATA_PAGE_ID_MASK =
-        ((long)FLAG_MASK << (PAGE_IDX_SIZE + PART_ID_SIZE)) | PAGE_IDX_MASK;
+        (FLAG_MASK << (PAGE_IDX_SIZE + PART_ID_SIZE)) | PAGE_IDX_MASK;
 
     /** Maximum page number. */
     public static final int MAX_PAGE_NUM = (1 << PAGE_IDX_SIZE) - 1;
@@ -131,7 +131,7 @@ public final class PageIdUtils {
      * @param pageId Page id.
      * @return Page ID.
      */
-    public static int pageIdx(long pageId) {
+    public static int pageIndex(long pageId) {
         return (int)(pageId & PAGE_IDX_MASK); // 30 bytes
     }
 
@@ -188,12 +188,12 @@ public final class PageIdUtils {
      * @return Part ID constructed from the given cache ID and partition ID.
      */
     public static long pageId(int partId, byte flag, long pageIdx) {
-        int fileId = 0;
+        long fileId = 0;
 
         fileId = (fileId << FLAG_SIZE) | (flag & FLAG_MASK);
         fileId = (fileId << PART_ID_SIZE) | (partId & PART_ID_MASK);
 
-        return pageId(fileId, pageIdx);
+        return pageId((int)fileId, pageIdx);
     }
 
     /**
@@ -220,7 +220,7 @@ public final class PageIdUtils {
         assert flag(pageId) == PageIdAllocator.FLAG_IDX; // Possible only for index pages.
 
         int partId = partId(pageId);
-        long pageIdx = pageIdx(pageId);
+        long pageIdx = pageIndex(pageId);
 
         return pageId(partId + 1, PageIdAllocator.FLAG_IDX, pageIdx);
     }
@@ -232,6 +232,6 @@ public final class PageIdUtils {
     public static long maskPartId(long pageId) {
         assert flag(pageId) == PageIdAllocator.FLAG_IDX; // Possible only for index pages.
 
-        return pageId & ~((long)PART_ID_MASK << PAGE_IDX_SIZE);
+        return pageId & ~(PART_ID_MASK << PAGE_IDX_SIZE);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a307f13/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryImpl.java
index 56160f2..1f91967 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryImpl.java
@@ -216,7 +216,7 @@ public class  PageMemoryImpl implements PageMemory {
 
             pageId = readPageId(absPtr);
 
-            long idx = PageIdUtils.pageIdx(pageId);
+            long idx = PageIdUtils.pageIndex(pageId);
 
             // Reassign page ID according to flags and partition ID.
             pageId = PageIdUtils.pageId(partId, flags, idx);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a307f13/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeTree.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeTree.java
index ca769e7..14477c8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeTree.java
@@ -69,7 +69,7 @@ public class FreeTree extends BPlusTree<FreeItem, FreeItem> {
         int res = Short.compare(((FreeIO)io).getFreeSpace(buf, idx), row.freeSpace());
 
         if (res == 0)
-            res = Integer.compare(((FreeIO)io).getPageIndex(buf, idx), PageIdUtils.pageIdx(row.pageId()));
+            res = Integer.compare(((FreeIO)io).getPageIndex(buf, idx), PageIdUtils.pageIndex(row.pageId()));
 
         return res;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a307f13/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeInnerIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeInnerIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeInnerIO.java
index 9082965..8bfbdc8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeInnerIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeInnerIO.java
@@ -31,7 +31,7 @@ public class FreeInnerIO extends BPlusInnerIO<FreeItem> implements
FreeIO {
         int off = offset(idx);
 
         buf.putShort(off, row.freeSpace());
-        buf.putInt(off + 2, PageIdUtils.pageIdx(row.pageId()));
+        buf.putInt(off + 2, PageIdUtils.pageIndex(row.pageId()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a307f13/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
index 210f0ba..6dca626 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/io/FreeLeafIO.java
@@ -49,7 +49,7 @@ public class FreeLeafIO extends BPlusLeafIO<FreeItem> implements FreeIO
{
         int off = offset(idx);
 
         buf.putShort(off, row.freeSpace());
-        buf.putInt(off + 2, PageIdUtils.pageIdx(row.pageId()));
+        buf.putInt(off + 2, PageIdUtils.pageIndex(row.pageId()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a307f13/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
index fa8aa11..7cdf290 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/ReuseTree.java
@@ -51,7 +51,7 @@ public final class ReuseTree extends BPlusTree<Number, Long> {
     @Override protected int compare(BPlusIO<Number> io, ByteBuffer buf, int idx, Number
row)
         throws IgniteCheckedException {
         int pageIdx = io.isLeaf() ?
-            PageIdUtils.pageIdx(((ReuseLeafIO)io).getPageId(buf, idx)) :
+            PageIdUtils.pageIndex(((ReuseLeafIO)io).getPageId(buf, idx)) :
             (((ReuseInnerIO)io).getPageIndex(buf, idx));
 
         return Integer.compare(pageIdx, toPageIndex(row));
@@ -65,7 +65,7 @@ public final class ReuseTree extends BPlusTree<Number, Long> {
         if (row.getClass() == Integer.class)
             return row.intValue();
 
-        return PageIdUtils.pageIdx(row.longValue());
+        return PageIdUtils.pageIndex(row.longValue());
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a307f13/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
index db3914d..61eae17 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseInnerIO.java
@@ -44,7 +44,7 @@ public final class ReuseInnerIO extends BPlusInnerIO<Number> {
     /** {@inheritDoc} */
     @Override public void store(ByteBuffer dst, int dstIdx, BPlusIO<Number> srcIo,
ByteBuffer src, int srcIdx) {
         int pageIdx = srcIo.isLeaf() ?
-            PageIdUtils.pageIdx(((ReuseLeafIO)srcIo).getPageId(src, srcIdx)) :
+            PageIdUtils.pageIndex(((ReuseLeafIO)srcIo).getPageId(src, srcIdx)) :
             ((ReuseInnerIO)srcIo).getPageIndex(src, srcIdx);
 
         store(dst, dstIdx, pageIdx);
@@ -71,7 +71,7 @@ public final class ReuseInnerIO extends BPlusInnerIO<Number> {
     /** {@inheritDoc} */
     @Override public void store(ByteBuffer buf, int idx, Number row) {
         store(buf, idx, row.getClass() == Integer.class ? row.intValue() :
-            PageIdUtils.pageIdx(row.longValue()));
+            PageIdUtils.pageIndex(row.longValue()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/9a307f13/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
index 5bf47ce..bfc6776 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/reuse/io/ReuseLeafIO.java
@@ -37,7 +37,7 @@ public final class ReuseLeafIO extends BPlusLeafIO<Number> {
      * @param ver Page format version.
      */
     protected ReuseLeafIO(int ver) {
-        super(T_REUSE_LEAF, ver, 8); // TODO we can store only 6 bytes here: pageIdx(4) +
partId(2)
+        super(T_REUSE_LEAF, ver, 8); // TODO we can store only 6 bytes here: pageIndex(4)
+ partId(2)
     }
 
     /** {@inheritDoc} */


Mime
View raw message