| 225 | |
| 226 | |
| 227 | Try<Option<Entry>> LevelDBStorageProcess::read(const string& name) |
| 228 | { |
| 229 | CHECK_NONE(error); |
| 230 | |
| 231 | leveldb::ReadOptions options; |
| 232 | |
| 233 | string value; |
| 234 | |
| 235 | leveldb::Status status = db->Get(options, name, &value); |
| 236 | |
| 237 | if (status.IsNotFound()) { |
| 238 | return None(); |
| 239 | } else if (!status.ok()) { |
| 240 | return Error(status.ToString()); |
| 241 | } |
| 242 | |
| 243 | google::protobuf::io::ArrayInputStream stream(value.data(), value.size()); |
| 244 | |
| 245 | Entry entry; |
| 246 | |
| 247 | if (!entry.ParseFromZeroCopyStream(&stream)) { |
| 248 | return Error("Failed to deserialize Entry"); |
| 249 | } |
| 250 | |
| 251 | return Some(entry); |
| 252 | } |
| 253 | |
| 254 | |
| 255 | Try<bool> LevelDBStorageProcess::write(const Entry& entry) |
no test coverage detected