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

Method addInputForActiveRows

bolt/exec/GroupingSet.cpp:244–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242}
243
244void GroupingSet::addInputForActiveRows(
245 const RowVectorPtr& input,
246 bool mayPushdown) {
247 BOLT_CHECK(!isGlobal_);
248 if (!table_) {
249 createHashTable();
250 }
251 ensureInputFits(input);
252
253 BOLT_TEST_ADJUST(
254 "bytedance::bolt::exec::GroupingSet::addInputForActiveRows", this);
255
256 if (!bypassProbeHT_) { // probing time
257 NanosecondTimer probeTimer(&stats_.aggProbeTimeNs);
258 table_->prepareForGroupProbe(
259 *lookup_,
260 input,
261 activeRows_,
262 ignoreNullKeys_,
263 BaseHashTable::kNoSpillInputStartPartitionBit);
264 if (lookup_->rows.empty()) {
265 // No rows to probe. Can happen when ignoreNullKeys_ is true and all rows
266 // have null keys.
267 return;
268 }
269 table_->groupProbe(*lookup_);
270 masks_.addInput(input, activeRows_);
271 } else {
272 // if there are too many distinct group-by keys and they should be spilled,
273 // we can bypass probing the hash table, directly add rows to the table. In
274 // the merge phase of output, dong the final agg can get correct results.
275
276 NanosecondTimer probeTimer(&stats_.aggProbeBypassTimeNs);
277 stats_.aggProbeBypassCount++;
278 table_->directAddRows(*lookup_, input, activeRows_, ignoreNullKeys_);
279 if (lookup_->rows.empty()) {
280 // No rows to probe. Can happen when ignoreNullKeys_ is true and all rows
281 // have null keys.
282 return;
283 }
284 masks_.addInput(input, activeRows_);
285 }
286
287 // agg func time
288 {
289 NanosecondTimer funcTimer(&stats_.aggFunctionTimeNs);
290 auto* groups = lookup_->hits.data();
291 auto& newGroups = lookup_->newGroups;
292 for (auto i = 0; i < aggregates_.size(); ++i) {
293 if (!aggregates_[i].sortingKeys.empty()) {
294 continue;
295 }
296
297 const auto& rows = getSelectivityVector(i);
298
299 if (aggregates_[i].distinct) {
300 if (!newGroups.empty()) {
301 distinctAggregations_[i]->initializeNewGroups(groups, newGroups);

Callers

nothing calls this directly

Calls 13

areAllLazyNotLoadedFunction · 0.85
prepareForGroupProbeMethod · 0.80
groupProbeMethod · 0.80
directAddRowsMethod · 0.80
hasSelectionsMethod · 0.80
emptyMethod · 0.45
addInputMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
initializeNewGroupsMethod · 0.45
addRawInputMethod · 0.45

Tested by

no test coverage detected