| 376 | } |
| 377 | |
| 378 | comm::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 | |
| 415 | comm::RetCode LockDb::Get(const string &k, string &vstr) { |
| 416 | if (0 >= k.size()) { |
no test coverage detected