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

Method getOutput

bolt/exec/StreamingAggregation.cpp:298–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298RowVectorPtr StreamingAggregation::getOutput() {
299 NanosecondTimer timer(&stats_.aggOutputTimeNs);
300 if (!input_) {
301 if (noMoreInput_ && numGroups_ > 0) {
302 auto output = createOutput(numGroups_);
303 numGroups_ = 0;
304 return output;
305 }
306 return nullptr;
307 }
308
309 // hold on accept new input if groups_ is too large to avoid large memory
310 // usage and too many copy
311 if (numGroups_ < groupNumberThreshold_) {
312 auto numInput = input_->size();
313 inputRows_.resize(numInput);
314 inputRows_.setAll();
315
316 masks_->addInput(input_, inputRows_);
317
318 auto numPrevGroups = numGroups_;
319 {
320 NanosecondTimer aggTimer(&stats_.aggOutputUpdateTimeNs);
321 assignGroups();
322 initializeNewGroups(numPrevGroups);
323 }
324 evaluateAggregates();
325
326 prevInput_ = input_;
327 input_ = nullptr;
328 }
329
330 RowVectorPtr output;
331 uint32_t outputSize = 0;
332 if (numGroups_ > outputBatchSize_) {
333 outputSize = outputBatchSize_;
334 } else if (
335 numGroups_ > 1 &&
336 rows_->estimateRowSize().value_or(0) * rows_->numRows() > outputBytes_) {
337 outputSize = numGroups_ - 1;
338 }
339
340 if (outputSize > 0) {
341 output = createOutput(outputSize);
342
343 // Rotate the entries in the groups_ vector to move the remaining groups to
344 // the beginning and place reusable groups at the end.
345 std::vector<char*> copy(groups_.size());
346 std::copy(groups_.begin() + outputSize, groups_.end(), copy.begin());
347 std::copy(
348 groups_.begin(),
349 groups_.begin() + outputSize,
350 copy.begin() + groups_.size() - outputSize);
351 groups_ = std::move(copy);
352 numGroups_ -= outputSize;
353 }
354
355 return output;

Callers

nothing calls this directly

Calls 11

initializeNewGroupsFunction · 0.85
setAllMethod · 0.80
value_orMethod · 0.80
copyFunction · 0.50
sizeMethod · 0.45
resizeMethod · 0.45
addInputMethod · 0.45
estimateRowSizeMethod · 0.45
numRowsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected