| 836 | |
| 837 | template <bool ignoreNullKeys> |
| 838 | void HashTable<ignoreNullKeys>::allocateTables(uint64_t size) { |
| 839 | BOLT_CHECK(bits::isPowerOfTwo(size), "Size is not a power of two: {}", size); |
| 840 | BOLT_CHECK_GT(size, 0); |
| 841 | capacity_ = size; |
| 842 | const uint64_t byteSize = capacity_ * tableSlotSize(); |
| 843 | BOLT_CHECK_EQ(byteSize % kBucketSize, 0); |
| 844 | numTombstones_ = 0; |
| 845 | sizeMask_ = byteSize - 1; |
| 846 | numBuckets_ = byteSize / kBucketSize; |
| 847 | sizeBits_ = __builtin_popcountll(sizeMask_); |
| 848 | bucketOffsetMask_ = sizeMask_ & ~(kBucketSize - 1); |
| 849 | // The total size is 8 bytes per slot, in groups of 16 slots with 16 bytes of |
| 850 | // tags and 16 * 6 bytes of pointers and a padding of 16 bytes to round up the |
| 851 | // cache line. |
| 852 | const auto numPages = |
| 853 | memory::AllocationTraits::numPages(size * tableSlotSize()); |
| 854 | rows_->pool()->allocateContiguous(numPages, tableAllocation_); |
| 855 | table_ = tableAllocation_.data<char*>(); |
| 856 | memset(table_, 0, capacity_ * sizeof(char*)); |
| 857 | } |
| 858 | |
| 859 | template <bool ignoreNullKeys> |
| 860 | void HashTable<ignoreNullKeys>::clear() { |
nothing calls this directly
no test coverage detected