-
Notifications
You must be signed in to change notification settings - Fork 952
Expand file tree
/
Copy pathredis_hyperloglog.cpp
More file actions
126 lines (101 loc) · 2.6 KB
/
redis_hyperloglog.cpp
File metadata and controls
126 lines (101 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "acl_stdafx.hpp"
#ifndef ACL_PREPARE_COMPILE
#include "acl_cpp/redis/redis_client.hpp"
#include "acl_cpp/redis/redis_hyperloglog.hpp"
#endif
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
namespace acl {
redis_hyperloglog::redis_hyperloglog()
{
}
redis_hyperloglog::redis_hyperloglog(redis_client* conn)
: redis_command(conn)
{
}
redis_hyperloglog::redis_hyperloglog(redis_client_cluster* cluster)
: redis_command(cluster)
{
}
redis_hyperloglog::redis_hyperloglog(redis_client_cluster* cluster, size_t)
: redis_command(cluster)
{
}
redis_hyperloglog::redis_hyperloglog(redis_client_pipeline* pipeline)
: redis_command(pipeline)
{
}
redis_hyperloglog::~redis_hyperloglog()
{
}
int redis_hyperloglog::pfadd(const char* key, const char* first_element, ...)
{
std::vector<const char*> elements;
elements.push_back(first_element);
va_list ap;
va_start(ap, first_element);
const char* element;
while ((element = va_arg(ap, const char*)) != NULL)
elements.push_back(element);
va_end(ap);
return pfadd(key, elements);
}
int redis_hyperloglog::pfadd(const char* key,
const std::vector<const char*>& elements)
{
build("PFADD", key, elements);
return get_number();
}
int redis_hyperloglog::pfadd(const char* key,
const std::vector<string>& elements)
{
build("PFADD", key, elements);
return get_number();
}
int redis_hyperloglog::pfcount(const char* first_key, ...)
{
std::vector<const char*> keys;
keys.push_back(first_key);
va_list ap;
va_start(ap, first_key);
const char* key;
while ((key = va_arg(ap, const char*)) != NULL)
keys.push_back(key);
va_end(ap);
return pfcount(keys);
}
int redis_hyperloglog::pfcount(const std::vector<const char*>& keys)
{
build("PFCOUNT", NULL, keys);
return get_number();
}
int redis_hyperloglog::pfcount(const std::vector<string>& keys)
{
build("PFCOUNT", NULL, keys);
return get_number();
}
bool redis_hyperloglog::pfmerge(const char* dst, const char* first_src, ...)
{
std::vector<const char*> keys;
keys.push_back(first_src);
va_list ap;
va_start(ap, first_src);
const char* src;
while ((src = va_arg(ap, const char*)) != NULL)
keys.push_back(src);
va_end(ap);
return pfmerge(dst, keys);
}
bool redis_hyperloglog::pfmerge(const char* dst,
const std::vector<const char*>& keys)
{
build("PFMERGE", dst, keys);
return check_status();
}
bool redis_hyperloglog::pfmerge(const char* dst,
const std::vector<string>& keys)
{
build("PFMERGE", dst, keys);
return check_status();
}
} // namespace acl
#endif // ACL_CLIENT_ONLY