use of com.google.protobuf.CodedInputStream in project calcite-avatica by apache.
the class ProtobufTranslationImpl method parseResponse.
@Override
public Response parseResponse(byte[] bytes) throws IOException {
ByteString byteString = UnsafeByteOperations.unsafeWrap(bytes);
CodedInputStream inputStream = byteString.newCodedInput();
// Enable aliasing to avoid an extra copy to get at the serialized Response inside of the
// WireMessage.
inputStream.enableAliasing(true);
WireMessage wireMsg = WireMessage.parseFrom(inputStream);
String serializedMessageClassName = wireMsg.getName();
try {
ResponseTranslator translator = getParserForResponse(serializedMessageClassName);
return translator.transform(wireMsg.getWrappedMessage());
} catch (RuntimeException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Failed to parse response message '{}'", TextFormat.shortDebugString(wireMsg));
}
throw e;
}
}
Aggregations