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

Method HllUpdate

be/src/exprs/aggregate-functions-ir.cc:2139–2156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2137// Always inline in IR so that constants can be replaced.
2138template <typename T>
2139IR_ALWAYS_INLINE void AggregateFunctions::HllUpdate(
2140 FunctionContext* ctx, const T& src, StringVal* dst, int precision) {
2141 if (src.is_null) return;
2142 DCHECK(!dst->is_null);
2143
2144 const int& hll_len = dst->len;
2145 DCHECK_IN_RANGE(hll_len, MIN_HLL_LEN, MAX_HLL_LEN);
2146
2147 uint64_t hash_value =
2148 AnyValUtil::Hash64(src, *ctx->GetArgType(0), HashUtil::FNV64_SEED);
2149 // Use the lower bits to index into the number of streams and then find the first 1 bit
2150 // after the index bits.
2151 int idx = hash_value & (hll_len - 1);
2152 const uint8_t first_one_bit = 1
2153 + BitUtil::CountTrailingZeros(
2154 hash_value >> precision, sizeof(hash_value) * CHAR_BIT - precision);
2155 dst->ptr[idx] = ::max(dst->ptr[idx], first_one_bit);
2156}
2157
2158// Update function for NDV() that accepts an expression only.
2159template <typename T>

Callers

nothing calls this directly

Calls 6

maxFunction · 0.85
HllUpdateFunction · 0.85
GetArgTypeMethod · 0.80
GetConstFnAttrMethod · 0.80
implMethod · 0.80

Tested by

no test coverage detected