acl/lib_acl_cpp/include/acl_cpp/redis/redis_hyperloglog.hpp

87 lines
3.1 KiB
C++
Raw Normal View History

#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include <vector>
#include "acl_cpp/stdlib/string.hpp"
#include "acl_cpp/redis/redis_command.hpp"
namespace acl
{
class redis_client;
2015-04-12 21:37:17 +08:00
class redis_client_cluster;
class ACL_CPP_API redis_hyperloglog : virtual public redis_command
{
public:
2015-03-29 19:27:41 +08:00
/**
* see redis_command::redis_command()
*/
redis_hyperloglog(void);
2015-03-29 19:27:41 +08:00
/**
* see redis_command::redis_command(redis_client*)
*/
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
*/
redis_hyperloglog(redis_client_cluster* cluster, size_t max_conns = 0);
2015-03-29 19:27:41 +08:00
virtual ~redis_hyperloglog(void);
2015-01-29 00:38:29 +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
2015-01-29 00:38:29 +08:00
* @param key {const char*} ָ<EFBFBD><EFBFBD> key ֵ
2015-04-12 21:37:17 +08:00
* the key
2015-01-29 00:38:29 +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
2015-01-29 00:38:29 +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:
2015-01-29 00:38:29 +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
2015-01-29 00:38:29 +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
2015-01-29 00:38:29 +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
*/
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
/**
* <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)
2015-01-29 00:38:29 +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
2015-01-29 00:38:29 +08:00
* @return {int} <EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>о<EFBFBD>ȥ<EFBFBD>غ<EFBFBD>Ԫ<EFBFBD>صĽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
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
/**
* <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
2015-01-29 00:38:29 +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
2015-01-29 00:38:29 +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
2015-01-29 00:38:29 +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
*/
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