houqp commented on a change in pull request #1095: URL: https://github.com/apache/arrow-datafusion/pull/1095#discussion_r725709058
########## File path: datafusion/src/physical_plan/hyperloglog/mod.rs ########## @@ -0,0 +1,295 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! # HyperLogLog +//! +//! `hyperloglog` is a module that contains a modified version +//! of [redis's implementation](https://github.com/redis/redis/blob/4930d19e70c391750479951022e207e19111eb55/src/hyperloglog.c) +//! with some modification based on strong assumption of usage +//! within datafusion, so that [`approx_distinct`] function can +//! be efficiently implemented. +//! +//! Specifically, like Redis's version, this HLL structure uses +//! 2**14 = 16384 registers, which means the standard error is +//! 1.04/(16384**0.5) = 0.8125%. Unlike Redis, the register takes +//! up full [`u8`] size instead of a raw int* and thus saves some +//! tricky bit shifting techniques used in the original version. +//! This results in a memory usage increase from 12Kib to 16Kib. +//! Also only the dense version is adopted, so there's no automatic +//! conversion, largely to simplify the code. +//! +//! This module also borrows some code structure from [pdatastructs.rs](https://github.com/crepererum/pdatastructs.rs/blob/3997ed50f6b6871c9e53c4c5e0f48f431405fc63/src/hyperloglog.rs). Review comment: I think we might need to give credit to pdatastructs in NOTICE.txt as well if we are forking the code base. -- 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]
