| 71 | } |
| 72 | |
| 73 | std::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 | |
| 109 | std::unique_ptr<core::PartitionFunction> HashPartitionFunctionSpec::create( |
| 110 | int numPartitions) const { |
no test coverage detected