| 35 | |
| 36 | namespace facebook::cachelib::navy::tests { |
| 37 | TEST(SparseMapIndex, Recovery) { |
| 38 | SparseMapIndex index; |
| 39 | std::vector<std::pair<uint64_t, uint32_t>> log; |
| 40 | // Write to 16 buckets |
| 41 | for (uint64_t i = 0; i < 16; i++) { |
| 42 | for (uint64_t j = 0; j < 10; j++) { |
| 43 | // First 32 bits set bucket id, last 32 is key for that bucket |
| 44 | uint64_t key = i << 32 | j; |
| 45 | uint32_t val = j + i; |
| 46 | index.insert(key, val, 0); |
| 47 | log.emplace_back(key, val); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | folly::IOBufQueue ioq; |
| 52 | auto rw = createMemoryRecordWriter(ioq); |
| 53 | index.persist(*rw); |
| 54 | |
| 55 | auto rr = createMemoryRecordReader(ioq); |
| 56 | SparseMapIndex newIndex; |
| 57 | newIndex.recover(*rr); |
| 58 | for (auto& entry : log) { |
| 59 | auto lookupResult = newIndex.lookup(entry.first); |
| 60 | EXPECT_EQ(entry.second, lookupResult.address()); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | TEST(SparseMapIndex, EntrySize) { |
| 65 | SparseMapIndex index; |
nothing calls this directly
no test coverage detected