当前位置: 首页>>代码示例>>C++>>正文


C++ HIterator类代码示例

本文整理汇总了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;
}
开发者ID:KerwinMa,项目名称:ssdb,代码行数:34,代码来源:proc_hash.cpp

示例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;
}
开发者ID:aducode,项目名称:ssdb,代码行数:31,代码来源:proc_hash.cpp

示例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;
}
开发者ID:KerwinMa,项目名称:ssdb,代码行数:14,代码来源:proc_hash.cpp

示例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;
}
开发者ID:KerwinMa,项目名称:ssdb,代码行数:15,代码来源:proc_hash.cpp

示例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;
}
开发者ID:airowner,项目名称:ssdb,代码行数:15,代码来源:proc.cpp

示例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;
}
开发者ID:2php,项目名称:ssdb,代码行数:15,代码来源:cluster_store.cpp

示例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;
}
开发者ID:dryangkun,项目名称:ssdb,代码行数:22,代码来源:t_hash.cpp


注:本文中的HIterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。