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

Method MergePartialFromCodedStream

src/brpc/memcache.cpp:62–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62bool MemcacheRequest::MergePartialFromCodedStream(
63 ::google::protobuf::io::CodedInputStream* input) {
64 LOG(WARNING) << "You're not supposed to parse a MemcacheRequest";
65
66 // simple approach just making it work.
67 butil::IOBuf tmp;
68 const void* data = NULL;
69 int size = 0;
70 while (input->GetDirectBufferPointer(&data, &size)) {
71 tmp.append(data, size);
72 input->Skip(size);
73 }
74 const butil::IOBuf saved = tmp;
75 int count = 0;
76 for (; !tmp.empty(); ++count) {
77 char aux_buf[sizeof(policy::MemcacheRequestHeader)];
78 const policy::MemcacheRequestHeader* header =
79 (const policy::MemcacheRequestHeader*)tmp.fetch(aux_buf, sizeof(aux_buf));
80 if (header == NULL) {
81 return false;
82 }
83 if (header->magic != (uint8_t)policy::MC_MAGIC_REQUEST) {
84 return false;
85 }
86 uint32_t total_body_length = butil::NetToHost32(header->total_body_length);
87 if (tmp.size() < sizeof(*header) + total_body_length) {
88 return false;
89 }
90 tmp.pop_front(sizeof(*header) + total_body_length);
91 }
92 _buf.append(saved);
93 _pipelined_count += count;
94 return true;
95}
96
97void MemcacheRequest::SerializeWithCachedSizes(
98 ::google::protobuf::io::CodedOutputStream* output) const {

Callers

nothing calls this directly

Calls 7

NetToHost32Function · 0.85
fetchMethod · 0.80
appendMethod · 0.45
SkipMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
pop_frontMethod · 0.45

Tested by

no test coverage detected