| 567 | } |
| 568 | |
| 569 | void HashProbe::spillInput(RowVectorPtr& input) { |
| 570 | BOLT_CHECK(needSpillInput()); |
| 571 | |
| 572 | const auto numInput = input->size(); |
| 573 | prepareInputIndicesBuffers( |
| 574 | input->size(), spiller_->state().spilledPartitionSet()); |
| 575 | const auto singlePartition = |
| 576 | spillHashFunction_->partition(*input, spillPartitions_); |
| 577 | |
| 578 | vector_size_t numNonSpillingInput = 0; |
| 579 | for (auto row = 0; row < numInput; ++row) { |
| 580 | const auto partition = singlePartition.has_value() ? singlePartition.value() |
| 581 | : spillPartitions_[row]; |
| 582 | if (!spiller_->isSpilled(partition)) { |
| 583 | rawNonSpillInputIndicesBuffer_[numNonSpillingInput++] = row; |
| 584 | continue; |
| 585 | } |
| 586 | rawSpillInputIndicesBuffers_[partition][numSpillInputs_[partition]++] = row; |
| 587 | } |
| 588 | if (numNonSpillingInput == numInput) { |
| 589 | return; |
| 590 | } |
| 591 | |
| 592 | // Ensure vector are lazy loaded before spilling. |
| 593 | for (int32_t i = 0; i < input->childrenSize(); ++i) { |
| 594 | input->childAt(i)->loadedVector(); |
| 595 | } |
| 596 | |
| 597 | for (int32_t partition = 0; partition < numSpillInputs_.size(); ++partition) { |
| 598 | const auto numSpillInputs = numSpillInputs_[partition]; |
| 599 | if (numSpillInputs == 0) { |
| 600 | continue; |
| 601 | } |
| 602 | BOLT_CHECK(spiller_->isSpilled(partition)); |
| 603 | spiller_->spill( |
| 604 | partition, |
| 605 | wrapAndCombineDict( |
| 606 | numSpillInputs, spillInputIndicesBuffers_[partition], input)); |
| 607 | } |
| 608 | |
| 609 | if (numNonSpillingInput == 0) { |
| 610 | input = nullptr; |
| 611 | } else { |
| 612 | input = wrapAndCombineDict( |
| 613 | numNonSpillingInput, nonSpillInputIndicesBuffer_, input); |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | void HashProbe::prepareInputIndicesBuffers( |
| 618 | vector_size_t numInput, |
nothing calls this directly
no test coverage detected