| 442 | } |
| 443 | |
| 444 | comm::RetCode LockDb::Delete(const string &k, const bool sync) { |
| 445 | if (0 >= k.size()) { |
| 446 | QLErr("key \"%s\" invalid", k.c_str()); |
| 447 | |
| 448 | return comm::RetCode::RET_ERR_KEY; |
| 449 | } |
| 450 | |
| 451 | if (Type::MAP == type_) { |
| 452 | map_.erase(k); |
| 453 | QLVerb("key \"%s\"", k.c_str()); |
| 454 | } else if (Type::LEVELDB == type_) { |
| 455 | leveldb::WriteOptions write_options; |
| 456 | write_options.sync = sync; |
| 457 | leveldb::Status status(leveldb_->Delete(write_options, k)); |
| 458 | if (!status.ok()) { |
| 459 | QLErr("%s", status.ToString().c_str()); |
| 460 | |
| 461 | return comm::RetCode::RET_ERR_LEVELDB; |
| 462 | } |
| 463 | QLVerb("key \"%s\"", k.c_str()); |
| 464 | } else { |
| 465 | return comm::RetCode::RET_ERR_NO_IMPL; |
| 466 | } |
| 467 | |
| 468 | return comm::RetCode::RET_OK; |
| 469 | } |
| 470 | |
| 471 | void LockDb::SeekToFirst() { |
| 472 | if (Type::MAP == type_) { |
no test coverage detected