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

Method testCycle

bolt/exec/tests/HashTableTest.cpp:131–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129 }
130
131 void testCycle(
132 BaseHashTable::HashMode mode,
133 int32_t size,
134 int32_t numWays,
135 TypePtr buildType,
136 int32_t numKeys) {
137 std::vector<TypePtr> dependentTypes;
138 int32_t sequence = 0;
139 isInTable_.resize(
140 bits::nwords(numWays * size),
141 static_cast<const std::vector<
142 unsigned long,
143 std::allocator<unsigned long>>::value_type>(-1));
144 if (insertPct_ != 100) {
145 // If we probe with all keys but only mean to insert part, we deselect.
146 folly::Random::DefaultGenerator rng;
147 rng.seed(1);
148 for (auto i = 0; i < size * numWays; ++i) {
149 if (folly::Random::rand32(rng) % 100 > insertPct_) {
150 bits::clearBit(isInTable_.data(), i);
151 }
152 }
153 }
154 int32_t startOffset = 0;
155 std::vector<std::unique_ptr<BaseHashTable>> otherTables;
156 uint64_t numRows{0};
157 for (auto way = 0; way < numWays; ++way) {
158 std::vector<RowVectorPtr> batches;
159 std::vector<std::unique_ptr<VectorHasher>> keyHashers;
160 for (auto channel = 0; channel < numKeys; ++channel) {
161 keyHashers.emplace_back(std::make_unique<VectorHasher>(
162 buildType->childAt(channel), channel));
163 }
164 auto table = HashTable<true>::createForJoin(
165 std::move(keyHashers),
166 dependentTypes,
167 true,
168 false,
169 BaseHashTable::HashMode::kArray,
170 1'000,
171 pool(),
172 GetParam().jitRowEqVectors);
173
174 makeRows(size, 1, sequence, buildType, batches);
175 copyVectorsToTable(batches, startOffset, table.get());
176 sequence += size;
177 if (topTable_ == nullptr) {
178 topTable_ = std::move(table);
179 numRows += topTable_->rows()->numRows();
180 } else {
181 numRows += table->rows()->numRows();
182 otherTables.push_back(std::move(table));
183 }
184 batches_.insert(batches_.end(), batches.begin(), batches.end());
185 startOffset += size;
186 }
187
188 const uint64_t estimatedTableSize =

Callers

nothing calls this directly

Calls 15

nwordsFunction · 0.85
clearBitFunction · 0.85
childAtMethod · 0.80
estimateHashTableSizeMethod · 0.80
prepareJoinTableMethod · 0.80
hashModeMethod · 0.80
allRowsMethod · 0.80
poolFunction · 0.50
resizeMethod · 0.45
seedMethod · 0.45
dataMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected