本文整理汇总了C++中Ardb::ZCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Ardb::ZCount方法的具体用法?C++ Ardb::ZCount怎么用?C++ Ardb::ZCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ardb
的用法示例。
在下文中一共展示了Ardb::ZCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_zsets_zcount
void test_zsets_zcount(Ardb& db)
{
DBID dbid = 0;
db.ZClear(dbid, "myzset");
db.ZAdd(dbid, "myzset", ValueData((int64) 1), "one");
db.ZAdd(dbid, "myzset", ValueData((int64) 2), "two");
db.ZAdd(dbid, "myzset", ValueData((int64) 3), "three");
int count = db.ZCount(dbid, "myzset", "-inf", "+inf");
CHECK_FATAL(count != 3, "Fail:%d", count);
count = db.ZCount(dbid, "myzset", "(1", "3");
CHECK_FATAL(count != 2, "Fail:%d", count);
}
示例2: test_zsets_zrank
void test_zsets_zrank(Ardb& db)
{
DBID dbid = 0;
db.ZClear(dbid, "myzset");
db.ZAdd(dbid, "myzset", ValueData((int64) 1), "one");
db.ZAdd(dbid, "myzset", ValueData((int64) 2), "two");
db.ZAdd(dbid, "myzset", ValueData((int64) 3), "three");
db.ZCount(dbid, "myzset", "-inf", "+inf");
int rank = db.ZRank(dbid, "myzset", "three");
CHECK_FATAL(rank != 2, "Fail:%d", rank);
db.ZClear(dbid, "myzset");
uint32 maxzsetsize = 100000;
uint64 start = get_current_epoch_millis();
for (uint32 i = 0; i < maxzsetsize; i++)
{
char value[16];
sprintf(value, "value%u", i);
db.ZAdd(dbid, "myzset", ValueData((int64) i), value);
}
uint64 end = get_current_epoch_millis();
INFO_LOG("Cost %lldms to write %u zset elements", (end - start), maxzsetsize);
start = get_current_epoch_millis();
rank = db.ZRank(dbid, "myzset", "value50001");
CHECK_FATAL(rank != 50001, "Fail:%d", rank);
end = get_current_epoch_millis();
INFO_LOG("Cost %lldms to rank.", (end - start));
}