20 #ifndef KLL_HELPER_HPP_
21 #define KLL_HELPER_HPP_
28 extern uint32_t kll_next_offset;
32 static const uint64_t powers_of_three[] = {1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441,
33 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467,
34 3486784401, 10460353203, 31381059609, 94143178827, 282429536481,
35 847288609443, 2541865828329, 7625597484987, 22876792454961, 68630377364883,
40 static inline bool is_even(uint32_t value);
41 static inline bool is_odd(uint32_t value);
42 static inline uint8_t floor_of_log2_of_fraction(uint64_t numer, uint64_t denom);
43 static inline uint8_t ub_on_num_levels(uint64_t n);
44 static inline uint32_t compute_total_capacity(uint16_t k, uint8_t m, uint8_t num_levels);
45 static inline uint16_t level_capacity(uint16_t k, uint8_t numLevels, uint8_t height, uint8_t min_wid);
46 static inline uint16_t int_cap_aux(uint16_t k, uint8_t depth);
47 static inline uint16_t int_cap_aux_aux(uint16_t k, uint8_t depth);
48 static inline uint64_t sum_the_sample_weights(uint8_t num_levels,
const uint32_t* levels);
51 static void randomly_halve_down(T* buf, uint32_t start, uint32_t length);
54 static void randomly_halve_up(T* buf, uint32_t start, uint32_t length);
59 template <
typename T,
typename C>
60 static void merge_sorted_arrays(T* buf, uint32_t start_a, uint32_t len_a, uint32_t start_b, uint32_t len_b, uint32_t start_c);
66 template <
typename T,
typename C>
67 static void merge_sorted_arrays(
const T* buf_a, uint32_t start_a, uint32_t len_a,
const T* buf_b, uint32_t start_b, uint32_t len_b, T* buf_c, uint32_t start_c);
69 struct compress_result {
70 uint8_t final_num_levels;
71 uint32_t final_capacity;
72 uint32_t final_num_items;
92 template <
typename T,
typename C>
93 static compress_result general_compress(uint16_t k, uint8_t m, uint8_t num_levels_in, T* items,
94 uint32_t* in_levels, uint32_t* out_levels,
bool is_level_zero_sorted);
97 static void copy_construct(
const T* src,
size_t src_first,
size_t src_last, T* dst,
size_t dst_first);
100 static void move_construct(T* src,
size_t src_first,
size_t src_last, T* dst,
size_t dst_first,
bool destroy);
102 #ifdef KLL_VALIDATION
105 static inline uint32_t deterministic_offset();
112 #include "kll_helper_impl.hpp"
DataSketches namespace.
Definition: binomial_bounds.hpp:38