ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [3/8] ignite git commit: ignite-5075 Fixed row size calculation in canUpdateOldRow
Date Fri, 07 Jul 2017 10:33:14 GMT
ignite-5075 Fixed row size calculation in canUpdateOldRow


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

Branch: refs/heads/ignite-gg-12306-1
Commit: 3259e2bb9d6532dd78e71314dc55a7a021090f36
Parents: 0b4b5dc
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Jul 7 11:27:31 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Jul 7 11:27:31 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/IgniteCacheOffheapManagerImpl.java  |  7 +++++--
 .../cache/persistence/freelist/FreeListImpl.java         | 11 ++++++-----
 2 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3259e2bb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index b51fc10..6d16b60 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -1179,12 +1179,15 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
             if (oldRow.expireTime() != dataRow.expireTime())
                 return false;
 
-            int oldLen = FreeListImpl.getRowSize(oldRow);
+            // Use grp.sharedGroup() flag since it is possible cacheId is not yet set here.
+            boolean sizeWithCacheId = grp.sharedGroup();
+
+            int oldLen = FreeListImpl.getRowSize(oldRow, sizeWithCacheId);
 
             if (oldLen > updateValSizeThreshold)
                 return false;
 
-            int newLen = FreeListImpl.getRowSize(dataRow);
+            int newLen = FreeListImpl.getRowSize(dataRow, sizeWithCacheId);
 
             return oldLen == newLen;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3259e2bb/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 139c6f3..844bc02 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
@@ -101,7 +101,7 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
             throws IgniteCheckedException {
             DataPageIO io = (DataPageIO)iox;
 
-            int rowSize = getRowSize(row);
+            int rowSize = getRowSize(row, row.cacheId() != 0);
 
             boolean updated = io.updateRow(pageAddr, itemId, pageSize(), null, row, rowSize);
 
@@ -147,7 +147,7 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
             throws IgniteCheckedException {
             DataPageIO io = (DataPageIO)iox;
 
-            int rowSize = getRowSize(row);
+            int rowSize = getRowSize(row, row.cacheId() != 0);
             int oldFreeSpace = io.getFreeSpace(pageAddr);
 
             assert oldFreeSpace > 0 : oldFreeSpace;
@@ -453,7 +453,7 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
 
     /** {@inheritDoc} */
     @Override public void insertDataRow(CacheDataRow row) throws IgniteCheckedException {
-        int rowSize = getRowSize(row);
+        int rowSize = getRowSize(row, row.cacheId() != 0);
 
         int written = 0;
 
@@ -579,17 +579,18 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
 
     /**
      * @param row Row.
+     * @param withCacheId If {@code true} adds cache ID size.
      * @return Entry size on page.
      * @throws IgniteCheckedException If failed.
      */
-    public static int getRowSize(CacheDataRow row) throws IgniteCheckedException {
+    public static int getRowSize(CacheDataRow row, boolean withCacheId) throws IgniteCheckedException
{
         KeyCacheObject key = row.key();
         CacheObject val = row.value();
 
         int keyLen = key.valueBytesLength(null);
         int valLen = val.valueBytesLength(null);
 
-        return keyLen + valLen + CacheVersionIO.size(row.version(), false) + 8 + (row.cacheId()
== 0 ? 0 : 4);
+        return keyLen + valLen + CacheVersionIO.size(row.version(), false) + 8 + (withCacheId
? 4 : 0);
     }
 
     /** {@inheritDoc} */


Mime
View raw message