MCPcopy Create free account
hub / github.com/Tencent/phxqueue / Get

Method Get

phxqueue/lock/lockdb.cpp:378–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376}
377
378comm::RetCode LockDb::Get(const string &k, proto::LocalLockInfo &v) {
379 if (0 >= k.size()) {
380 QLErr("key \"%s\" invalid", k.c_str());
381
382 return comm::RetCode::RET_ERR_KEY;
383 }
384
385 if (Type::MAP == type_) {
386 auto it(map_.find(k));
387 if (map_.end() == it) {
388 QLVerb("key \"%s\" not exist", k.c_str());
389
390 // not found
391 return comm::RetCode::RET_ERR_KEY_NOT_EXIST;
392 }
393 v = it->second;
394 QLVerb("key \"%s\" ver %llu", k.c_str(), v.version());
395 } else if (Type::LEVELDB == type_) {
396 string vstr;
397 comm::RetCode ret{Get(k, vstr)};
398 if (comm::RetCode::RET_OK != ret) {
399 return ret;
400 }
401 bool succ(v.ParseFromString(vstr));
402 if (!succ) {
403 QLErr("ParseFromString err");
404
405 return comm::RetCode::RET_ERR_LOGIC;
406 }
407 QLVerb("key \"%s\" ver %llu", k.c_str(), v.version());
408 } else {
409 return comm::RetCode::RET_ERR_NO_IMPL;
410 }
411
412 return comm::RetCode::RET_OK;
413}
414
415comm::RetCode LockDb::Get(const string &k, string &vstr) {
416 if (0 >= k.size()) {

Callers 5

ReadCheckpointMethod · 0.45
ReadRestartCheckpointMethod · 0.45
CleanLockMethod · 0.45
AcquireLockMethod · 0.45
GetLockInfoMethod · 0.45

Calls 1

ToStringMethod · 0.80

Tested by

no test coverage detected