All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tinkerpop.rexster.gremlin.converter.MsgPackResultConverter Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
package com.tinkerpop.rexster.gremlin.converter;

import com.tinkerpop.rexster.protocol.serializer.msgpack.templates.ResultsConverter;
import org.msgpack.MessagePack;
import org.msgpack.packer.BufferPacker;

/**
 * Converts a result from Gremlin to a byte array encoded by MsgPack.
 *
 * @author Blake Eggleston (bdeggleston.github.com)
 */
public class MsgPackResultConverter implements ResultConverter {
    private final MessagePack msgpack = new MessagePack();

    public byte[] convert(final Object result) throws Exception {
        final BufferPacker packer = msgpack.createBufferPacker(1024);
        try {
            ResultsConverter.serializeObject(result, packer);
            return packer.toByteArray();
        } catch (Exception e) {
            throw e;
        } finally {
            packer.close();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy