本文整理汇总了C++中HIterator类的典型用法代码示例。如果您正苦于以下问题:C++ HIterator类的具体用法?C++ HIterator怎么用?C++ HIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HIterator类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: proc_hclear
static int proc_hclear(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){
HIterator *it = serv->ssdb->hscan(name, "", "", 1000);
int num = 0;
while(it->next()){
int ret = serv->ssdb->hdel(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;
}
示例2: proc_hclear
static int proc_hclear(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];
int64_t count = 0;
while(1){
HIterator *it = serv->ssdb->hscan(name, "", "", 1000);
int num = 0;
while(it->next()){
int ret = serv->ssdb->hdel(name, it->key);
if(ret == -1){
delete it;
resp->push_back("error");
return 0;
}
num ++;
};
delete it;
if(num == 0){
break;
}
count += num;
}
resp->reply_int(0, count);
return 0;
}
示例3: proc_hgetall
static int proc_hgetall(Server *serv, Link *link, const Request &req, Response *resp){
if(req.size() < 2){
resp->push_back("client_error");
}else{
HIterator *it = serv->ssdb->hscan(req[1], "", "", 9999999999);
resp->push_back("ok");
while(it->next()){
resp->push_back(it->key);
resp->push_back(it->val);
}
delete it;
}
return 0;
}
示例4: proc_hvals
static int proc_hvals(Server *serv, Link *link, const Request &req, Response *resp){
if(req.size() < 5){
resp->push_back("client_error");
}else{
uint64_t limit = req[4].Uint64();
HIterator *it = serv->ssdb->hscan(req[1], req[2], req[3], limit);
resp->push_back("ok");
while(it->next()){
resp->push_back(it->val);
}
delete it;
}
return 0;
}
示例5: proc_hscan
int CommandProc::proc_hscan(const Link &link, const Request &req, Response *resp){
if(req.size() < 5){
resp->push_back("client_error");
}else{
int limit = req[4].Int();
HIterator *it = ssdb->hscan(req[1], req[2], req[3], limit);
resp->push_back("ok");
while(it->next()){
resp->push_back(it->key);
resp->push_back(it->val);
}
delete it;
}
return 0;
}
示例6: load_kv_node_list
int ClusterStore::load_kv_node_list(std::vector<Node> *list){
int ret = 0;
HIterator *it = db->hscan(kv_node_list_key, "", "", 10000);
if(it){
while(it->next()){
Node node;
this->load_kv_node(str_to_int(it->key), &node);
log_debug("load node: %d - %s %s:%d", node.id, node.range.str().c_str(),
node.ip.c_str(), node.port);
list->push_back(node);
}
delete it;
}
return ret;
}
示例7: while
int64_t SSDBImpl::hclear(const Bytes &name){
int64_t count = 0;
while(1){
HIterator *it = this->hscan(name, "", "", 1000);
int num = 0;
while(it->next()){
int ret = this->hdel(name, it->key);
if(ret == -1){
delete it;
return 0;
}
num ++;
};
delete it;
if(num == 0){
break;
}
count += num;
}
return count;
}