| 147 | } |
| 148 | |
| 149 | std::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 | |
| 184 | BlockCache::~BlockCache() { regionManager_.drain(); } |
| 185 |
nothing calls this directly
no test coverage detected