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

Method validate

cachelib/navy/block_cache/BlockCache.cpp:112–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void BlockCache::validate(BlockCache::Config& config) const {
113 uint32_t allocAlignSize = calcAllocAlignSize();
114 if (!folly::isPowTwo(allocAlignSize)) {
115 throw std::invalid_argument("invalid block size");
116 }
117 if (config.regionSize % allocAlignSize != 0) {
118 throw std::invalid_argument("invalid region size");
119 }
120 auto shiftWidth =
121 facebook::cachelib::NumBits<decltype(RelAddress().offset())>::value;
122 if (config.cacheSize > static_cast<uint64_t>(allocAlignSize) << shiftWidth) {
123 throw std::invalid_argument(
124 fmt::format("can't address cache with {} bits", shiftWidth));
125 }
126}
127
128uint32_t BlockCache::calcAllocAlignSize() const {
129 // Shift the total device size by <RelAddressWidth-in-bits>,

Callers 3

BlockCache.cppFile · 0.45
BlockCacheMethod · 0.45
BigHashMethod · 0.45

Calls 2

RelAddressClass · 0.85
offsetMethod · 0.45

Tested by

no test coverage detected