| 184 | } |
| 185 | |
| 186 | void WindowBuild::noMoreInputCommon() { |
| 187 | if (numRows_ == 0) { |
| 188 | return; |
| 189 | } |
| 190 | |
| 191 | if (sortSpiller_ != nullptr) { |
| 192 | // Spill remaining data to avoid running out of memory while sort-merging |
| 193 | // spilled data. |
| 194 | sortSpill(); |
| 195 | |
| 196 | BOLT_CHECK_NULL(sortMerge_); |
| 197 | BOLT_CHECK_NULL(rowBasedSpillSortMerger_); |
| 198 | auto spillPartition = sortSpiller_->finishSpill(); |
| 199 | if (spillConfig_->rowBasedSpillMode == common::RowBasedSpillMode::DISABLE) { |
| 200 | sortMerge_ = spillPartition.createOrderedReader(pool_); |
| 201 | } else { |
| 202 | rowBasedSpillSortMerger_ = |
| 203 | spillPartition.createRowBasedOrderedReaderWithLength( |
| 204 | pool_, |
| 205 | data_.get(), |
| 206 | spillConfig_->getJITenabledForSpill(), |
| 207 | spillConfig_->spillUringEnabled); |
| 208 | } |
| 209 | |
| 210 | } else { |
| 211 | // At this point we have seen all the input rows. The operator is |
| 212 | // being prepared to output rows now. |
| 213 | // To prepare the rows for output in SortWindowBuild they need to |
| 214 | // be separated into partitions and sort by ORDER BY keys within |
| 215 | // the partition. This will order the rows for getOutput(). |
| 216 | updateEstimatedOutputRowSize(); |
| 217 | sortPartitions(); |
| 218 | return; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | void WindowBuild::sortPartitions() { |
| 223 | sortRows_.resize(numRows_); |
no test coverage detected