Search in sources :

Example 46 with BinaryRawWriterEx

use of org.apache.ignite.internal.binary.BinaryRawWriterEx in project ignite by apache.

the class PlatformFutureUtils method writeToWriter.

/**
     * Write result to a custom writer
     *
     * @param obj Object to write.
     * @param err Error to write.
     * @param ctx Context.
     * @param writer Writer.
     * @param futPtr Future pointer.
     * @return Value indicating whether custom write was performed. When false, default write will be used.
     */
private static boolean writeToWriter(Object obj, Throwable err, PlatformContext ctx, Writer writer, long futPtr) {
    boolean canWrite = writer.canWrite(obj, err);
    if (!canWrite)
        return false;
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx outWriter = ctx.writer(out);
        writer.write(outWriter, obj, err);
        out.synchronize();
        ctx.gateway().futureObjectResult(futPtr, mem.pointer());
    }
    return true;
}
Also used : PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory)

Aggregations

BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)46 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)41 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)39 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)10 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IgniteException (org.apache.ignite.IgniteException)6 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 PlatformNativeException (org.apache.ignite.internal.processors.platform.PlatformNativeException)3 CacheEntryListenerException (javax.cache.event.CacheEntryListenerException)2 CacheLoaderException (javax.cache.integration.CacheLoaderException)2 PlatformContext (org.apache.ignite.internal.processors.platform.PlatformContext)2 PlatformExtendedException (org.apache.ignite.internal.processors.platform.PlatformExtendedException)2 PlatformTargetProxyImpl (org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl)2 Nullable (org.jetbrains.annotations.Nullable)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1