mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-12-23 10:41:50 +01:00
ef4c5eb65e
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
18 lines
402 B
C++
18 lines
402 B
C++
#pragma once
|
|
#ifdef __cplusplus
|
|
namespace twml {
|
|
|
|
inline int64_t mixDiscreteIdAndValue(int64_t key, int64_t value) {
|
|
key ^= ((17LL + value) * 2654435761LL);
|
|
return key;
|
|
}
|
|
|
|
inline int64_t mixStringIdAndValue(int64_t key, int32_t str_len, const uint8_t *str) {
|
|
int32_t hash = 0;
|
|
for (int32_t i = 0; i < str_len; i++) {
|
|
hash = (31 * hash) + (int32_t)str[i];
|
|
}
|
|
return key ^ hash;
|
|
}
|
|
}
|
|
#endif |