use of org.apache.ignite.internal.processors.query.h2.H2RowCache in project ignite by apache.
the class H2RowCacheSelfTest method checkUpdateEntry.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
private void checkUpdateEntry() throws Exception {
final String cacheName = "cache";
grid().getOrCreateCache(cacheConfiguration(cacheName, true));
int grpId = grid().cachex(cacheName).context().groupId();
assertEquals(grpId, grid().cachex(cacheName).context().groupId());
fillCache(cacheName);
H2RowCache rowCache = rowCache(grid(), grpId);
fillRowCache(cacheName);
assertNotNull(rowCache);
int key = RND.nextInt(ENTRIES);
long rowLink = getLinkForKey(cacheName, rowCache, key);
int rowCacheSize = rowCache.size();
assertNotNull(rowCache.get(rowLink));
// Update row
grid().cache(cacheName).put(key, new Value(key + 1));
assertNull(rowCache.get(rowLink));
int rowCacheSizeAfterUpdate = rowCache.size();
assertEquals(rowCacheSize - 1, rowCacheSizeAfterUpdate);
// Check updated value.
List<Cache.Entry<Integer, Value>> res = grid().<Integer, Value>cache(cacheName).query(new SqlQuery(Value.class, "_key = " + key)).getAll();
assertEquals(1, res.size());
assertEquals(key + 1, (int) res.get(0).getValue().lVal);
}
Aggregations