ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject ignite git commit: IGNITE-6641 Improved partition ID handling for links - Fixes #2866.
Date Fri, 27 Oct 2017 15:32:41 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 031f63c2e -> 007c579c4


IGNITE-6641 Improved partition ID handling for links - Fixes #2866.

Signed-off-by: Alexey Goncharuk <alexey.goncharuk@gmail.com>


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

Branch: refs/heads/master
Commit: 007c579c48e5361858ca5f5f77eae28034fe611b
Parents: 031f63c
Author: Sergey Chugunov <sergey.chugunov@gmail.com>
Authored: Fri Oct 27 18:31:49 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Fri Oct 27 18:31:49 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/pagemem/PageIdUtils.java     | 19 +++++++++++++++++++
 .../cache/persistence/freelist/FreeListImpl.java | 18 ++++++++++++++++--
 .../cache/persistence/tree/io/DataPageIO.java    | 17 +++++++++++++++--
 3 files changed, 50 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/007c579c/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 d47f2de..2754d79 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
@@ -191,6 +191,14 @@ public final class PageIdUtils {
     }
 
     /**
+     * Masks partition ID from full page ID.
+     * @param pageId Page ID to mask partition ID from.
+     */
+    public static long maskPartitionId(long pageId) {
+        return pageId & ~((-1L << PAGE_IDX_SIZE) & (~(-1L << PAGE_IDX_SIZE
+ PART_ID_SIZE)));
+    }
+
+    /**
      * Change page type.
      *
      * @param pageId Old page ID.
@@ -213,4 +221,15 @@ public final class PageIdUtils {
             ")"
             ;
     }
+
+    /**
+     * @param pageId Page ID.
+     * @param partId Partition ID.
+     */
+    public static long changePartitionId(long pageId, int partId) {
+        byte flag = flag(pageId);
+        int pageIdx = pageIndex(pageId);
+
+        return pageId(partId, flag, pageIdx);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/007c579c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
index 6a87d3e..5bacc53 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
@@ -191,7 +191,7 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
             CacheDataRow row,
             int rowSize
         ) throws IgniteCheckedException {
-            io.addRow(pageAddr, row, rowSize, pageSize());
+            io.addRow(pageId, pageAddr, row, rowSize, pageSize());
 
             if (needWalDeltaRecord(pageId, page, null)) {
                 // TODO IGNITE-5829 This record must contain only a reference to a logical
WAL record with the actual data.
@@ -256,12 +256,20 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
 
 
     /** */
-    private final PageHandler<Void, Long> rmvRow = new RemoveRowHandler();
+    private final PageHandler<Void, Long> rmvRow;
 
     /**
      *
      */
     private final class RemoveRowHandler extends PageHandler<Void, Long> {
+        /** Indicates whether partition ID should be masked from page ID. */
+        private final boolean maskPartId;
+
+        /** */
+        RemoveRowHandler(boolean maskPartId) {
+            this.maskPartId = maskPartId;
+        }
+
         @Override public Long run(
             int cacheId,
             long pageId,
@@ -293,6 +301,7 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
 
                     if (oldBucket != newBucket) {
                         // It is possible that page was concurrently taken for put, in this
case put will handle bucket change.
+                        pageId = maskPartId ? PageIdUtils.maskPartitionId(pageId) : pageId;
                         if (removeDataPage(pageId, page, pageAddr, io, oldBucket))
                             put(null, pageId, page, pageAddr, newBucket);
                     }
@@ -330,6 +339,9 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
         long metaPageId,
         boolean initNew) throws IgniteCheckedException {
         super(cacheId, name, memPlc.pageMemory(), BUCKETS, wal, metaPageId);
+
+        rmvRow = new RemoveRowHandler(cacheId == 0);
+
         this.evictionTracker = memPlc.evictionTracker();
         this.reuseList = reuseList == null ? this : reuseList;
         int pageSize = pageMem.pageSize();
@@ -492,6 +504,8 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
 
             if (allocated)
                 pageId = allocateDataPage(row.partition());
+            else
+                pageId = PageIdUtils.changePartitionId(pageId, (row.partition()));
 
             DataPageIO init = reuseBucket || allocated ? DataPageIO.VERSIONS.latest() : null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/007c579c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
index 628ff38..173ed66 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
@@ -775,6 +775,7 @@ public class DataPageIO extends PageIO {
     /**
      * Adds row to this data page and sets respective link to the given row object.
      *
+     * @param pageId page ID.
      * @param pageAddr Page address.
      * @param row Cache data row.
      * @param rowSize Row size.
@@ -782,6 +783,7 @@ public class DataPageIO extends PageIO {
      * @throws IgniteCheckedException If failed.
      */
     public void addRow(
+        final long pageId,
         final long pageAddr,
         CacheDataRow row,
         final int rowSize,
@@ -800,7 +802,7 @@ public class DataPageIO extends PageIO {
 
         int itemId = addItem(pageAddr, fullEntrySize, directCnt, indirectCnt, dataOff, pageSize);
 
-        setLink(row, pageAddr, itemId);
+        setLinkByPageId(row, pageId, itemId);
     }
 
     /**
@@ -1021,7 +1023,18 @@ public class DataPageIO extends PageIO {
      * @param itemId Item ID.
      */
     private void setLink(CacheDataRow row, long pageAddr, int itemId) {
-        row.link(PageIdUtils.link(getPageId(pageAddr), itemId));
+        long pageId = getPageId(pageAddr);
+
+        setLinkByPageId(row, pageId, itemId);
+    }
+
+    /**
+     * @param row Row to set link to.
+     * @param pageId Page ID.
+     * @param itemId Item ID.
+     */
+    private void setLinkByPageId(CacheDataRow row, long pageId, int itemId) {
+        row.link(PageIdUtils.link(pageId, itemId));
     }
 
     /**


Mime
View raw message