MCPcopy Create free account
hub / github.com/bytedance/bolt / allocateTables

Method allocateTables

bolt/exec/HashTable.cpp:838–857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

836
837template <bool ignoreNullKeys>
838void 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
859template <bool ignoreNullKeys>
860void HashTable<ignoreNullKeys>::clear() {

Callers

nothing calls this directly

Calls 4

isPowerOfTwoFunction · 0.85
memsetFunction · 0.85
allocateContiguousMethod · 0.45
poolMethod · 0.45

Tested by

no test coverage detected