当前位置:网站首页>11_ Redis_ Hyperloglog_ command
11_ Redis_ Hyperloglog_ command
2022-07-02 15:19:00 【Listen to the rain】
Hyperloglog
What is the cardinality ?
A{ 1,3,5,7,8,7 }
B{ 1,3,5,7,8 }
base ( Elements that don't repeat ) = 5, The error is acceptable !
brief introduction
Redis 2.8.9 The version is updated Hyperloglog data structure !
Redis Hyperloglog The algorithm of cardinality Statistics !
advantage : The memory occupied is fixed ,2^64 Different elements of Technology , Just waste 12KB Memory ! If you want to compare from the memory point of view Hyperloglog The preferred !
Web page UV( A person visits a website many times , But still count as a person ! ) 0.81% Error rate ! Statistics UV Mission , Negligible !
The traditional way ,set( Elements are not allowed to repeat ) Save the user's id, And then you can count set The number of elements in as a standard judgment !
This way, if you save a large number of users id, It will be more troublesome ! Our purpose is to count , Instead of saving users id;
127.0.0.1:6379> PFADD mykey a b c d e f g h i j k // Create the first set of elements
(integer) 1
127.0.0.1:6379> PFCOUNT mykey // Statistics mykey The cardinal number of elements
(integer) 11
127.0.0.1:6379> PFADD mykey2 i j k z d e // Create a second set of elements mykey2
(integer) 1
127.0.0.1:6379> PFCOUNT mykey2
(integer) 6
127.0.0.1:6379> PFMERGE mykey3 mykey mykey2 // Combine the two groups mykey mykey2 => mykey3 Combine
OK
127.0.0.1:6379> PFCOUNT mykey3 // Look at the number of unions !
(integer) 12
If fault tolerance is allowed , Then it must be possible to use Hyperloglog
If fault tolerance is not allowed , Just use set Or your own data type !
边栏推荐
猜你喜欢
随机推荐
TiDB数据迁移场景综述
Mfc a dialog calls B dialog function and passes parameters
05_ queue
数据分析常见的英文缩写(一)
Mavn 搭建 Nexus 私服
21_ Redis_ Analysis of redis cache penetration and avalanche
可视化搭建页面工具的前世今生
. Net core logging system
vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)
Internet Explorer officially retired
如何对 TiDB 进行 TPC-C 测试
Printf function and scanf function in C language
Huawei interview question: no palindrome string
Introduction to mathjax (web display of mathematical formulas, vector)
Principles, language, compilation, interpretation
解决el-radio-group 回显后不能编辑问题
Record an error report, solve the experience, rely on repetition
871. Minimum refueling times: simple priority queue (heap) greedy question
C语言中的算术运算及相关练习题
16_Redis_Redis持久化

![[noi Simulation Competition] scraping (dynamic planning)](/img/ee/27a07f80207a2925f5065e633eb39f.png)







