| 112 | } |
| 113 | |
| 114 | Index::LookupResult SparseMapIndex::lookup(uint64_t key) { |
| 115 | auto& map = getMap(key); |
| 116 | auto lock = std::lock_guard{getMutex(key)}; |
| 117 | |
| 118 | auto it = map.find(subkey(key)); |
| 119 | if (it != map.end()) { |
| 120 | LookupResult lr{true, it->second}; |
| 121 | |
| 122 | if (extraField_ == ExtraField::kTotalHits) { |
| 123 | it.value().extra.totalHits = safeInc(it.value().extra.totalHits); |
| 124 | } |
| 125 | it.value().currentHits = safeInc(it.value().currentHits); |
| 126 | return lr; |
| 127 | } |
| 128 | return {}; |
| 129 | } |
| 130 | |
| 131 | Index::LookupResult SparseMapIndex::peek(uint64_t key) const { |
| 132 | const auto& map = getMap(key); |