| 630 | } |
| 631 | |
| 632 | Status TopNNode::PrepareForOutput(RuntimeState* state) { |
| 633 | if (is_partitioned()) { |
| 634 | // Dump all rows into the sorter and sort by partition, so that we can iterate |
| 635 | // through the rows and build heaps partition-by-partition. |
| 636 | RETURN_IF_ERROR(EvictPartitions(state, /*evict_final=*/true)); |
| 637 | DCHECK(partition_heaps_.empty()); |
| 638 | RETURN_IF_ERROR(sorter_->InputDone()); |
| 639 | sort_out_batch_.reset( |
| 640 | new RowBatch(row_desc(), state->batch_size(), mem_tracker())); |
| 641 | } else { |
| 642 | DCHECK(heap_->DCheckConsistency()); |
| 643 | heap_->PrepareForOutput(*this, &sorted_top_n_); |
| 644 | get_next_iter_ = sorted_top_n_.begin(); |
| 645 | } |
| 646 | return Status::OK(); |
| 647 | } |
| 648 | |
| 649 | void TopNNode::Heap::PrepareForOutput( |
| 650 | const TopNNode& RESTRICT node, vector<Tuple*>* sorted_top_n) RESTRICT { |
no test coverage detected