| 154 | } |
| 155 | |
| 156 | Status Sorter::Run::TryInit(bool* allocation_failed) { |
| 157 | *allocation_failed = true; |
| 158 | DCHECK_GT(sorter_->inmem_run_max_pages_, 0); |
| 159 | // No need for additional copy page because var-len data is not reordered. |
| 160 | // The in-memory merger can copy var-len data directly from the in-memory runs, |
| 161 | // which are kept until the merge is finished |
| 162 | int num_to_create = 1 + has_var_len_slots_; |
| 163 | int64_t required_mem = num_to_create * sorter_->page_len_; |
| 164 | if (!sorter_->buffer_pool_client_->IncreaseReservationToFit(required_mem)) { |
| 165 | return Status::OK(); |
| 166 | } |
| 167 | |
| 168 | RETURN_IF_ERROR(AddPage(&fixed_len_pages_)); |
| 169 | if (has_var_len_slots_) { |
| 170 | RETURN_IF_ERROR(AddPage(&var_len_pages_)); |
| 171 | } |
| 172 | if (initial_run_) { |
| 173 | sorter_->initial_runs_counter_->Add(1); |
| 174 | } |
| 175 | *allocation_failed = false; |
| 176 | return Status::OK(); |
| 177 | } |
| 178 | |
| 179 | template <bool HAS_VAR_LEN_SLOTS, bool INITIAL_RUN> |
| 180 | Status Sorter::Run::AddBatchInternal( |
no test coverage detected