当前位置:网站首页>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 !
边栏推荐
猜你喜欢

LeetCode 2320. Count the number of ways to place the house

02_线性表_顺序表

基于RZ/G2L | OK-G2LD-C开发板存储读写速度与网络实测

02_ Linear table_ Sequence table

.NET Core 日志系统

21_ Redis_ Analysis of redis cache penetration and avalanche

Tidb data migration tool overview

LeetCode 209. Minimum length subarray

08_ strand

Dragonfly low code security tool platform development path
随机推荐
MFC timer usage
LeetCode_ Sliding window_ Medium_ 395. Longest substring with at least k repeated characters
15_Redis_Redis.conf详解
Dragonfly low code security tool platform development path
二叉树的遍历方式主要有:先序遍历、中序遍历、后序遍历、层次遍历。先序、中序、后序其实指的是父节点被访问的次序。若在遍历过程中,父节点先于它的子节点被访问,就是先序遍历;
kibana 基础操作
04_ Stack
XML Configuration File
Points clés de l'examen de principe de compilation pour l'année scolaire 2021 - 2022 [Université chinoise d'outre - mer]
【C语音】详解指针进阶和注意点(2)
HUSTPC2022
Learn the method code example of converting timestamp to uppercase date using PHP
About text selection in web pages and counting the length of selected text
CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E
02_线性表_顺序表
學習使用php實現公曆農曆轉換的方法代碼
[noi simulation] Elis (greedy, simulation)
How does CTO help the business?
Set set you don't know
【C语言】详解指针的初阶和进阶以及注意点(1)