mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 11:33:46 +00:00
b7ef5a699c
* Get rid of non-existent vectorclass * Move FastMemcpy to contribs * Restore comments * Disable FastMemcpy on non-Linux * Fix cmake file * Don't build FastMemcpy for ARM64 * Replace FastMemcpy submodule with its contents * Fix cmake file * Move widechar_width to contrib/ * Move sumbur to contrib/ * Move consistent-hashing to contrib/ * Fix UBSan tests
20 lines
833 B
C++
20 lines
833 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
|
|
/*
|
|
* Author: Konstantin Oblakov
|
|
*
|
|
* Maps random ui64 x (in fact hash of some string) to n baskets/shards.
|
|
* Output value is id of a basket. 0 <= ConsistentHashing(x, n) < n.
|
|
* Probability of all baskets must be equal. Also, it should be consistent
|
|
* in terms, that with different n_1 < n_2 probability of
|
|
* ConsistentHashing(x, n_1) != ConsistentHashing(x, n_2) must be equal to
|
|
* (n_2 - n_1) / n_2 - the least possible with previous conditions.
|
|
* It requires O(1) memory and cpu to calculate. So, it is faster than classic
|
|
* consistent hashing algos with points on circle.
|
|
*/
|
|
std::size_t ConsistentHashing(std::uint64_t x, std::size_t n); // Works for n <= 32768
|
|
std::size_t ConsistentHashing(std::uint64_t lo, std::uint64_t hi, std::size_t n); // Works for n <= 2^31
|