本文整理汇总了C++中ZPack::key方法的典型用法代码示例。如果您正苦于以下问题:C++ ZPack::key方法的具体用法?C++ ZPack::key怎么用?C++ ZPack::key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZPack
的用法示例。
在下文中一共展示了ZPack::key方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_shared
string HTWorker::remove_shared(const ZPack &zpack) {
string result;
if (zpack.key().empty())
return Const::ZSC_REC_EMPTYKEY; //-1
string key = zpack.key();
int ret = PMAP->remove(key);
if (ret != 0) {
printf("thread[%lu] DB Error: fail to remove, rcode = %d\n",
pthread_self(), ret);
fflush(stdout);
result = Const::ZSC_REC_NONEXISTKEY; //-92
} else {
if (_instant_swap) {
PMAP->writeFileFG();
}
result = Const::ZSC_REC_SUCC; //0, succeed.
}
return result;
}
示例2: state_change_callback_internal
string HTWorker::state_change_callback_internal(const ZPack &zpack) {
string result;
if (zpack.key().empty())
return Const::ZSC_REC_EMPTYKEY; //-1
string key = zpack.key();
string *ret = PMAP->get(key);
if (ret == NULL) {
printf("thread[%lu] DB Error: lookup found nothing\n", pthread_self());
fflush(stdout);
result = Const::ZSC_REC_NONEXISTKEY;
} else {
ZPack rltpack;
rltpack.ParseFromString(*ret);
if (zpack.val() == rltpack.val()) {
result = Const::ZSC_REC_SUCC; //0, succeed.
} else {
result = Const::ZSC_REC_SCCBPOLLTRY;
}
}
return result;
}
示例3: lookup_shared
string HTWorker::lookup_shared(const ZPack &zpack) {
string result;
if (zpack.key().empty())
return Const::ZSC_REC_EMPTYKEY; //-1
string key = zpack.key();
string *ret = PMAP->get(key);
if (ret == NULL) {
printf("thread[%lu] DB Error: lookup found nothing\n", pthread_self());
fflush(stdout);
result = Const::ZSC_REC_NONEXISTKEY;
result.append("Empty");
} else {
result = Const::ZSC_REC_SUCC;
result.append(*ret);
}
return result;
}
示例4: append_shared
string HTWorker::append_shared(const ZPack &zpack) {
string result;
if (zpack.key().empty())
return Const::ZSC_REC_EMPTYKEY; //-1
string key = zpack.key();
int ret = PMAP->append(key, zpack.SerializeAsString());
if (ret != 0) {
printf("thread[%lu] DB Error: fail to append, rcode = %d\n",
pthread_self(), ret);
fflush(stdout);
result = Const::ZSC_REC_NONEXISTKEY; //-92
} else {
if (_instant_swap) {
PMAP->writeFile();
//PMAP->flushDbfile();
}
result = Const::ZSC_REC_SUCC; //0, succeed.
}
return result;
}
示例5: run
string HTWorker::run(const char *buf) {
string result;
ZPack zpack;
//string str(buf);
string* str =(string*) buf;
zpack.ParseFromString(*str);
if(ZPack_Pack_type_BATCH_REQ == zpack.pack_type()){//batch
cout << "HTWrorker::run(): ZPack_Pack_type_BATCH_REQ received."<< endl;
cout << "Batch contains "<< zpack.batch_item_size() << " items."<<endl;
cout <<"zpack.key: "<< zpack.key() <<endl;
cout <<"zpack.batch_item(i).val: "<<zpack.batch_item(0).val() << endl<< endl;
result = Const::ZSC_REC_UOPC; // "OK";
}else if(ZPack_Pack_type_SINGLE == zpack.pack_type()){//single
if (zpack.opcode() == Const::ZSC_OPC_LOOKUP) {
result = lookup(zpack);
} else if (zpack.opcode() == Const::ZSC_OPC_INSERT) {
result = insert(zpack);
} else if (zpack.opcode() == Const::ZSC_OPC_APPEND) {
result = append(zpack);
} else if (zpack.opcode() == Const::ZSC_OPC_CMPSWP) {
result = compare_swap(zpack);
} else if (zpack.opcode() == Const::ZSC_OPC_REMOVE) {
result = remove(zpack);
} else if (zpack.opcode() == Const::ZSC_OPC_STCHGCB) {
result = state_change_callback(zpack);
} else {
result = Const::ZSC_REC_UOPC;
}
}
return result;
}
示例6: compare_swap
string HTWorker::compare_swap(const ZPack &zpack) {
if (zpack.key().empty())
return Const::ZSC_REC_EMPTYKEY; //-1
string result = compare_swap_internal(zpack);
string lkpresult = lookup_shared(zpack);
result.append(erase_status_code(lkpresult));
#ifdef SCCB
_stub->sendBack(_addr, result.data(), result.size());
return "";
#else
return result;
#endif
}