MCPcopy Create free account
hub / github.com/apache/brpc / Decompress

Function Decompress

src/brpc/policy/gzip_compress.cpp:72–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72static bool Decompress(const butil::IOBuf& data, google::protobuf::Message* msg,
73 google::protobuf::io::GzipInputStream::Format format) {
74 butil::IOBufAsZeroCopyInputStream wrapper(data);
75 google::protobuf::io::GzipInputStream gzip(&wrapper, format);
76 bool ok;
77 if (msg->GetDescriptor() == Deserializer::descriptor()) {
78 ok = ((Deserializer*)msg)->DeserializeFrom(&gzip);
79 } else {
80 ok = msg->ParseFromZeroCopyStream(&gzip);
81 }
82 if (!ok) {
83 LOG(WARNING) << "Fail to deserialize input message="
84 << msg->GetDescriptor()->full_name()
85 << ", format=" << Format2CStr(format) << " : "
86 << (NULL == gzip.ZlibErrorMessage() ? "" : gzip.ZlibErrorMessage());
87 }
88 return ok;
89}
90
91bool GzipCompress(const google::protobuf::Message& msg, butil::IOBuf* buf) {
92 return Compress(msg, buf, google::protobuf::io::GzipOutputStream::GZIP);

Callers 2

GzipDecompressFunction · 0.85
ZlibDecompressFunction · 0.85

Calls 3

Format2CStrFunction · 0.85
DeserializeFromMethod · 0.80
GetDescriptorMethod · 0.45

Tested by

no test coverage detected