MCPcopy Create free account
hub / github.com/acl-dev/acl / test_pfadd

Function test_pfadd

lib_acl_cpp/samples/redis/redis_hyperloglog/redis_hyperloglog.cpp:5–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3static const char* __keypre = "hyperloglog_";
4
5static bool test_pfadd(acl::redis_hyperloglog& redis, int n)
6{
7 acl::string key, element;
8 std::vector<acl::string> elements;
9
10 elements.reserve(1000);
11 for (int i = 0; i < 1000; i++)
12 {
13 element.format("element_%d", i);
14 elements.push_back(element);
15 }
16
17 for (int i = 0; i < n; i++)
18 {
19 key.format("%s_key_%d", __keypre, i);
20
21 redis.clear();
22 int ret = redis.pfadd(key.c_str(), elements);
23 if (ret < 0)
24 {
25 printf("pfadd error: %s, key: %s\r\n",
26 redis.result_error(), key.c_str());
27 return false;
28 }
29
30 if (i >= 10)
31 continue;
32
33 printf("pfadd ok\r\n");
34 }
35
36 return true;
37}
38
39static bool test_pfcount(acl::redis_hyperloglog& redis, int n)
40{

Callers 1

mainFunction · 0.85

Calls 7

pfaddMethod · 0.80
result_errorMethod · 0.80
reserveMethod · 0.45
formatMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…