示例#1
0
float benchmarkRemove() {

    double start = 0;
    double end = 0;
    start = TimeUtil::getTime_msec();
    int errCount = 0;

    int c = 0;
    vector<string>::iterator it;
    for (it = pkgList.begin(); it != pkgList.end(); it++) {

        string result;
        c++;

        string pkg_str = *it;
        Package pkg;
        pkg.ParseFromString(pkg_str);

        int ret = zc.remove(pkg.virtualpath());

        if (ret < 0) {
            errCount++;
        }
    }

    end = TimeUtil::getTime_msec();

    char buf[200];
    sprintf(buf, "Removed packages, %d, %d, cost(ms), %f", numOfOps - errCount,
            numOfOps, end - start);
    cout << buf << endl;

    return 0;
}
int c_zht_remove_std(ZHTClient_c zhtClient, const char *pair) {

	ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;

	string str(pair);

	return zhtcppClient->remove(str);
}
int c_zht_remove2_std(ZHTClient_c zhtClient, const char *key) {

	ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;

	string sKey(key);

	Package package;
	package.set_virtualpath(sKey);
	package.set_operation(2); //1 for look up, 2 for remove, 3 for insert, 4 append

	return zhtcppClient->remove(package.SerializeAsString());
}
示例#4
0
int c_zht_remove2(const char *key) {

	string keyStr(key);

	if (keyStr.empty()) //empty key not allowed.
		return -1;

	Package package;
	package.set_virtualpath(keyStr);
	package.set_operation(2); //1 for look up, 2 for remove, 3 for insert

	return zhtClient.remove(package.SerializeAsString());
}
int c_zht_remove_std(ZHTClient_c zhtClient, const char *key) {

#ifdef IND_MUTEX
	LockGuard lock(&c_zht_remove_mutex);
#elif SHARED_MUTEX
	LockGuard lock(&c_zht_client_mutex);
#else
#endif

	ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;

	string skey(key);

	return zhtcppClient->remove(skey);
}
示例#6
0
float benchmarkRemove(vector<string> strList, ZHTClient &client) {
    vector<string>::iterator it;

    for (it = strList.begin(); it != strList.end(); it++) {
        Package package;
        package.ParseFromString((*it));
        package.set_operation(2); // 3 for insert, 1 for look up, 2 for remove
        package.set_replicano(5); //5: original, 3 not original

        strList.erase(it);
        string newStr = package.SerializeAsString();
        strList.push_back(newStr);
    }

    double start = 0;
    double end = 0;
    start = getTime_msec();
    int errCount = 0;
    int c=0;
    for (it = strList.begin(); it != strList.end(); it++) {
        string result;
        c++;
        //cout <<"Remove count "<< c << endl;

        //cout <<"Remove: "<< (*it).c_str() << endl;
        if (client.remove((*it)) < 0) {
            errCount++;
        }

    }

    end = getTime_msec();

    cout << "Remove " << strList.size() - errCount << " packages out of "
         << strList.size() << ", cost " << end - start << " ms" << endl;
    return 0;

    return 0;
}
示例#7
0
int c_zht_remove(const char *pair) {

	string str(pair);

	return zhtClient.remove(str);
}