/** * @param buf Buffer to write to. * @param entry Data entry. */ void putPlainDataEntry(ByteBuffer buf, DataEntry entry) throws IgniteCheckedException { buf.putInt(entry.cacheId()); if (!entry.key().putValue(buf)) throw new AssertionError(); if (entry.value() == null) buf.putInt(-1); else if (!entry.value().putValue(buf)) throw new AssertionError(); buf.put((byte)entry.op().ordinal()); putVersion(buf, entry.nearXidVersion(), true); putVersion(buf, entry.writeVersion(), false); buf.putInt(entry.partitionId()); buf.putLong(entry.partitionCounter()); buf.putLong(entry.expireTime()); }
/** * @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)); } }
addr += row.key().putValue(addr);
/** * @param buf Buffer to write to. * @param entry Data entry. */ void putPlainDataEntry(ByteBuffer buf, DataEntry entry) throws IgniteCheckedException { buf.putInt(entry.cacheId()); if (!entry.key().putValue(buf)) throw new AssertionError(); if (entry.value() == null) buf.putInt(-1); else if (!entry.value().putValue(buf)) throw new AssertionError(); buf.put((byte)entry.op().ordinal()); putVersion(buf, entry.nearXidVersion(), true); putVersion(buf, entry.writeVersion(), false); buf.putInt(entry.partitionId()); buf.putLong(entry.partitionCounter()); buf.putLong(entry.expireTime()); }
addr += row.key().putValue(addr);