use of io.protostuff.ByteBufInput in project turbo-rpc by hank-whu.
the class TracerSerializerBenchmark method readByProtostuff.
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public Tracer readByProtostuff() throws Exception {
protostuffBuffer.readerIndex(0);
ByteBufInput input = new ByteBufInput(protostuffBuffer, true);
Tracer tracer = tracerSchema.newMessage();
tracerSchema.mergeFrom(input, tracer);
return tracer;
}
use of io.protostuff.ByteBufInput in project turbo-rpc by hank-whu.
the class ProtostuffBenchmark method deserializeUser.
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public User deserializeUser() throws Exception {
userBuffer.readerIndex(0);
ByteBufInput input = new ByteBufInput(userBuffer, true);
User user = userSchema.newMessage();
userSchema.mergeFrom(input, user);
return user;
}
use of io.protostuff.ByteBufInput in project turbo-rpc by hank-whu.
the class ProtostuffBenchmark method deserializeUserPage.
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@SuppressWarnings("unchecked")
public Page<User> deserializeUserPage() throws Exception {
listBuffer.readerIndex(0);
ByteBufInput input = new ByteBufInput(listBuffer, true);
Page<User> userPage = (Page<User>) userPageSchema.newMessage();
userPageSchema.mergeFrom(input, userPage);
return userPage;
}
use of io.protostuff.ByteBufInput in project turbo-rpc by hank-whu.
the class ProtostuffSerializer method readRequest.
public Request readRequest(ByteBuf byteBuf) throws IOException {
int requestId = byteBuf.readInt();
int serviceId = ByteBufUtils.readVarInt(byteBuf);
Tracer tracer = TRACER_SERIALIZER.read(byteBuf);
Schema<MethodParam> schema = schema(serviceId);
MethodParam methodParam = null;
if (EmptyMethodParam.class.equals(schema.typeClass())) {
methodParam = EmptyMethodParam.empty();
} else {
ByteBufInput input = getOrUpdate(INPUT_ATTACHMENT_INDEX, INPUT_SUPPLIER);
input.setByteBuf(byteBuf, true);
methodParam = schema.newMessage();
schema.mergeFrom(input, methodParam);
}
Request request = RecycleRequest.newInstance(requestId, serviceId, tracer, methodParam);
return request;
}
use of io.protostuff.ByteBufInput in project turbo-rpc by hank-whu.
the class ProtostuffSerializer method readResponse.
public Response readResponse(ByteBuf byteBuf) throws IOException {
// System.out.println("response content: " + new
// String(ByteBufUtil.getBytes(byteBuf.duplicate())));
// System.out.println("response length: " + byteBuf.readableBytes());
ByteBufInput input = getOrUpdate(INPUT_ATTACHMENT_INDEX, INPUT_SUPPLIER);
input.setByteBuf(byteBuf, true);
Response response = RecycleResponse.newInstance(0, (byte) 0, null, null);
responseSchema.mergeFrom(input, response);
return response;
}
Aggregations