the input format like create name tid pid ttl leader endpoints
| 3460 | |
| 3461 | // the input format like create name tid pid ttl leader endpoints |
| 3462 | void HandleClientCreateTable(const std::vector<std::string>& parts, |
| 3463 | ::fedb::client::TabletClient* client) { |
| 3464 | if (parts.size() < 6) { |
| 3465 | std::cout << "Bad create format, input like create <name> <tid> <pid> " |
| 3466 | "<ttl> <seg_cnt>" |
| 3467 | << std::endl; |
| 3468 | return; |
| 3469 | } |
| 3470 | |
| 3471 | try { |
| 3472 | int64_t abs_ttl = 0; |
| 3473 | int64_t lat_ttl = 0; |
| 3474 | ::fedb::type::TTLType type = ::fedb::type::TTLType::kAbsoluteTime; |
| 3475 | if (parts.size() > 4) { |
| 3476 | std::vector<std::string> vec; |
| 3477 | ::fedb::base::SplitString(parts[4], ":", vec); |
| 3478 | abs_ttl = boost::lexical_cast<int64_t>(vec[vec.size() - 1]); |
| 3479 | if (vec.size() > 1) { |
| 3480 | if (vec[0] == "latest") { |
| 3481 | type = ::fedb::type::TTLType::kLatestTime; |
| 3482 | lat_ttl = abs_ttl; |
| 3483 | abs_ttl = 0; |
| 3484 | if (lat_ttl > FLAGS_latest_ttl_max) { |
| 3485 | std::cout << "Create failed. The max num of latest " |
| 3486 | "LatestTime is " |
| 3487 | << FLAGS_latest_ttl_max << std::endl; |
| 3488 | return; |
| 3489 | } |
| 3490 | } else { |
| 3491 | std::cout << "invalid ttl type" << std::endl; |
| 3492 | return; |
| 3493 | } |
| 3494 | } else { |
| 3495 | if (abs_ttl > FLAGS_absolute_ttl_max) { |
| 3496 | std::cout |
| 3497 | << "Create failed. The max num of AbsoluteTime ttl is " |
| 3498 | << FLAGS_absolute_ttl_max << std::endl; |
| 3499 | return; |
| 3500 | } |
| 3501 | } |
| 3502 | } |
| 3503 | if (abs_ttl < 0 || lat_ttl < 0) { |
| 3504 | std::cout << "ttl should be equal or greater than 0" << std::endl; |
| 3505 | return; |
| 3506 | } |
| 3507 | uint32_t seg_cnt = 16; |
| 3508 | if (parts.size() > 5) { |
| 3509 | seg_cnt = boost::lexical_cast<uint32_t>(parts[5]); |
| 3510 | } |
| 3511 | bool is_leader = true; |
| 3512 | if (parts.size() > 6 && parts[6] == "false") { |
| 3513 | is_leader = false; |
| 3514 | } |
| 3515 | std::vector<std::string> endpoints; |
| 3516 | ::fedb::type::CompressType compress_type = |
| 3517 | ::fedb::type::CompressType::kNoCompress; |
| 3518 | if (parts.size() > 7) { |
| 3519 | std::string raw_compress_type = parts[7]; |
no test coverage detected