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

Method estimateBytesPerRow

bolt/exec/TableScan.cpp:536–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534}
535
536void TableScan::estimateBytesPerRow(
537 const std::optional<RowVectorPtr>& dataOptional) {
538 if (!enableEstimateBytesPerRow_ || !dataOptional || !dataOptional.value()) {
539 return;
540 }
541 auto size = dataOptional.value()->size();
542 if (size <= 0) {
543 return;
544 }
545
546 auto batchByets = dataOptional.value()->usedSize();
547 auto bytesPerRow = batchByets / size;
548
549 auto adjustBatchSizeFactor = [this]() {
550 estimateBatchSizeFactor_ =
551 std::max(estimateBatchSizeFactor_ / 2, MinEstimateBatchSizeFactor);
552 };
553 auto isLargeDiff = [this](int64_t l, int64_t r, int32_t multiples) -> bool {
554 return l * multiples / estimateBatchSizeFactor_ < r ||
555 l > r * multiples / estimateBatchSizeFactor_;
556 };
557
558 if (bytesPerRowAverage_ > 0 &&
559 isLargeDiff(bytesPerRow, bytesPerRowAverage_, 5)) {
560 adjustBatchSizeFactor();
561 bytesPerRowAverage_ = 0;
562 } else if (
563 bytesPerRowLastBatch_.has_value() &&
564 isLargeDiff(bytesPerRow, bytesPerRowLastBatch_.value(), 3)) {
565 adjustBatchSizeFactor();
566 }
567 bytesPerRowLastBatch_ = bytesPerRow;
568}
569
570void TableScan::close() {
571 if (dataSource_) {

Callers

nothing calls this directly

Calls 5

has_valueMethod · 0.80
maxFunction · 0.50
valueMethod · 0.45
sizeMethod · 0.45
usedSizeMethod · 0.45

Tested by

no test coverage detected