| 342 | } |
| 343 | |
| 344 | std::pair<iterator, bool> insert(const value_type& val) { |
| 345 | #ifdef IFOPSH_WITH_ROCKSDB |
| 346 | std::string key_str = key_to_string(val.first); |
| 347 | std::string full_key = prefix_ + key_str; |
| 348 | std::string existing; |
| 349 | rocksdb::Status s = db_->Get(rocksdb::ReadOptions{}, full_key, &existing); |
| 350 | if (s.ok()) { |
| 351 | // Key already exists. |
| 352 | return { find(val.first), false }; |
| 353 | } |
| 354 | std::string encoded = codec_.encode(val.second); |
| 355 | s = db_->Put(rocksdb::WriteOptions{}, full_key, encoded); |
| 356 | if (!s.ok()) { |
| 357 | return { end(), false }; |
| 358 | } |
| 359 | #endif |
| 360 | return { find(val.first), true }; |
| 361 | } |
| 362 | }; |
| 363 | |
| 364 | #endif |
nothing calls this directly
no test coverage detected