| 1470 | } |
| 1471 | |
| 1472 | void Sorter::TryToIncreaseMemAllocationForMerge() { |
| 1473 | int pages_needed_for_full_merge = 0; |
| 1474 | for (auto run : sorted_runs_) { |
| 1475 | pages_needed_for_full_merge += (run->HasVarLenPages()) ? 2 : 1; |
| 1476 | } |
| 1477 | int available_pages = buffer_pool_client_->GetUnusedReservation() / page_len_; |
| 1478 | |
| 1479 | // Start allocating more pages than available now. Stop once no more memory can be |
| 1480 | // allocated. |
| 1481 | for (int i = 0; i < pages_needed_for_full_merge - available_pages; ++i) { |
| 1482 | if (!buffer_pool_client_->IncreaseReservation(page_len_)) return; |
| 1483 | } |
| 1484 | } |
| 1485 | |
| 1486 | int Sorter::GetNumOfRunsForMerge() const { |
| 1487 | int max_runs_in_next_merge = MaxRunsInNextMerge(); |
nothing calls this directly
no test coverage detected