morningman commented on a change in pull request #8555:
URL: https://github.com/apache/incubator-doris/pull/8555#discussion_r831276266
##########
File path: be/src/olap/hll.cpp
##########
@@ -333,7 +262,7 @@ bool HyperLogLog::deserialize(const Slice& slice) {
// NOTE(zc): Don't remove this check unless you known what
// you are doing. Because of history bug, we ingest some
- // invalid HLL data in storage, which ptr is nullptr.
+ // invalid HLL data in storge, which ptr is nullptr.
Review comment:
```suggestion
// invalid HLL data in storage, which ptr is nullptr.
```
##########
File path: be/src/olap/hll.h
##########
@@ -216,11 +153,10 @@ class HyperLogLog {
void clear() {
_type = HLL_DATA_EMPTY;
- delete[] _registers;
- _registers = nullptr;
- delete[] _explicit_data;
- _explicit_data = nullptr;
- _explicit_data_num = 0;
+ _hash_set.clear();
+ if (_registers.data != nullptr) {
+ ChunkAllocator::instance()->free(_registers);
Review comment:
_registers.data = nullptr;
##########
File path: be/src/olap/hll.cpp
##########
@@ -418,33 +353,32 @@ int64_t HyperLogLog::estimate_cardinality() const {
int num_zero_registers = 0;
for (int i = 0; i < HLL_REGISTERS_COUNT; ++i) {
- harmonic_mean += powf(2.0f, -_registers[i]);
+ harmonic_mean += powf(2.0f, -_registers.data[i]);
- if (_registers[i] == 0) {
+ if (_registers.data[i] == 0) {
++num_zero_registers;
}
}
harmonic_mean = 1.0f / harmonic_mean;
double estimate = alpha * num_streams * num_streams * harmonic_mean;
- // according to HyperLogLog current correction, if E is cardinal
+ // according to HerperLogLog current correction, if E is cardinal
Review comment:
```suggestion
// according to HyperLogLog current correction, if E is cardinal
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]