Search in sources :

Example 11 with IgniteCacheObjectProcessor

use of org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor in project ignite by apache.

the class IgniteCacheObjectPutSelfTest method testPrimitiveValues.

/**
     * @throws Exception If failed.
     */
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));
    }
}
Also used : IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) IgniteEx(org.apache.ignite.internal.IgniteEx) ByteBuffer(java.nio.ByteBuffer)

Aggregations

IgniteCacheObjectProcessor (org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor)11 IgniteException (org.apache.ignite.IgniteException)3 IgniteKernal (org.apache.ignite.internal.IgniteKernal)3 ByteBuffer (java.nio.ByteBuffer)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 CacheObjectContext (org.apache.ignite.internal.processors.cache.CacheObjectContext)2 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)2 CacheObjectBinaryProcessorImpl (org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl)2 CreatedExpiryPolicy (javax.cache.expiry.CreatedExpiryPolicy)1 Duration (javax.cache.expiry.Duration)1 Ignite (org.apache.ignite.Ignite)1 IgniteIllegalStateException (org.apache.ignite.IgniteIllegalStateException)1 BinaryObject (org.apache.ignite.binary.BinaryObject)1 BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)1 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)1 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)1