| 372 | // Spill large partitions |
| 373 | template <bool needSort> |
| 374 | void SpillableWindowBuild<needSort>::ensureOutputFits() { |
| 375 | if (spillConfig_->testSpillPct > 0 && inputRows_.size() > 0) { |
| 376 | spill(); |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | std::optional<size_t> rowLength = std::nullopt; |
| 381 | if (rowLength_.has_value()) { |
| 382 | rowLength = rowLength_; |
| 383 | } else if (estimateRowSize().has_value()) { |
| 384 | rowLength = estimateRowSize(); |
| 385 | } |
| 386 | const uint64_t outputBufferSizeToReserve = |
| 387 | (rowLength.has_value() ? (rowLength.value() * maxBatchRows_) |
| 388 | : preferredOutputBatchBytes_) * |
| 389 | 1.2; |
| 390 | |
| 391 | { |
| 392 | memory::ReclaimableSectionGuard guard(nonReclaimableSection_); |
| 393 | if (data_->pool()->maybeReserve(outputBufferSizeToReserve)) { |
| 394 | return; |
| 395 | } |
| 396 | } |
| 397 | LOG(WARNING) << "Failed to reserve " |
| 398 | << succinctBytes(outputBufferSizeToReserve) |
| 399 | << " for memory pool " << data_->pool()->name() |
| 400 | << ", usage: " << succinctBytes(data_->pool()->currentBytes()) |
| 401 | << ", reservation: " |
| 402 | << succinctBytes(data_->pool()->reservedBytes()); |
| 403 | } |
| 404 | |
| 405 | template <bool needSort> |
| 406 | void SpillableWindowBuild<needSort>::storeRows() { |
nothing calls this directly
no test coverage detected