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


Java MessageUnpacker.readPayload方法代码示例

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


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

示例1: readSpanId

import org.msgpack.core.MessageUnpacker; //导入方法依赖的package包/类
static SpanId readSpanId(MessageUnpacker unpacker) throws IOException {
  int alen = unpacker.unpackBinaryHeader();
  if (alen != SPAN_ID_BYTE_LENGTH) {
    throw new IOException("Invalid length given for spanID array.  " +
        "Expected " + SPAN_ID_BYTE_LENGTH + "; got " + alen);
  }
  byte[] payload = new byte[SPAN_ID_BYTE_LENGTH];
  unpacker.readPayload(payload);
  return new SpanId(
      ((payload[ 7] & 0xffL) <<  0) |
      ((payload[ 6] & 0xffL) <<  8) |
      ((payload[ 5] & 0xffL) << 16) |
      ((payload[ 4] & 0xffL) << 24) |
      ((payload[ 3] & 0xffL) << 32) |
      ((payload[ 2] & 0xffL) << 40) |
      ((payload[ 1] & 0xffL) << 48) |
      ((payload[ 0] & 0xffL) << 56),
      ((payload[15] & 0xffL) <<  0) |
      ((payload[14] & 0xffL) <<  8) |
      ((payload[13] & 0xffL) << 16) |
      ((payload[12] & 0xffL) << 24) |
      ((payload[11] & 0xffL) << 32) |
      ((payload[10] & 0xffL) << 40) |
      ((payload[ 9] & 0xffL) << 48) |
      ((payload[ 8] & 0xffL) << 56)
    );
}
 
开发者ID:apache,项目名称:incubator-htrace,代码行数:28,代码来源:PackedBuffer.java

示例2: 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

示例3: unpackByteBuffer

import org.msgpack.core.MessageUnpacker; //导入方法依赖的package包/类
private static ByteBuffer unpackByteBuffer(MessageUnpacker unpack) throws IOException {
    ByteBuffer bb = ByteBuffer.allocate(unpack.unpackBinaryHeader());
    unpack.readPayload(bb);
    bb.flip(); // prepare for read of byte buffer
    return bb;
}
 
开发者ID:Distelli,项目名称:java-persistence,代码行数:7,代码来源:AttributeValuePacker.java


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