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

Method getOutput

bolt/exec/HashAggregation.cpp:544–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542}
543
544RowVectorPtr HashAggregation::getOutput() {
545 if (BOLT_TEST_VALUE_ENABLED()) {
546 bool injectSegfault = false;
547 BOLT_TEST_ADJUST(
548 "bytedance::bolt::exec::HashAggregation::getOutput", &injectSegfault);
549 if (injectSegfault) {
550 triggerSegfault();
551 }
552 }
553 if (finished_) {
554 input_ = nullptr;
555 return nullptr;
556 }
557 if (abandonedPartialAggregation_) {
558 if (noMoreInput_) {
559 finished_ = true;
560 }
561 if (!input_) {
562 return nullptr;
563 }
564 prepareOutput(input_->size(), false);
565 groupingSet_->toIntermediate(input_, output_);
566 numOutputRows_ += input_->size();
567 input_ = nullptr;
568 return output_;
569 }
570
571 // Produce results if one of the following is true:
572 // - received no-more-input message;
573 // - partial aggregation reached memory limit;
574 // - distinct aggregation has new keys;
575 // - running in partial streaming mode and have some output ready.
576 if (!noMoreInput_ && !partialFull_ && !newDistincts_ &&
577 !groupingSet_->hasOutput()) {
578 input_ = nullptr;
579 return nullptr;
580 }
581
582 if (isDistinct_) {
583 auto currentOutput = getDistinctOutput();
584 // Accumulate the generated output using append()
585 if (currentOutput) {
586 if (!accumulatedOutput_) {
587 if (currentOutput->size() >= minOutputRows_) {
588 return currentOutput;
589 }
590 accumulatedOutput_ =
591 RowVector::createEmpty(currentOutput->type(), operatorCtx_->pool());
592 }
593 accumulatedOutput_->append(currentOutput.get());
594 }
595
596 // Handle accumulated output when no more input or memory pressure
597 if (accumulatedOutput_ &&
598 (finished_ || partialFull_ ||
599 accumulatedOutput_->size() >= minOutputRows_ ||
600 abandonedPartialAggregation_)) {
601 auto result = std::move(accumulatedOutput_);

Callers 1

getDistinctOutputMethod · 0.45

Calls 15

createEmptyFunction · 0.85
hasOutputMethod · 0.80
value_orMethod · 0.80
triggerSegfaultFunction · 0.70
poolFunction · 0.50
maxFunction · 0.50
sizeMethod · 0.45
toIntermediateMethod · 0.45
typeMethod · 0.45
poolMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected