| 91 | } |
| 92 | |
| 93 | comm::RetCode LockDb::Init(const LockDb::Type type, const string &leveldb_file) { |
| 94 | type_ = type; |
| 95 | |
| 96 | if (Type::MAP == type_) { |
| 97 | } else if (Type::LEVELDB == type_) { |
| 98 | leveldb::Options options; |
| 99 | options.create_if_missing = true; |
| 100 | // raise an error as soon as it detects an internal corruption |
| 101 | options.paranoid_checks = leveldb_checks_; |
| 102 | leveldb::Status status(leveldb::DB::Open(options, leveldb_file, &leveldb_)); |
| 103 | if (!status.ok()) { |
| 104 | QLErr("open \"%s\" err \"%s\"", leveldb_file.c_str(), status.ToString().c_str()); |
| 105 | |
| 106 | return comm::RetCode::RET_ERR_LEVELDB; |
| 107 | } |
| 108 | } else { |
| 109 | return comm::RetCode::RET_ERR_NO_IMPL; |
| 110 | } |
| 111 | |
| 112 | return comm::RetCode::RET_OK; |
| 113 | } |
| 114 | |
| 115 | comm::RetCode LockDb::Dispose() { |
| 116 | if (Type::MAP == type_) { |