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

93 lines
3.2 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "../acl_cpp_define.hpp"
#include <vector>
2017-06-02 14:47:24 +08:00
#include "../stdlib/string.hpp"
#include "redis_command.hpp"
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
namespace acl
{
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
/**
* see redis_command::redis_command(redis_client_cluster*)
2015-03-29 19:27:41 +08:00
*/
redis_hyperloglog(redis_client_cluster* cluster);
ACL_CPP_DEPRECATED
redis_hyperloglog(redis_client_cluster* cluster, size_t max_conns);
2015-03-29 19:27:41 +08:00
redis_hyperloglog(redis_client_pipeline* pipeline);
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
* @param key {const char*} ָ<EFBFBD><EFBFBD> key ֵ
2015-04-12 21:37:17 +08:00
* the key
* @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
* @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:
* 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
* 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
* -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)
* @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
* @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
*/
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
* @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
* @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
* @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
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)