| 845 | } |
| 846 | |
| 847 | vector_size_t Window::callApplyLoop( |
| 848 | vector_size_t numOutputRows, |
| 849 | const RowVectorPtr& result) { |
| 850 | // Compute outputs by traversing as many partitions as possible. This |
| 851 | // logic takes care of partial partitions output also. |
| 852 | vector_size_t resultIndex = 0; |
| 853 | vector_size_t numOutputRowsLeft = numOutputRows; |
| 854 | |
| 855 | // This function requires that the currentPartition_ is available for |
| 856 | // output. |
| 857 | BOLT_DCHECK_NOT_NULL(currentPartition_); |
| 858 | while (numOutputRowsLeft > 0) { |
| 859 | // SpillableWindowBuild can not be handled by callApplyLoop. |
| 860 | if (isSpillableWindowBuild_ && currentPartition_->isSpilled()) { |
| 861 | break; |
| 862 | } |
| 863 | auto rowsForCurrentPartition = |
| 864 | currentPartition_->numRows() - partitionOffset_; |
| 865 | if (rowsForCurrentPartition <= numOutputRowsLeft) { |
| 866 | // Current partition can fit completely in the output buffer. |
| 867 | // So output all its rows. |
| 868 | callApplyForPartitionRows( |
| 869 | partitionOffset_, |
| 870 | partitionOffset_ + rowsForCurrentPartition, |
| 871 | resultIndex, |
| 872 | result); |
| 873 | resultIndex += rowsForCurrentPartition; |
| 874 | numOutputRowsLeft -= rowsForCurrentPartition; |
| 875 | if (currentPartition_->supportRowsStreaming()) { |
| 876 | if (currentPartition_->processFinished()) { |
| 877 | callResetPartition(); |
| 878 | if (currentPartition_ && |
| 879 | partitionOffset_ == currentPartition_->numRows()) { |
| 880 | if (!currentPartition_->buildNextRows()) { |
| 881 | windowBuild_->loadNextPartialPartitionFromSpill(); |
| 882 | break; |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | } else { |
| 887 | // Break until the next getOutput call to handle the remaining data |
| 888 | // in currentPartition_. |
| 889 | break; |
| 890 | } |
| 891 | } else { |
| 892 | callResetPartition(); |
| 893 | } |
| 894 | |
| 895 | if (!currentPartition_) { |
| 896 | // The WindowBuild doesn't have any more partitions to process right |
| 897 | // now. So break until the next getOutput call. |
| 898 | break; |
| 899 | } |
| 900 | } else { |
| 901 | // Current partition can fit only partially in the output buffer. |
| 902 | // Call apply for the rows that can fit in the buffer and break from |
| 903 | // outputting. |
| 904 | callApplyForPartitionRows( |
nothing calls this directly
no test coverage detected