| 101 | } |
| 102 | |
| 103 | int64_t KVWorkload::indexForKey(const KeyRef& key, bool absent) const { |
| 104 | int idx = 0; |
| 105 | if (nodePrefix > 0) { |
| 106 | ASSERT(keyBytes >= 32); |
| 107 | idx += 16; |
| 108 | } |
| 109 | ASSERT(keyBytes >= 16); |
| 110 | // extract int64_t index, the reverse process of emplaceIndex() |
| 111 | auto end = key.size() - idx - (absent ? 1 : 0); |
| 112 | std::string str((char*)key.begin() + idx, end); |
| 113 | int64_t res = std::stoll(str, nullptr, 16); |
| 114 | return res; |
| 115 | } |
| 116 | |
| 117 | Key KVWorkload::keyForIndex(uint64_t index, bool absent) const { |
| 118 | int adjustedKeyBytes = (absent) ? (keyBytes + 1) : keyBytes; |
no test coverage detected