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

Method partition

bolt/exec/HashPartitionFunction.cpp:73–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73std::optional<uint32_t> HashPartitionFunction::partition(
74 const RowVector& input,
75 std::vector<uint32_t>& partitions) {
76 if (hashers_.empty()) {
77 return 0u;
78 }
79
80 const auto size = input.size();
81 rows_.resize(size);
82 rows_.setAll();
83
84 hashes_.resize(size);
85 for (auto i = 0; i < hashers_.size(); ++i) {
86 auto& hasher = hashers_[i];
87 if (hasher->channel() != kConstantChannel) {
88 hashers_[i]->decode(*input.childAt(hasher->channel()), rows_);
89 hashers_[i]->hash(rows_, i > 0, hashes_);
90 } else {
91 hashers_[i]->hashPrecomputed(rows_, i > 0, hashes_);
92 }
93 }
94
95 partitions.resize(size);
96 if (hashBitRange_.has_value()) {
97 for (auto i = 0; i < size; ++i) {
98 partitions[i] = hashBitRange_->partition(hashes_[i]);
99 }
100 } else {
101 for (auto i = 0; i < size; ++i) {
102 partitions[i] = hashes_[i] % numPartitions_;
103 }
104 }
105
106 return std::nullopt;
107}
108
109std::unique_ptr<core::PartitionFunction> HashPartitionFunctionSpec::create(
110 int numPartitions) const {

Callers 6

spillInputMethod · 0.45
addInputMethod · 0.45
fillSpillRunsMethod · 0.45
addInputMethod · 0.45
spillInputMethod · 0.45

Calls 10

setAllMethod · 0.80
childAtMethod · 0.80
hashPrecomputedMethod · 0.80
has_valueMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
channelMethod · 0.45
decodeMethod · 0.45
hashMethod · 0.45

Tested by

no test coverage detected