php - redis的HyperLogLog有什么用?
高洛峰
高洛峰 2017-04-11 10:28:16
[PHP讨论组]

如果是单纯计算基数的话,使用HyperLogLog之前还得先一个一个PFADD,我在业务代码(php,java)中调用PFADD的时候换成用increment给一个string类型的专门用于统计基数的键来计算不就好了嘛?

所以说是我的用法不正确吗?HyperLogLog应该是在哪种场景下使用?如何正确科学的使用?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回复(1)
伊谢尔伦

维基百科上有写的啊:

approximating the number of distinct elements in a multiset. Calculating the exact cardinality of a multiset requires an amount of memory proportional to the cardinality, which is impractical for very large data sets. Probabilistic cardinality estimators, such as the HyperLogLog algorithm, use significantly less memory than this, at the cost of obtaining only an approximation of the cardinality.

简单来说就是用正确性换空间。如果你的数据量不大当然用不上。比如你的移动应用有多少个安装(使用 UUID 标识的)。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号