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

Method createIndex

cachelib/navy/block_cache/BlockCache.cpp:149–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149std::unique_ptr<Index> BlockCache::createIndex(
150 const BlockCacheIndexConfig& indexConfig,
151 const NavyPersistParams& persistParams,
152 bool useCombinedEntryBlock,
153 const std::string& name) {
154 if (indexConfig.isFixedSizeIndexEnabled()) {
155 return std::make_unique<FixedSizeIndex>(
156 indexConfig.getNumChunks(),
157 indexConfig.getNumBucketsPerChunkPower(),
158 indexConfig.getNumBucketsPerMutex(),
159 (indexConfig.useShmToPersist() || persistParams.useShm)
160 ? (persistParams.shmManager.has_value()
161 ? &(persistParams.shmManager.value().get())
162 : nullptr)
163 : nullptr,
164 name,
165 useCombinedEntryBlock,
166 combinedEntryMgr_.get(),
167 bindThis(&BlockCache::onKeyHashRetrievalFromLocation, *this));
168 } else {
169 // Combined entry block is not supported for sparse map index
170 if (useCombinedEntryBlock) {
171 XLOG(WARN,
172 "Combined entry block is set to be used, however sparse map index "
173 "doesn't support it. It will be ignored.");
174 }
175 return std::make_unique<SparseMapIndex>(
176 indexConfig.getNumSparseMapBuckets(),
177 indexConfig.getNumBucketsPerMutex(),
178 indexConfig.isTrackItemHistoryEnabled()
179 ? SparseMapIndex::ExtraField::kItemHitHistory
180 : SparseMapIndex::ExtraField::kTotalHits);
181 }
182}
183
184BlockCache::~BlockCache() { regionManager_.drain(); }
185

Callers

nothing calls this directly

Calls 10

bindThisFunction · 0.85
getNumBucketsPerMutexMethod · 0.80
useShmToPersistMethod · 0.80
getNumChunksMethod · 0.45
getMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected