2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2015-01-25 21:03:20 +08:00
|
|
|
|
#include <vector>
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stdlib/string.hpp"
|
|
|
|
|
#include "redis_command.hpp"
|
2015-01-25 21:03:20 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2015-01-25 21:03:20 +08:00
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class redis_client;
|
2015-04-12 21:37:17 +08:00
|
|
|
|
class redis_client_cluster;
|
2015-01-25 21:03:20 +08:00
|
|
|
|
|
2015-03-27 17:05:12 +08:00
|
|
|
|
class ACL_CPP_API redis_hyperloglog : virtual public redis_command
|
2015-01-25 21:03:20 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
2015-03-29 19:27:41 +08:00
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command()
|
|
|
|
|
*/
|
2016-01-17 13:35:12 +08:00
|
|
|
|
redis_hyperloglog(void);
|
2015-03-29 19:27:41 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command(redis_client*)
|
|
|
|
|
*/
|
2015-03-27 17:05:12 +08:00
|
|
|
|
redis_hyperloglog(redis_client* conn);
|
2015-03-29 19:27:41 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2016-05-22 09:10:34 +08:00
|
|
|
|
* see redis_command::redis_command(redis_client_cluster*, size_t)
|
2015-03-29 19:27:41 +08:00
|
|
|
|
*/
|
2016-01-17 13:35:12 +08:00
|
|
|
|
redis_hyperloglog(redis_client_cluster* cluster, size_t max_conns = 0);
|
2015-03-29 19:27:41 +08:00
|
|
|
|
|
2016-01-17 13:35:12 +08:00
|
|
|
|
virtual ~redis_hyperloglog(void);
|
2015-01-25 21:03:20 +08:00
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> HyperLogLog <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* add the specified elements to the specified HyperLogLog
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param key {const char*} ָ<EFBFBD><EFBFBD> key ֵ
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the key
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param first_element {const char*} Ԫ<EFBFBD>ؼ<EFBFBD><EFBFBD>ϵĵ<EFBFBD>һ<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the first element of the elements list, and the last must be NULL
|
|
|
|
|
* in the elements list
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* return the follow values:
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* 1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* successful, and the data was varied
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* nothing was changed after modifying the old data
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* -1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD> key <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> hyperloglog <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* error or the keh isn't a hyperloglog type
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-25 21:03:20 +08:00
|
|
|
|
int pfadd(const char* key, const char* first_element, ...);
|
|
|
|
|
int pfadd(const char* key, const std::vector<const char*>& elements);
|
|
|
|
|
int pfadd(const char* key, const std::vector<string>& elements);
|
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD> HyperLoglog ȥ<EFBFBD>غ<EFBFBD>Ԫ<EFBFBD>صĽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* return the approximated cardinality of the set(s) observed by
|
|
|
|
|
* the hyperloglog at key(s)
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param first_key {const char*} key <EFBFBD><EFBFBD><EFBFBD>ϵĵ<EFBFBD>һ<EFBFBD><EFBFBD> key<EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the firs key which must not be NULL of the keys list, and the
|
|
|
|
|
* last parameter must be NULL in keys' list
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>о<EFBFBD>ȥ<EFBFBD>غ<EFBFBD>Ԫ<EFBFBD>صĽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-25 21:03:20 +08:00
|
|
|
|
int pfcount(const char* first_key, ...);
|
|
|
|
|
int pfcount(const std::vector<const char*>& keys);
|
|
|
|
|
int pfcount(const std::vector<string>& keys);
|
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HyperLogLog <EFBFBD>ϲ<EFBFBD><EFBFBD><EFBFBD>merge<EFBFBD><EFBFBD>Ϊһ<EFBFBD><EFBFBD> HyperLogLog <EFBFBD><EFBFBD> <EFBFBD>ϲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* HyperLogLog <EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HyperLogLog <EFBFBD>Ŀɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵIJ<EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* merge multiple different hyperloglogs into a single one
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param dst {const char*} Ŀ<EFBFBD><EFBFBD><EFBFBD>洢 HyperLogLog <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ֵ
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the single key as the destination
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @param first_src {const char*} Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һ<EFBFBD><EFBFBD>Դ HyperLogLog <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the first source key which must not be NULL in the sources list,
|
|
|
|
|
* and the last one must be NULL showing the end of the list
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>/Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* HyperLogLog <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* true on success, false if the error or the dest/src are not
|
|
|
|
|
* hyperloglog
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-25 21:03:20 +08:00
|
|
|
|
bool pfmerge(const char* dst, const char* first_src, ...);
|
|
|
|
|
bool pfmerge(const char* dst, const std::vector<const char*>& keys);
|
|
|
|
|
bool pfmerge(const char* dst, const std::vector<string>& keys);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
2019-05-19 16:54:20 +08:00
|
|
|
|
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
|