redis中HyperLogLog的学习

0 环境

  • 系统环境: centos7
  • 编辑器: xshell
  • IDE:IDEA

1 前言

reids思维导图图片版总结

2 正文

1 准备

具体代码参考之前博客文章

2 代码

public class HyperLogLogTest {
    public static void main(String[] args) {

        CallRedisDemo redisDemo = new CallRedisDemo();
        redisDemo.execute(jedis -> {
            // 可以将n的值 改大 就能看出误差了 自行验证
        	int n = 200;
            // 添加 
            for (int i = 0; i < n; i++) {
                jedis.pfadd("uv", "user" + i, "user" + (i + 1));
//                System.out.println(i);
            }

            // 统计结果
            long uv = jedis.pfcount("uv");

            System.out.println(uv);

            jedis.del("uv");

        });

    }
}

3 结果验证

在这里插入图片描述

猜你喜欢

转载自www.cnblogs.com/my-ordinary/p/12703650.html
今日推荐