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

Method calculateJoinBits

bolt/exec/HashBuild.cpp:1814–1896  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1812
1813template <bool isRepartition>
1814bool HashBuild::calculateJoinBits(
1815 uint8_t maxjoinBits,
1816 uint64_t maxPartitionRowCount) {
1817 uint32_t numPartitions;
1818 uint64_t rowsInMem = table_->rows()->numRows();
1819
1820 uint64_t totalRowCnt{0}, processedRowCnt{0};
1821 if constexpr (!isRepartition) {
1822 operatorCtx_->traverseOpToGetRowCount(totalRowCnt, processedRowCnt);
1823 spillThreshold_ = rowsInMem;
1824 memoryUsedForFirstSpill_ = pool()->currentBytes();
1825
1826 if (totalRowCnt <= 0 || processedRowCnt <= 0) {
1827 LOG(INFO) << name() << " DO NOTHING!!! totalRowCnt=" << totalRowCnt
1828 << ", processedRowCnt=" << processedRowCnt;
1829 return false;
1830 }
1831
1832 int32_t maxPartitionRowCnt =
1833 std::min((uint64_t)maxHashTableBucketCount_, processedRowCnt);
1834 numPartitions =
1835 (totalRowCnt + maxPartitionRowCnt) / (maxPartitionRowCnt + 1);
1836 } else {
1837 if (maxPartitionRowCount > 0 && spillThreshold_.has_value()) {
1838 totalRowCnt = maxPartitionRowCount;
1839 processedRowCnt = spillThreshold_.value();
1840
1841 if (totalRowCnt <= 0 || processedRowCnt <= 0) {
1842 LOG(INFO) << name() << " DO NOTHING!!! totalRowCnt=" << totalRowCnt
1843 << ", processedRowCnt=" << processedRowCnt;
1844 return false;
1845 }
1846
1847 int32_t maxPartitionRowCnt =
1848 std::min((uint64_t)maxHashTableBucketCount_, processedRowCnt);
1849 numPartitions =
1850 (totalRowCnt + maxPartitionRowCnt) / (maxPartitionRowCnt + 1);
1851 } else {
1852 return false;
1853 }
1854 }
1855
1856 uint8_t estimatedJoinBits =
1857 sizeof(unsigned int) * CHAR_BIT - __builtin_clz(numPartitions);
1858
1859 uint32_t estimatedPartitions = 1 << estimatedJoinBits;
1860 if ((estimatedPartitions < spillConfig_->spillPartitionsAdaptiveThreshold &&
1861 numPartitions >= estimatedPartitions / 4 * 3) ||
1862 estimatedPartitions == numPartitions) {
1863 ++estimatedJoinBits;
1864 }
1865
1866 LOG(INFO) << name() << " totalRowCnt = " << totalRowCnt
1867 << ", processedRowCnt = " << processedRowCnt
1868 << ", maxHashTableSize = " << maxHashTableBucketCount_
1869 << ", rowsInMem = " << rowsInMem
1870 << ", numPartitions = " << numPartitions
1871 << ", estimatedJoinBits = " << (int)estimatedJoinBits

Callers

nothing calls this directly

Calls 10

succinctBytesFunction · 0.85
has_valueMethod · 0.80
poolFunction · 0.50
minFunction · 0.50
numRowsMethod · 0.45
rowsMethod · 0.45
currentBytesMethod · 0.45
valueMethod · 0.45
reservedBytesMethod · 0.45

Tested by

no test coverage detected