acl  3.5.3.0
redis_hyperloglog.hpp
浏览该文件的文档.
1 #pragma once
2 #include "../acl_cpp_define.hpp"
3 #include <vector>
4 #include "../stdlib/string.hpp"
5 #include "redis_command.hpp"
6 
7 #if !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
8 
9 namespace acl
10 {
11 
13 {
14 public:
15  /**
16  * see redis_command::redis_command()
17  */
18  redis_hyperloglog(void);
19 
20  /**
21  * see redis_command::redis_command(redis_client*)
22  */
24 
25  /**
26  * see redis_command::redis_command(redis_client_cluster*)
27  */
29 
31  redis_hyperloglog(redis_client_cluster* cluster, size_t max_conns);
32 
34 
35  virtual ~redis_hyperloglog(void);
36 
37  /**
38  * 将任意数量的元素添加到指定的 HyperLogLog 里面
39  * add the specified elements to the specified HyperLogLog
40  * @param key {const char*} 指定 key 值
41  * the key
42  * @param first_element {const char*} 元素集合的第一个元素值,非空字符串
43  * the first element of the elements list, and the last must be NULL
44  * in the elements list
45  * @return {int} 操作是否成功,同时表明是否发生了变更,返回值含义如下:
46  * return the follow values:
47  * 1:操作成功,且数据发生了变更(新增数据或老数据发生变更)
48  * successful, and the data was varied
49  * 0:修改老数据未发生变化
50  * nothing was changed after modifying the old data
51  * -1:出错或对应的 key 对象非 hyperloglog 对象
52  * error or the keh isn't a hyperloglog type
53  */
54  int pfadd(const char* key, const char* first_element, ...);
55  int pfadd(const char* key, const std::vector<const char*>& elements);
56  int pfadd(const char* key, const std::vector<string>& elements);
57 
58  /**
59  * 获得给定键列表的 HyperLoglog 去重后元素的近似数量
60  * return the approximated cardinality of the set(s) observed by
61  * the hyperloglog at key(s)
62  * @param first_key {const char*} key 集合的第一个 key,非空字符串
63  * the firs key which must not be NULL of the keys list, and the
64  * last parameter must be NULL in keys' list
65  * @return {int} 键列表集合中经去重后元素的近似数量
66  */
67  int pfcount(const char* first_key, ...);
68  int pfcount(const std::vector<const char*>& keys);
69  int pfcount(const std::vector<string>& keys);
70 
71  /**
72  * 将多个 HyperLogLog 合并(merge)为一个 HyperLogLog , 合并后的
73  * HyperLogLog 的基数接近于所有输入 HyperLogLog 的可见集合的并集
74  * merge multiple different hyperloglogs into a single one
75  * @param dst {const char*} 目标存储 HyperLogLog 对象的键值
76  * the single key as the destination
77  * @param first_src {const char*} 源对象集合中第一个源 HyperLogLog 对象的键
78  * the first source key which must not be NULL in the sources list,
79  * and the last one must be NULL showing the end of the list
80  * @return {bool} 操作是否成功,返回 false 表明出错或目标/源对象非
81  * HyperLogLog 对象
82  * true on success, false if the error or the dest/src are not
83  * hyperloglog
84  */
85  bool pfmerge(const char* dst, const char* first_src, ...);
86  bool pfmerge(const char* dst, const std::vector<const char*>& keys);
87  bool pfmerge(const char* dst, const std::vector<string>& keys);
88 };
89 
90 } // namespace acl
91 
92 #endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
#define ACL_CPP_DEPRECATED
Definition: atomic.hpp:86
#define ACL_CPP_API