string HTWorker::run(const char *buf) { string result; ZPack zpack; string str(buf); zpack.ParseFromString(str); 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; }
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; }