Set proper partition for key during insert - Fixes
@@ -101,6 +101,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgnitePredicate;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX;
@@ -1646,7 +1647,7 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
@Nullable CacheDataRow oldRow) throws IgniteCheckedException {
int cacheId = grp.storeCacheIdInDataPage() ? cctx.cacheId() : CU.UNDEFINED_CACHE_ID;
- DataRow dataRow = new DataRow(key, val, ver, partId, expireTime, cacheId);
+ DataRow dataRow = makeDataRow(key, val, ver, expireTime, cacheId);
if (canUpdateOldRow(cctx, oldRow, dataRow) && rowStore.updateRow(oldRow.link(), dataRow))
dataRow.link(oldRow.link());
@@ -1667,6 +1668,22 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
return dataRow;
}
+ /**
+ * @param key Cache key.
+ * @param val Cache value.
+ * @param ver Version.
+ * @param expireTime Expired time.
+ * @param cacheId Cache id.
+ * @return Made data row.
+ */
+ @NotNull private DataRow makeDataRow(KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime,
+ int cacheId) {
+ if (key.partition() == -1)
+ key.partition(partId);
+
+ return new DataRow(key, val, ver, partId, expireTime, cacheId);
+ }
+
/** {@inheritDoc} */
@Override public boolean mvccInitialValue(
GridCacheContext cctx,
@@ -2342,10 +2359,7 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
assert oldRow == null || oldRow.cacheId() == cacheId : oldRow;
- if (key.partition() == -1)
- key.partition(partId);
-
- DataRow dataRow = new DataRow(key, val, ver, partId, expireTime, cacheId);
+ DataRow dataRow = makeDataRow(key, val, ver, expireTime, cacheId);
CacheObjectContext coCtx = cctx.cacheObjectContext();
