|
17 | 17 |
|
18 | 18 | package org.apache.ignite.cache.query; |
19 | 19 |
|
| 20 | +import java.util.List; |
20 | 21 | import java.util.Objects; |
| 22 | +import javax.cache.Cache; |
21 | 23 | import org.apache.ignite.Ignite; |
22 | 24 | import org.apache.ignite.IgniteCache; |
23 | 25 | import org.apache.ignite.IgniteDataStreamer; |
24 | 26 | import org.apache.ignite.IgniteException; |
| 27 | +import org.apache.ignite.binary.BinaryObject; |
25 | 28 | import org.apache.ignite.cache.CacheMode; |
26 | 29 | import org.apache.ignite.cache.query.annotations.QuerySqlField; |
27 | 30 | import org.apache.ignite.configuration.CacheConfiguration; |
@@ -99,6 +102,44 @@ public void testServerNodePartitionedCache() { |
99 | 102 | assertEquals(CNT / 2, resultSize); |
100 | 103 | } |
101 | 104 |
|
| 105 | + /** Should return deserialized values for a cache that is not in keep-binary mode. */ |
| 106 | + @Test |
| 107 | + public void testLocalQueryReturnsDeserializedValues() { |
| 108 | + IgniteCache<Long, Person> cache = crd.createCache(ccfg(CacheMode.REPLICATED)); |
| 109 | + |
| 110 | + insertData(crd, cache); |
| 111 | + |
| 112 | + IndexQuery<Long, Person> qry = new IndexQuery<Long, Person>(Person.class, IDX) |
| 113 | + .setCriteria(lt("id", CNT / 2)); |
| 114 | + |
| 115 | + List<Cache.Entry<Long, Person>> res = cache.query(qry.setLocal(true)).getAll(); |
| 116 | + |
| 117 | + for (Cache.Entry<Long, Person> e : res) |
| 118 | + assertEquals(new Person(e.getKey().intValue()), e.getValue()); |
| 119 | + |
| 120 | + assertEquals(CNT / 2, res.size()); |
| 121 | + } |
| 122 | + |
| 123 | + /** Should keep binary values for a cache in keep-binary mode. */ |
| 124 | + @Test |
| 125 | + public void testLocalQueryKeepBinaryReturnsBinaryValues() { |
| 126 | + IgniteCache<Long, Person> cache = crd.createCache(ccfg(CacheMode.REPLICATED)); |
| 127 | + |
| 128 | + insertData(crd, cache); |
| 129 | + |
| 130 | + IgniteCache<Long, BinaryObject> binCache = cache.withKeepBinary(); |
| 131 | + |
| 132 | + IndexQuery<Long, BinaryObject> qry = new IndexQuery<Long, BinaryObject>(Person.class, IDX) |
| 133 | + .setCriteria(lt("id", CNT / 2)); |
| 134 | + |
| 135 | + List<Cache.Entry<Long, BinaryObject>> res = binCache.query(qry.setLocal(true)).getAll(); |
| 136 | + |
| 137 | + for (Cache.Entry<Long, BinaryObject> e : res) |
| 138 | + assertEquals(new Person(e.getKey().intValue()), e.getValue().deserialize()); |
| 139 | + |
| 140 | + assertEquals(CNT / 2, res.size()); |
| 141 | + } |
| 142 | + |
102 | 143 | /** Should fail as no data on nodes. */ |
103 | 144 | @Test |
104 | 145 | public void testClientNodeReplicatedCache() throws Exception { |
|
0 commit comments