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

Method store

src/brpc/couchbase.cpp:1094–1127  ·  view source on GitHub ↗

MUST have extras. MUST have key. MAY have value. Extra data for set/add/replace: Byte/ 0 | 1 | 2 | 3 | / | | | | |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| +---------------+---------------+---------------+---------------+ 0| Flags

Source from the content-addressed store, hash-verified

1092// +---------------+---------------+---------------+---------------+
1093// Total 8 bytes
1094bool CouchbaseOperations::CouchbaseRequest::store(
1095 uint8_t command, const butil::StringPiece& key,
1096 const butil::StringPiece& value, uint32_t flags, uint32_t exptime,
1097 uint64_t cas_value, uint8_t coll_id) {
1098 // add collection id
1099 // uint16_t collection_id = 0x00;
1100 uint8_t collection_id = coll_id;
1101 uint16_t vBucket_id = hashCrc32(key.data(), key.size());
1102 StoreHeaderWithExtras header_with_extras = {
1103 {policy::CB_MAGIC_REQUEST, command,
1104 butil::HostToNet16(key.size() +
1105 1), // collection id is not included in part of key,
1106 // so not including it in key length.
1107 STORE_EXTRAS, policy::CB_JSON, butil::HostToNet16(vBucket_id),
1108 butil::HostToNet32(STORE_EXTRAS + sizeof(collection_id) + key.size() +
1109 value.size()), // total body length
1110 0, butil::HostToNet64(cas_value)},
1111 butil::HostToNet32(flags),
1112 butil::HostToNet32(exptime)};
1113 if (_buf.append(&header_with_extras, sizeof(header_with_extras))) {
1114 return false;
1115 }
1116 if (_buf.append(&collection_id, sizeof(collection_id))) {
1117 return false;
1118 }
1119 if (_buf.append(key.data(), key.size())) {
1120 return false;
1121 }
1122 if (_buf.append(value.data(), value.size())) {
1123 return false;
1124 }
1125 ++_pipelined_count;
1126 return true;
1127}
1128
1129// MUST have CAS
1130// MUST NOT have extras

Callers 15

TestFunction · 0.45
mainFunction · 0.45
UpdateMethod · 0.45
RunUpdateTaskFunction · 0.45
ComputeLatencyMethod · 0.45
mainFunction · 0.45
TEST_FFunction · 0.45
OnCreatedMethod · 0.45
BeforeRecycledMethod · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
mainFunction · 0.45

Calls 6

HostToNet16Function · 0.85
HostToNet32Function · 0.85
HostToNet64Function · 0.85
dataMethod · 0.45
sizeMethod · 0.45
appendMethod · 0.45

Tested by 15

TestFunction · 0.36
TEST_FFunction · 0.36
OnCreatedMethod · 0.36
BeforeRecycledMethod · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
mainFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36
ThreadLocalForEachFuncFunction · 0.36
on_received_messagesMethod · 0.36