当前位置: 首页>>代码示例>>Java>>正文


Java MessageUnpacker.close方法代码示例

本文整理汇总了Java中org.msgpack.core.MessageUnpacker.close方法的典型用法代码示例。如果您正苦于以下问题:Java MessageUnpacker.close方法的具体用法?Java MessageUnpacker.close怎么用?Java MessageUnpacker.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.msgpack.core.MessageUnpacker的用法示例。


在下文中一共展示了MessageUnpacker.close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mergeFrom

import org.msgpack.core.MessageUnpacker; //导入方法依赖的package包/类
/**
 * Merges the {@code message} with the byte array using the given {@code schema}.
 */
public static <T> void mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean numeric)
        throws IOException
{

    ArrayBufferInput bios = new ArrayBufferInput(data, offset, length);

    MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(bios);

    try
    {
        mergeFrom(unpacker, message, schema, numeric);
    }
    finally
    {
        unpacker.close();
    }
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:21,代码来源:MsgpackIOUtil.java

示例2: close

import org.msgpack.core.MessageUnpacker; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
    try {
        MessageUnpacker messageUnpacker = getMessageUnpacker();
        messageUnpacker.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        isClosed = true;
    }
}
 
开发者ID:komamitsu,项目名称:jackson-dataformat-msgpack,代码行数:14,代码来源:MessagePackParser.java

示例3: next

import org.msgpack.core.MessageUnpacker; //导入方法依赖的package包/类
@Override
public KeyValue next() throws IOException {
    if (mReader.next(mKey, mValue)) {
        MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(mKey.getBytes());
        int mapSize = unpacker.unpackMapHeader();
        long offset = 0;
        long timestamp = -1;
        byte[] keyBytes = EMPTY_BYTES;
        for (int i = 0; i < mapSize; i++) {
            int key = unpacker.unpackInt();
            switch (key) {
                case KAFKA_MESSAGE_OFFSET:
                    offset = unpacker.unpackLong();
                    break;
                case KAFKA_MESSAGE_TIMESTAMP:
                    timestamp = unpacker.unpackLong();
                    break;
                case KAFKA_HASH_KEY:
                    int keySize = unpacker.unpackBinaryHeader();
                    keyBytes = new byte[keySize];
                    unpacker.readPayload(keyBytes);
                    break;
            }
        }
        unpacker.close();
        return new KeyValue(offset, keyBytes, Arrays.copyOfRange(mValue.getBytes(), 0, mValue.getLength()), timestamp);
    } else {
        return null;
    }
}
 
开发者ID:pinterest,项目名称:secor,代码行数:31,代码来源:MessagePackSequenceFileReaderWriterFactory.java

示例4: parseListFrom

import org.msgpack.core.MessageUnpacker; //导入方法依赖的package包/类
/**
 * Parses the {@code messages} from the stream using the given {@code schema}.
 */
public static <T> List<T> parseListFrom(MessageBufferInput in, Schema<T> schema, boolean numeric) throws IOException
{

    MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(in);

    try
    {
        return parseListFrom(unpacker, schema, numeric);
    }
    finally
    {
        unpacker.close();
    }
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:18,代码来源:MsgpackIOUtil.java

示例5: Message

import org.msgpack.core.MessageUnpacker; //导入方法依赖的package包/类
protected Message(byte[] bytes) throws IOException {

        MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(bytes);

        int arrayHeader = unpacker.unpackArrayHeader();
        this.type = unpacker.unpackString();
        // unpack data
        if (unpacker.getNextFormat() != MessageFormat.NIL) {
            int mapSize = unpacker.unpackMapHeader();
            this.data = new HashMap<String, Object>(6);
            while (mapSize > 0) {
                String key = null;
                // unpack key
                if (unpacker.getNextFormat() == MessageFormat.NIL) {
                    unpacker.unpackNil();
                } else {
                    key = unpacker.unpackString();
                }
                // unpack value
                MessageFormat messageFormat = unpacker.getNextFormat();
                Object value;

                switch (messageFormat.getValueType()) {
                    case BOOLEAN:
                        value = unpacker.unpackBoolean();
                        break;
                    case FLOAT:
                        value = unpacker.unpackFloat();
                        break;
                    case INTEGER:
                        value = unpacker.unpackInt();
                        break;
                    case NIL:
                        value = null;
                        unpacker.unpackNil();
                        break;
                    case STRING:
                        value = unpacker.unpackString();
                        break;
                    default:
                        throw new IOException("Message received unsupported type: " + messageFormat.getValueType());
                }
                if (null != key) {
                    this.data.put(key, value);
                }
                mapSize--;
            }

        } else {
            this.data = null;
        }
        if (unpacker.getNextFormat() != MessageFormat.NIL) {
            this.nodeID = unpacker.unpackString();
        } else {
            unpacker.unpackNil();
            this.nodeID = null;
        }
        unpacker.close();
    }
 
开发者ID:myzhan,项目名称:locust4j,代码行数:60,代码来源:Message.java


注:本文中的org.msgpack.core.MessageUnpacker.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。