/** {@inheritDoc} */ @Override public int size() { try { GridCacheContext<Object, Object> cctx = cached.context(); KeyCacheObject key = cached.key(); byte[] keyBytes = key.valueBytes(cctx.cacheObjectContext()); byte[] valBytes = null; CacheObject cacheObj = cached.valueBytes(); if (cacheObj != null) valBytes = cacheObj.valueBytes(cctx.cacheObjectContext()); return valBytes == null ? keyBytes.length : keyBytes.length + valBytes.length; } catch (GridCacheEntryRemovedException ignored) { return 0; } catch (IgniteCheckedException e) { throw new IgniteException(e); } }
@Override public boolean applyx() { try { if (c.get(key) != null) return false; // Get "cache" field from GridCacheProxyImpl. GridCacheAdapter c0 = cacheFromCtx(c); if (!c0.context().deferredDelete()) { GridCacheEntryEx e0 = c0.entryEx(key); return e0 == null || (e0.rawGet() == null && e0.valueBytes() == null); } else return true; } catch (GridCacheEntryRemovedException e) { throw new RuntimeException(e); } } }, Math.min(ttl * 10, getTestTimeout())));
@Override public boolean applyx() { try { Integer val = c.get(key); if (val != null) { info("Value is in cache [key=" + key + ", val=" + val + ']'); return false; } // Get "cache" field from GridCacheProxyImpl. GridCacheAdapter c0 = cacheFromCtx(c); if (!c0.context().deferredDelete()) { GridCacheEntryEx e0 = c0.peekEx(key); return e0 == null || (e0.rawGet() == null && e0.valueBytes() == null); } else return true; } catch (GridCacheEntryRemovedException e) { throw new RuntimeException(e); } } }, Math.min(ttl * 10, getTestTimeout())));
@Override public boolean applyx() { try { Integer val = c.get(key); if (val != null) { info("Value is in cache [key=" + key + ", val=" + val + ']'); return false; } // Get "cache" field from GridCacheProxyImpl. GridCacheAdapter c0 = cacheFromCtx(c); if (!c0.context().deferredDelete()) { GridCacheEntryEx e0 = c0.peekEx(key); return e0 == null || (e0.rawGet() == null && e0.valueBytes() == null); } else return true; } catch (GridCacheEntryRemovedException e) { throw new RuntimeException(e); } } }, Math.min(ttl * 10, getTestTimeout())));
CacheObject val0 = entry.valueBytes(); CacheObject val0 = entry.valueBytes();
@Override public boolean applyx() throws IgniteCheckedException { try { Integer val = c.get(key); if (val != null) { info("Value is in cache [key=" + key + ", val=" + val + ']'); return false; } if (!internalCache(c).context().deferredDelete()) { GridCacheEntryEx e0 = internalCache(c).peekEx(key); return e0 == null || (e0.rawGet() == null && e0.valueBytes() == null); } else return true; } catch (GridCacheEntryRemovedException ignored) { // If e0.valueBytes() thrown this exception then entry has been removed. return true; } } }, Math.min(ttl * 10, getTestTimeout())));
/** * JUnit. * * @throws Exception If failed. */ @Test public void testEnabled() throws Exception { storeValBytes = true; Ignite g0 = startGrid(0); Ignite g1 = startGrid(1); IgniteCache<Integer, String> c = g0.cache(DEFAULT_CACHE_NAME); c.put(1, "Cached value"); GridCacheEntryEx entry = ((IgniteKernal)g1).internalCache(DEFAULT_CACHE_NAME).entryEx(1); assert entry != null; entry.unswap(); assert entry.valueBytes() != null; } }
val = e.valueBytes(null);
/** * @throws Exception If failed. */ @Test public void testPrimitiveValues() throws Exception { IgniteEx ignite = grid(0); IgniteCache<Object, Object> cache = ignite.cache(CACHE_NAME); for (int i = 0; i < 10; i++) cache.put(i, String.valueOf(i)); IgniteCacheObjectProcessor co = ignite.context().cacheObjects(); GridCacheAdapter<Object, Object> iCache = ignite.context().cache().internalCache(CACHE_NAME); GridCacheContext<Object, Object> cacheCtx = iCache.context(); CacheObjectContext coCtx = cacheCtx.cacheObjectContext(); ByteBuffer buf = ByteBuffer.allocate(2048); for (int i = 0; i < 10; i++) { KeyCacheObject key = co.toCacheKeyObject(coCtx, cacheCtx, i, false); GridCacheEntryEx entry = iCache.peekEx(key); assertNotNull(entry); assertTrue(entry.key().putValue(buf)); assertTrue(entry.valueBytes().putValue(buf)); } buf.flip(); for (int i = 0; i < 10; i++) { CacheObject co1 = co.toCacheObject(coCtx, buf); assertEquals((Integer)i, co1.value(coCtx, false)); CacheObject co2 = co.toCacheObject(coCtx, buf); assertEquals(String.valueOf(i), co2.value(coCtx, false)); } }
/** * @throws Exception If failed. */ @Test public void testClassValues() throws Exception { IgniteEx ignite = grid(0); IgniteCache<Object, Object> cache = ignite.cache(CACHE_NAME); for (int i = 0; i < 10; i++) cache.put(new TestValue(i), new TestValue(i)); IgniteCacheObjectProcessor co = ignite.context().cacheObjects(); GridCacheAdapter<Object, Object> iCache = ignite.context().cache().internalCache(CACHE_NAME); GridCacheContext<Object, Object> cacheCtx = iCache.context(); CacheObjectContext coCtx = cacheCtx.cacheObjectContext(); ByteBuffer buf = ByteBuffer.allocate(2048); for (int i = 0; i < 10; i++) { KeyCacheObject key = co.toCacheKeyObject(coCtx, cacheCtx, new TestValue(i), false); GridCacheEntryEx entry = iCache.peekEx(key); assertNotNull(entry); assertTrue(entry.key().putValue(buf)); assertTrue(entry.valueBytes().putValue(buf)); } buf.flip(); for (int i = 0; i < 10; i++) { CacheObject co1 = co.toCacheObject(coCtx, buf); assertEquals(new TestValue(i), co1.value(coCtx, false)); CacheObject co2 = co.toCacheObject(coCtx, buf); assertEquals(new TestValue(i), co2.value(coCtx, false)); } }
CacheObject val0 = cached.valueBytes(); CacheObject val0 = cached.valueBytes();
/** {@inheritDoc} */ @Override public int size() { try { GridCacheContext<Object, Object> cctx = cached.context(); KeyCacheObject key = cached.key(); byte[] keyBytes = key.valueBytes(cctx.cacheObjectContext()); byte[] valBytes = null; CacheObject cacheObj = cached.valueBytes(); if (cacheObj != null) valBytes = cacheObj.valueBytes(cctx.cacheObjectContext()); return valBytes == null ? keyBytes.length : keyBytes.length + valBytes.length; } catch (GridCacheEntryRemovedException ignored) { return 0; } catch (IgniteCheckedException e) { throw new IgniteException(e); } }
CacheObject val0 = entry.valueBytes(); CacheObject val0 = entry.valueBytes();
val = e.valueBytes(null);
CacheObject val0 = cached.valueBytes(); CacheObject val0 = cached.valueBytes();