| 698 | |
| 699 | template <RowFormat R> |
| 700 | void 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 | |
| 733 | template class WindowPartitionImpl<RowFormat::kRowContainer>; |
| 734 | template class WindowPartitionImpl<RowFormat::kSerializedRows>; |
no test coverage detected