MCPcopy Create free account
hub / github.com/bytedance/bolt / nextPartition

Method nextPartition

bolt/exec/SpillableWindowBuild.cpp:525–631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523
524template <bool needSort>
525std::shared_ptr<WindowPartition>
526SpillableWindowBuild<needSort>::nextPartition() {
527 BOLT_CHECK_GT(partitionStartRows_.size(), 0, "No window partitions available")
528 currentPartition_++;
529 BOLT_CHECK_LE(
530 currentPartition_,
531 partitionStartRows_.size() - 2,
532 "All window partitions consumed");
533 if (rowBasedSpillSortMerger_ != nullptr) {
534 BOLT_CHECK_LE(
535 currentPartition_,
536 partitionStartRows_.size() - 2,
537 "All window partitions consumed");
538
539 if (currentPartition_ > 0 &&
540 partitionStartRows_.size() - currentPartition_ <= 3) {
541 auto numPreviousPartitionRows = partitionStartRows_[currentPartition_];
542
543 auto lastEraseBuffer =
544 (lastErasePartition_ == -1) ? 0 : numBuffers_[lastErasePartition_];
545 int i = lastEraseBuffer;
546
547 for (; i < numBuffers_[currentPartition_ - 1]; i++) {
548 data_->pool()->free(allocatedStarts_[i], allocatedSizes_[i]);
549 allocatedSizes_[i] = 0;
550 }
551 lastErasePartition_ = currentPartition_ - 1;
552
553 sortedRows_.erase(
554 sortedRows_.begin(), sortedRows_.begin() + numPreviousPartitionRows);
555 for (int i = currentPartition_; i < partitionStartRows_.size(); i++) {
556 partitionStartRows_[i] =
557 partitionStartRows_[i] - numPreviousPartitionRows;
558 }
559 }
560 } else {
561 // Erase previous partition.
562 if ((!needSort && currentPartition_ > 0 &&
563 partitionStartRows_.size() - currentPartition_ <= 3)) {
564 auto numPreviousPartitionRows = partitionStartRows_[currentPartition_];
565 if (numPreviousPartitionRows > 0) {
566 data_->eraseRows(
567 folly::Range<char**>(sortedRows_.data(), numPreviousPartitionRows));
568 sortedRows_.erase(
569 sortedRows_.begin(),
570 sortedRows_.begin() + numPreviousPartitionRows);
571 for (int i = currentPartition_; i < partitionStartRows_.size(); i++) {
572 partitionStartRows_[i] =
573 partitionStartRows_[i] - numPreviousPartitionRows;
574 }
575 }
576 }
577 }
578
579 auto partitionSize = partitionStartRows_[currentPartition_ + 1] -
580 partitionStartRows_[currentPartition_];
581 auto partition = folly::Range(
582 sortedRows_.data() + partitionStartRows_[currentPartition_],

Callers

nothing calls this directly

Calls 12

eraseRowsMethod · 0.80
RangeClass · 0.50
sizeMethod · 0.45
freeMethod · 0.45
poolMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45
cleanUpMethod · 0.45
getMethod · 0.45
statsMethod · 0.45

Tested by

no test coverage detected