本文整理汇总了C++中ZIterator::next方法的典型用法代码示例。如果您正苦于以下问题:C++ ZIterator::next方法的具体用法?C++ ZIterator::next怎么用?C++ ZIterator::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZIterator
的用法示例。
在下文中一共展示了ZIterator::next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: proc_zrscan
int proc_zrscan(NetworkServer *net, Link *link, const Request &req, Response *resp){
SSDBServer *serv = (SSDBServer *)net->data;
CHECK_NUM_PARAMS(6);
uint64_t limit = req[5].Uint64();
uint64_t offset = 0;
if(req.size() > 6){
offset = limit;
limit = offset + req[6].Uint64();
}
ZIterator *it = serv->ssdb->zrscan(req[1], req[2], req[3], req[4], limit);
if(offset > 0){
it->skip(offset);
}
resp->push_back("ok");
uint64_t size = 0;
while(it->next()){
size += it->key.size() + it->score.size();
CHECK_SCAN_OUTPUT_LIMIT(size);
resp->push_back(it->key);
resp->push_back(it->score);
}
delete it;
return 0;
}
示例2: proc_zclear
int proc_zclear(NetworkServer *net, Link *link, const Request &req, Response *resp){
SSDBServer *serv = (SSDBServer *)net->data;
CHECK_NUM_PARAMS(2);
const Bytes &name = req[1];
int64_t count = 0;
while(1){
ZIterator *it = serv->ssdb->zrange(name, 0, 1000);
int num = 0;
while(it->next()){
int ret = serv->ssdb->zdel(name, it->key);
if(ret == -1){
resp->push_back("error");
delete it;
return 0;
}
num ++;
};
delete it;
if(num == 0){
break;
}
count += num;
}
serv->save_kv_stats();
resp->reply_int(0, count);
return 0;
}
示例3: proc_zremrangebyrank
static int proc_zremrangebyrank(Server *serv, Link *link, const Request &req, Response *resp){
if(req.size() < 4){
resp->push_back("client_error");
return 0;
}
uint64_t offset = req[2].Uint64();
uint64_t limit = req[3].Uint64();
ZIterator *it = serv->ssdb->zrange(req[1], offset, limit);
uint64_t count = 0;
while(it->next()){
count ++;
int ret = serv->ssdb->zdel(req[1], it->key);
if(ret == -1){
resp->push_back("error");
delete it;
return 0;
}
}
delete it;
char buf[20];
snprintf(buf, sizeof(buf), "%" PRIu64 "", count);
resp->push_back("ok");
resp->push_back(buf);
return 0;
}
示例4: proc_zclear
static int proc_zclear(Server *serv, Link *link, const Request &req, Response *resp){
if(req.size() < 2){
resp->push_back("client_error");
return 0;
}
const Bytes &name = req[1];
uint64_t total = 0;
while(1){
ZIterator *it = serv->ssdb->zrange(name, 0, 1000);
int num = 0;
while(it->next()){
int ret = serv->ssdb->zdel(name, it->key);
if(ret == -1){
resp->push_back("error");
delete it;
return 0;
}
num ++;
};
delete it;
if(num == 0){
break;
}
total += num;
}
char buf[20];
snprintf(buf, sizeof(buf), "%" PRIu64 "", total);
resp->push_back("ok");
resp->push_back(buf);
return 0;
}
示例5: proc_zkeys
int CommandProc::proc_zkeys(const Link &link, const Request &req, Response *resp){
if(req.size() < 6){
resp->push_back("client_error");
}else{
int limit = req[5].Int();
ZIterator *it = ssdb->zscan(req[1], req[2], req[3], req[4], limit);
resp->push_back("ok");
while(it->next()){
resp->push_back(it->key);
}
delete it;
}
return 0;
}
示例6: proc_zkeys
static int proc_zkeys(Server *serv, Link *link, const Request &req, Response *resp){
if(req.size() < 6){
resp->push_back("client_error");
}else{
uint64_t limit = req[5].Uint64();
ZIterator *it = serv->ssdb->zscan(req[1], req[2], req[3], req[4], limit);
resp->push_back("ok");
while(it->next()){
resp->push_back(it->key);
}
delete it;
}
return 0;
}
示例7: proc_zsum
int proc_zsum(NetworkServer *net, Link *link, const Request &req, Response *resp){
SSDBServer *serv = (SSDBServer *)net->data;
CHECK_NUM_PARAMS(4);
int64_t sum = 0;
ZIterator *it = serv->ssdb->zscan(req[1], "", req[2], req[3], -1);
while(it->next()){
sum += str_to_int64(it->score);
}
delete it;
resp->reply_int(0, sum);
return 0;
}
示例8: proc_zkeys
int proc_zkeys(NetworkServer *net, Link *link, const Request &req, Response *resp){
SSDBServer *serv = (SSDBServer *)net->data;
CHECK_NUM_PARAMS(6);
uint64_t limit = req[5].Uint64();
ZIterator *it = serv->ssdb->zscan(req[1], req[2], req[3], req[4], limit);
resp->push_back("ok");
uint64_t size = 0;
while(it->next()){
size += it->key.size();
CHECK_SCAN_OUTPUT_LIMIT(size);
resp->push_back(it->key);
}
delete it;
return 0;
}
示例9: zrrank
int64_t SSDB::zrrank(const Bytes &name, const Bytes &key) const{
ZIterator *it = ziterator(this, name, "", "", "", INT_MAX, Iterator::BACKWARD);
uint64_t ret = 0;
while(true){
if(it->next() == false){
ret = -1;
break;
}
if(key == it->key){
break;
}
ret ++;
}
delete it;
return ret;
}
示例10: proc_zrrange
static int proc_zrrange(Server *serv, Link *link, const Request &req, Response *resp){
if(req.size() != 4){
resp->push_back("client_error");
}else{
uint64_t offset = req[2].Uint64();
uint64_t limit = req[3].Uint64();
ZIterator *it = serv->ssdb->zrange(req[1], offset, limit);
resp->push_back("ok");
while(it->next()){
resp->push_back(it->key);
resp->push_back(it->score);
}
delete it;
}
return 0;
}
示例11: load_expiration_keys_from_db
void ExpirationHandler::load_expiration_keys_from_db(int num){
ZIterator *it;
it = ssdb->zscan(this->list_name, "", "", "", num);
int n = 0;
while(it->next()){
n ++;
std::string &key = it->key;
int64_t score = str_to_int64(it->score);
if(score < 2000000000){
// older version compatible
score *= 1000;
}
fast_keys.add(key, score);
}
delete it;
log_debug("load %d keys into fast_keys", n);
}
示例12: proc_zavg
int proc_zavg(NetworkServer *net, Link *link, const Request &req, Response *resp){
SSDBServer *serv = (SSDBServer *)net->data;
CHECK_NUM_PARAMS(4);
int64_t sum = 0;
int64_t count = 0;
ZIterator *it = serv->ssdb->zscan(req[1], "", req[2], req[3], -1);
while(it->next()){
sum += str_to_int64(it->score);
count ++;
}
delete it;
double avg = (double)sum/count;
resp->push_back("ok");
resp->add(avg);
return 0;
}
示例13: proc_zsum
static int proc_zsum(Server *serv, Link *link, const Request &req, Response *resp){
if(req.size() < 4){
resp->push_back("client_error");
return 0;
}
int64_t sum = 0;
ZIterator *it = serv->ssdb->zscan(req[1], "", req[2], req[3], -1);
while(it->next()){
sum += str_to_int64(it->score);
}
delete it;
char buf[20];
snprintf(buf, sizeof(buf), "%" PRId64 "", sum);
resp->push_back("ok");
resp->push_back(buf);
return 0;
}
示例14: proc_zcount
static int proc_zcount(Server *serv, Link *link, const Request &req, Response *resp){
if(req.size() < 4){
resp->push_back("client_error");
return 0;
}
uint64_t count = 0;
ZIterator *it = serv->ssdb->zscan(req[1], "", req[2], req[3], -1);
while(it->next()){
count ++;
}
delete it;
char buf[20];
snprintf(buf, sizeof(buf), "%" PRIu64 "", count);
resp->push_back("ok");
resp->push_back(buf);
return 0;
}
示例15: proc_zremrangebyscore
int proc_zremrangebyscore(NetworkServer *net, Link *link, const Request &req, Response *resp){
SSDBServer *serv = (SSDBServer *)net->data;
CHECK_NUM_PARAMS(4);
ZIterator *it = serv->ssdb->zscan(req[1], "", req[2], req[3], -1);
int64_t count = 0;
while(it->next()){
count ++;
int ret = serv->ssdb->zdel(req[1], it->key);
if(ret == -1){
delete it;
resp->push_back("error");
return 0;
}
}
delete it;
serv->save_kv_stats();
resp->reply_int(0, count);
return 0;
}