You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2018/11/28 11:53:07 UTC
[36/50] [abbrv] ignite git commit: IGNITE-7072: IgniteCache.replace(k, v,
nv) fix for binary mode
IGNITE-7072: IgniteCache.replace(k, v, nv) fix for binary mode
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/23de7435
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/23de7435
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/23de7435
Branch: refs/heads/ignite-9720
Commit: 23de74357483aa2979b54ea4e54254ef0d2f3637
Parents: 882b5a4
Author: Igor Sapego <is...@apache.org>
Authored: Tue Nov 27 19:26:26 2018 +0300
Committer: Igor Sapego <is...@apache.org>
Committed: Tue Nov 27 19:28:01 2018 +0300
----------------------------------------------------------------------
.../cache/CacheEntryPredicateContainsValue.java | 4 ++
.../GridCacheBinaryObjectsAbstractSelfTest.java | 58 ++++++++++++++++++++
2 files changed, 62 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/23de7435/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
index 73a98b7..ad9861c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -60,6 +61,9 @@ public class CacheEntryPredicateContainsValue extends CacheEntryPredicateAdapter
GridCacheContext cctx = e.context();
+ if (this.val instanceof BinaryObject && val instanceof BinaryObject)
+ return F.eq(val, this.val);
+
Object thisVal = CU.value(this.val, cctx, false);
Object cacheVal = CU.value(val, cctx, false);
http://git-wip-us.apache.org/repos/asf/ignite/blob/23de7435/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
index 00a3181..98e906f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
@@ -290,6 +290,64 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
/**
* @throws Exception If failed.
*/
+ public void testReplace() throws Exception {
+ IgniteCache<Integer, TestObject> c = jcache(0);
+
+ for (int i = 0; i < ENTRY_CNT; i++)
+ c.put(i, new TestObject(i));
+
+ for (int i = 0; i < ENTRY_CNT; i++) {
+ TestObject obj = c.get(i);
+
+ assertEquals(i, obj.val);
+ }
+
+ IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();
+
+ BinaryObjectBuilder bldr = grid(0).binary().builder(TestObject.class.getName());
+
+ bldr.setField("val", -42);
+
+ BinaryObject testObj = bldr.build();
+
+ for (int i = 0; i < ENTRY_CNT; i++) {
+ BinaryObject po = kpc.get(i);
+
+ assertEquals(i, (int)po.field("val"));
+
+ assertTrue(kpc.replace(i, po, testObj));
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRemove() throws Exception {
+ IgniteCache<Integer, TestObject> c = jcache(0);
+
+ for (int i = 0; i < ENTRY_CNT; i++)
+ c.put(i, new TestObject(i));
+
+ for (int i = 0; i < ENTRY_CNT; i++) {
+ TestObject obj = c.get(i);
+
+ assertEquals(i, obj.val);
+ }
+
+ IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();
+
+ for (int i = 0; i < ENTRY_CNT; i++) {
+ BinaryObject po = kpc.get(i);
+
+ assertEquals(i, (int)po.field("val"));
+
+ assertTrue(kpc.remove(i, po));
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testIterator() throws Exception {
IgniteCache<Integer, TestObject> c = jcache(0);