| 1526 | |
| 1527 | template<typename T> |
| 1528 | void AggregateFunctions::PcUpdate(FunctionContext* c, const T& input, StringVal* dst) { |
| 1529 | DCHECK_EQ(dst->len, PC_INTERMEDIATE_BYTES); |
| 1530 | if (input.is_null) return; |
| 1531 | // Core of the algorithm. This is a direct translation of the code in the paper. |
| 1532 | // Please see the paper for details. For simple averaging, we need to compute hash |
| 1533 | // values NUM_PC_BITMAPS times using NUM_PC_BITMAPS different hash functions (by using a |
| 1534 | // different seed). |
| 1535 | for (int i = 0; i < NUM_PC_BITMAPS; ++i) { |
| 1536 | uint32_t hash_value = AnyValUtil::Hash(input, *c->GetArgType(0), i); |
| 1537 | const int bit_index = BitUtil::CountTrailingZeros(hash_value, PC_BITMAP_LENGTH - 1); |
| 1538 | // Set bitmap[i, bit_index] to 1 |
| 1539 | SetDistinctEstimateBit(dst->ptr, i, bit_index); |
| 1540 | } |
| 1541 | } |
| 1542 | |
| 1543 | template<typename T> |
| 1544 | void AggregateFunctions::PcsaUpdate(FunctionContext* c, const T& input, StringVal* dst) { |
nothing calls this directly
no test coverage detected