本文整理汇总了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();
}
}
示例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;
}
}
示例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;
}
}
示例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();
}
}
示例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();
}