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

Method getWindowFunctionResults

bolt/exec/WindowPartition.cpp:700–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

698
699template <RowFormat R>
700void SpilledWindowPartition<R>::getWindowFunctionResults(
701 VectorPtr& result,
702 int32_t numOutputRows,
703 int32_t functionIndex,
704 bool isAggregateWindowFunc) {
705 if (isAggregateWindowFunc) {
706 const auto* aggResult = aggregateResults_[functionIndex].back().get();
707 for (auto i = 0; i < numOutputRows; ++i) {
708 result->copy(aggResult, i, 0, 1);
709 }
710 } else {
711 auto& aggResults = aggregateResults_[functionIndex];
712 int32_t target_index = 0;
713 while (numOutputRows && (aggResults.size() > 0)) {
714 const auto* currentResult = aggResults.front().get();
715 auto actualCopySize = std::min(numOutputRows, currentResult->size());
716 result->copy(currentResult, target_index, 0, actualCopySize);
717 numOutputRows = numOutputRows - actualCopySize;
718 target_index = target_index + actualCopySize;
719 if (actualCopySize == currentResult->size()) {
720 // If we copied all rows from the first aggregate result, we can
721 // prepare it for reuse and remove it from the list.
722 aggResults.front()->prepareForReuse();
723 aggResults.pop_front();
724 } else {
725 // If we copied only part of the first aggregate result, we slice it
726 aggResults.front() = currentResult->slice(
727 actualCopySize, currentResult->size() - actualCopySize);
728 }
729 }
730 }
731}
732
733template class WindowPartitionImpl<RowFormat::kRowContainer>;
734template class WindowPartitionImpl<RowFormat::kSerializedRows>;

Callers 1

Calls 7

backMethod · 0.80
minFunction · 0.50
getMethod · 0.45
copyMethod · 0.45
sizeMethod · 0.45
prepareForReuseMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected