| 450 | } |
| 451 | |
| 452 | Status Sorter::Run::PrepareRead() { |
| 453 | DCHECK(is_finalized_); |
| 454 | DCHECK(is_sorted_); |
| 455 | |
| 456 | fixed_len_pages_index_ = 0; |
| 457 | fixed_len_page_offset_ = 0; |
| 458 | var_len_pages_index_ = 0; |
| 459 | end_of_fixed_len_page_ = end_of_var_len_page_ = fixed_len_pages_.empty(); |
| 460 | num_tuples_returned_ = 0; |
| 461 | |
| 462 | buffered_batch_.reset(new RowBatch( |
| 463 | sorter_->output_row_desc_, sorter_->state_->batch_size(), sorter_->mem_tracker_)); |
| 464 | |
| 465 | // If the run is pinned, all pages are already pinned, so we're ready to read. |
| 466 | if (is_pinned_) return Status::OK(); |
| 467 | |
| 468 | // Pins the first fixed len page. |
| 469 | if (!fixed_len_pages_.empty()) { |
| 470 | RETURN_IF_ERROR(fixed_len_pages_[0].Pin(sorter_->buffer_pool_client_)); |
| 471 | } |
| 472 | |
| 473 | // Pins the first var len page if there is any. |
| 474 | if (HasVarLenPages()) { |
| 475 | RETURN_IF_ERROR(var_len_pages_[0].Pin(sorter_->buffer_pool_client_)); |
| 476 | } |
| 477 | |
| 478 | return Status::OK(); |
| 479 | } |
| 480 | |
| 481 | Status Sorter::Run::GetNextBatch(RowBatch** output_batch) { |
| 482 | DCHECK(buffered_batch_ != nullptr); |
no test coverage detected