| 4504 | } |
| 4505 | |
| 4506 | void HandleClientSGet(const std::vector<std::string>& parts, |
| 4507 | ::fedb::client::TabletClient* client) { |
| 4508 | if (parts.size() < 5) { |
| 4509 | std::cout |
| 4510 | << "Bad sget format, eg. sget tid pid key index_name ts | sget " |
| 4511 | "table_name=xxx key=xxx index_name=xxx ts=xxx ts_name=xxx" |
| 4512 | << std::endl; |
| 4513 | return; |
| 4514 | } |
| 4515 | std::map<std::string, std::string> parameter_map; |
| 4516 | if (!GetParameterMap("tid", parts, "=", parameter_map)) { |
| 4517 | std::cout << "sget format erro! eg. sget table_name=xxx key=xxx " |
| 4518 | "index_name=xxx ts=xxx ts_name=xxx" |
| 4519 | << std::endl; |
| 4520 | return; |
| 4521 | } |
| 4522 | bool is_pair_format = parameter_map.empty() ? false : true; |
| 4523 | uint32_t tid = 0; |
| 4524 | uint32_t pid = 0; |
| 4525 | std::string key; |
| 4526 | std::string index_name; |
| 4527 | uint64_t timestamp = 0; |
| 4528 | std::string ts_name; |
| 4529 | auto iter = parameter_map.begin(); |
| 4530 | try { |
| 4531 | if (is_pair_format) { |
| 4532 | iter = parameter_map.find("tid"); |
| 4533 | if (iter != parameter_map.end()) { |
| 4534 | tid = boost::lexical_cast<uint32_t>(iter->second); |
| 4535 | } else { |
| 4536 | std::cout << "sget format error: tid does not exist!" |
| 4537 | << std::endl; |
| 4538 | return; |
| 4539 | } |
| 4540 | iter = parameter_map.find("pid"); |
| 4541 | if (iter != parameter_map.end()) { |
| 4542 | pid = boost::lexical_cast<uint32_t>(iter->second); |
| 4543 | } else { |
| 4544 | std::cout << "sget format error: pid does not exist!" |
| 4545 | << std::endl; |
| 4546 | return; |
| 4547 | } |
| 4548 | iter = parameter_map.find("key"); |
| 4549 | if (iter != parameter_map.end()) { |
| 4550 | key = iter->second; |
| 4551 | } else { |
| 4552 | std::cout << "sget format error: key does not exist!" |
| 4553 | << std::endl; |
| 4554 | return; |
| 4555 | } |
| 4556 | iter = parameter_map.find("index_name"); |
| 4557 | if (iter != parameter_map.end()) { |
| 4558 | index_name = iter->second; |
| 4559 | } |
| 4560 | iter = parameter_map.find("ts"); |
| 4561 | if (iter != parameter_map.end()) { |
| 4562 | timestamp = boost::lexical_cast<uint64_t>(iter->second); |
| 4563 | } |
no test coverage detected