本文整理汇总了C++中ZHTClient::append方法的典型用法代码示例。如果您正苦于以下问题:C++ ZHTClient::append方法的具体用法?C++ ZHTClient::append怎么用?C++ ZHTClient::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZHTClient
的用法示例。
在下文中一共展示了ZHTClient::append方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: c_zht_append_std
int c_zht_append_std(ZHTClient_c zhtClient, const char *pair) {
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string str(pair);
return zhtcppClient->append(str);
}
示例2: benchmarkAppend
//pretty much same as benchmarkInsert.
int benchmarkAppend(ZHTClient &client, int numTest, int lenString) {
// cout << "start to append"<<endl;
// if (clientRet.initialize(cfgFile, memberList) != 0) { //zhouxb
vector<string> pkgList_append;
for (int i = 0; i < numTest; i++) {
Package package, package_ret;
package.set_virtualpath(randomString(lenString).append("-append")); //as key
package.set_isdir(true);
package.set_replicano(5); //orginal--Note: never let it be nagative!!!
package.set_operation(4); // 3 for insert, 1 for look up, 2 for remove
package.set_realfullpath(
"Some-Real-longer-longer-and-longer-Paths--------");
package.add_listitem("item-----2");
package.add_listitem("item-----3");
package.add_listitem("item-----4");
package.add_listitem("item-----5");
package.add_listitem("item-----6");
string str = package.SerializeAsString();
// cout << "package size = " << str.size() << endl;
// cout<<"Client.cpp:benchmarkInsert: "<<endl;
// cout<<"string: "<<str<<endl;
// cout<<"Insert str: "<<str.c_str()<<endl;
// cout<<"data(): "<< str.data()<<endl;
pkgList_append.push_back(str);
}
double start = 0;
double end = 0;
start = getTime_msec();
int errCount = 0;
vector<string>::iterator it;
int c = 0;
//cout << "-----0" << endl;
for (it = pkgList_append.begin(); it != pkgList_append.end(); it++) {
// cerr <<"insert count "<< c << endl;
c++;
string str_ins = *it;
//cout << "-----1:about to append" << endl;
// sleep(1);
int ret = client.append(str_ins);
if (ret != 0)
// cout << "client: append ret = " << ret << endl;
//cout << "-----2" << endl;
if (ret < 0) {
errCount++;
}
}
//close(sock);
end = getTime_msec();
cout << "Appended " << numTest - errCount << " packages out of " << numTest
<< ", cost " << end - start << " ms" << endl;
return 0;
}
示例3: benchmarkAppend
int benchmarkAppend() {
vector<string> pkgList_append;
vector<string>::iterator it;
for (it = pkgList.begin(); it != pkgList.end(); it++) {
Package package;
package.ParseFromString((*it));
package.add_listitem("item-----6-append");
pkgList_append.push_back(package.SerializeAsString());
}
double start = 0;
double end = 0;
start = TimeUtil::getTime_msec();
int errCount = 0;
int c = 0;
for (it = pkgList_append.begin(); it != pkgList_append.end(); it++) {
c++;
string pkg_str = *it;
Package pkg;
pkg.ParseFromString(pkg_str);
int ret = zc.append(pkg.virtualpath(), pkg_str);
if (ret < 0) {
errCount++;
}
}
end = TimeUtil::getTime_msec();
char buf[200];
sprintf(buf, "Appended packages, %d, %d, cost(ms), %f", numOfOps - errCount,
numOfOps, end - start);
cout << buf << endl;
return 0;
}
示例4: c_zht_append_std
int c_zht_append_std(ZHTClient_c zhtClient, const char *key,
const char *value) {
#ifdef IND_MUTEX
LockGuard lock(&c_zht_append_mutex);
#elif SHARED_MUTEX
LockGuard lock(&c_zht_client_mutex);
#else
#endif
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string skey(key);
string sval(value);
return zhtcppClient->append(skey, sval);
}
示例5: c_zht_append2_std
int c_zht_append2_std(ZHTClient_c zhtClient, const char *key,
const char *value) {
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string sKey(key);
string sValue(value);
Package package;
package.set_virtualpath(sKey); //as key
package.set_isdir(true);
package.set_replicano(5);
package.set_operation(4); //1 for look up, 2 for remove, 3 for insert, 4 append
if (!sValue.empty())
package.set_realfullpath(sValue);
return zhtcppClient->append(package.SerializeAsString());
}