| 396 | } |
| 397 | |
| 398 | void writeSpillData(const std::vector<RowVectorPtr>& batches) { |
| 399 | vector_size_t numRows = 0; |
| 400 | for (const auto& batch : batches) { |
| 401 | numRows += batch->size(); |
| 402 | } |
| 403 | if (rowVector_ == nullptr) { |
| 404 | rowVector_ = |
| 405 | BaseVector::create<RowVector>(rowType_, numRows, pool_.get()); |
| 406 | } |
| 407 | rows_.resize(numRows); |
| 408 | for (int i = 0; i < numRows; ++i) { |
| 409 | rows_[i] = rowContainer_->newRow(); |
| 410 | } |
| 411 | |
| 412 | vector_size_t nextRow = 0; |
| 413 | for (const auto& batch : batches) { |
| 414 | rowVector_->append(batch.get()); |
| 415 | const SelectivityVector allRows(batch->size()); |
| 416 | for (int index = 0; index < batch->size(); ++index, ++nextRow) { |
| 417 | for (int i = 0; i < rowType_->size(); ++i) { |
| 418 | DecodedVector decodedVector(*batch->childAt(i), allRows); |
| 419 | rowContainer_->store(decodedVector, index, rows_[nextRow], i); |
| 420 | } |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | void sortSpillData(bool ascending = true) { |
| 426 | partitions_.clear(); |