| 198 | : columns_(columns), num_buckets_(num_buckets), hash_key_(hash_key) {} |
| 199 | |
| 200 | int64 Generate(const int64 batch_index, |
| 201 | const std::vector<int>& permutation) const { |
| 202 | // Do the fingerprint concatenation on uint64. |
| 203 | uint64 hashed_output = hash_key_; |
| 204 | for (size_t i = 0; i < permutation.size(); ++i) { |
| 205 | uint64 hash_i = columns_[i]->Feature(batch_index, permutation[i]); |
| 206 | hashed_output = FingerprintCat64(hashed_output, hash_i); |
| 207 | } |
| 208 | // The return value is int64 based on the number of buckets. |
| 209 | if (num_buckets_ > 0) { |
| 210 | return hashed_output % num_buckets_; |
| 211 | } else { |
| 212 | // To prevent negative output we take modulo to max int64. |
| 213 | return hashed_output % std::numeric_limits<int64>::max(); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | private: |
| 218 | const std::vector<std::unique_ptr<ColumnInterface<int64>>>& columns_; |
no test coverage detected