MCPcopy Create free account
hub / github.com/bytedance/bolt / makePins

Method makePins

bolt/common/caching/tests/SsdFileTest.cpp:142–168  ·  view source on GitHub ↗

Gets consecutive entries from file 'fileId' starting at 'startOffset' with sizes between 'minSize' and 'maxSize'. Sizes start at 'minSize' and double each time and go back to 'minSize' after exceeding 'maxSize'. This stops after the total size has exceeded 'totalSize'. The entries are returned as pins. The pins are exclusive for newly created entries and shared for existing ones. New entries are

Source from the content-addressed store, hash-verified

140 // existing ones. New entries are deterministically initialized from 'fileId'
141 // and the entry's offset.
142 std::vector<CachePin> makePins(
143 uint64_t fileId,
144 uint64_t startOffset,
145 int32_t minSize,
146 int32_t maxSize,
147 int64_t totalSize) {
148 auto offset = startOffset;
149 int64_t bytesFromCache = 0;
150 auto size = minSize;
151 std::vector<CachePin> pins;
152 while (bytesFromCache < totalSize) {
153 pins.push_back(
154 cache_->findOrCreate(RawFileCacheKey{fileId, offset}, size, nullptr));
155 bytesFromCache += size;
156 EXPECT_FALSE(pins.back().empty());
157 auto entry = pins.back().entry();
158 if (entry && entry->isExclusive()) {
159 initializeContents(fileId + offset, entry->data());
160 }
161 offset += size;
162 size *= 2;
163 if (size > maxSize) {
164 size = minSize;
165 }
166 }
167 return pins;
168 }
169
170 std::vector<SsdPin> pinAllRegions(const std::vector<TestEntry>& entries) {
171 std::vector<SsdPin> pins;

Callers 2

loadDataMethod · 0.45
loadDataMethod · 0.45

Calls 7

findOrCreateMethod · 0.80
backMethod · 0.80
entryMethod · 0.80
isExclusiveMethod · 0.80
push_backMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected