MCPcopy Create free account
hub / github.com/apache/impala / HllUpdate

Function HllUpdate

be/src/udf_samples/hyperloglog-uda.cc:70–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70IMPALA_UDF_EXPORT
71void HllUpdate(FunctionContext* ctx, const IntVal& src, StringVal* dst) {
72 if (src.is_null) return;
73 assert(dst != NULL);
74 assert(!dst->is_null);
75 assert(dst->len == pow(2, HLL_PRECISION));
76 uint64_t hash_value = Hash(src);
77 // Use the lower bits to index into the number of streams and then find the first 1 bit
78 // after the index bits.
79 int idx = hash_value % dst->len;
80 const uint64_t hash_top_bits = hash_value >> HLL_PRECISION;
81 uint8_t first_one_bit =
82 1 + ((hash_top_bits != 0) ? __builtin_ctzll(hash_top_bits) :
83 (sizeof(hash_value) * CHAR_BIT - HLL_PRECISION));
84 dst->ptr[idx] = ::max(dst->ptr[idx], first_one_bit);
85}
86
87IMPALA_UDF_EXPORT
88void HllMerge(FunctionContext* ctx, const StringVal& src, StringVal* dst) {

Callers 2

HllUpdateMethod · 0.85
SampledNdvUpdateMethod · 0.85

Calls 2

HashFunction · 0.85
maxFunction · 0.85

Tested by

no test coverage detected