| 19 | constexpr double Log2Squared = Log2 * Log2; |
| 20 | |
| 21 | BloomStore::BloomStore(const std::string &path_, int64_t length_) : bitMasks{}, backingFile(path_), length(length_) { |
| 22 | |
| 23 | for (size_t i = 0; i < BloomStore::BlockSize; ++i) { |
| 24 | bitMasks.at(i) = BloomStore::BlockType{1} << i; |
| 25 | } |
| 26 | |
| 27 | if (backingFile.size() == 0) { |
| 28 | backingFile.truncate(blockCount()); |
| 29 | } |
| 30 | |
| 31 | if (backingFile.size() != blockCount()) { |
| 32 | throw std::runtime_error("Trying to open bloom filter of wrong size"); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | int64_t BloomStore::blockCount() const { |
| 37 | return (length + BlockSize - 1) / BlockSize; |