MCPcopy Create free account
hub / github.com/facebook/CacheLib / TEST

Function TEST

cachelib/navy/block_cache/tests/SparseMapIndexTest.cpp:37–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36namespace facebook::cachelib::navy::tests {
37TEST(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
64TEST(SparseMapIndex, EntrySize) {
65 SparseMapIndex index;

Callers

nothing calls this directly

Calls 15

createMemoryRecordWriterFunction · 0.85
createMemoryRecordReaderFunction · 0.85
addressMethod · 0.80
sizeHintMethod · 0.80
foundMethod · 0.80
totalHitsMethod · 0.80
currentHitsMethod · 0.80
itemHistoryMethod · 0.80
joinMethod · 0.80
insertMethod · 0.45
persistMethod · 0.45

Tested by

no test coverage detected