| 4077 | } |
| 4078 | |
| 4079 | void HandleClientPreview(const std::vector<std::string>& parts, |
| 4080 | ::fedb::client::TabletClient* client) { |
| 4081 | if (parts.size() < 3) { |
| 4082 | std::cout << "preview format error. eg: preview tid pid [limit]" |
| 4083 | << std::endl; |
| 4084 | return; |
| 4085 | } |
| 4086 | uint32_t limit = FLAGS_preview_default_limit; |
| 4087 | uint32_t tid, pid; |
| 4088 | try { |
| 4089 | tid = boost::lexical_cast<uint32_t>(parts[1]); |
| 4090 | pid = boost::lexical_cast<uint32_t>(parts[2]); |
| 4091 | if (parts.size() > 3) { |
| 4092 | int64_t tmp = boost::lexical_cast<int64_t>(parts[3]); |
| 4093 | if (tmp < 0) { |
| 4094 | printf("preview error. limit should be unsigned int\n"); |
| 4095 | return; |
| 4096 | } |
| 4097 | limit = boost::lexical_cast<uint32_t>(parts[3]); |
| 4098 | if (limit > FLAGS_preview_limit_max_num) { |
| 4099 | printf("preview error. limit is greater than the max num %u\n", |
| 4100 | FLAGS_preview_limit_max_num); |
| 4101 | return; |
| 4102 | } else if (limit == 0) { |
| 4103 | printf("preview error. limit must be greater than zero\n"); |
| 4104 | return; |
| 4105 | } |
| 4106 | } |
| 4107 | } catch (std::exception const& e) { |
| 4108 | printf("Invalid args. tid, pid and limit should be unsigned int\n"); |
| 4109 | return; |
| 4110 | } |
| 4111 | ::fedb::api::TableStatus table_status; |
| 4112 | if (!client->GetTableStatus(tid, pid, true, table_status)) { |
| 4113 | std::cout << "Fail to get table status" << std::endl; |
| 4114 | return; |
| 4115 | } |
| 4116 | /*std::string schema = table_status.schema(); |
| 4117 | std::vector<::fedb::codec::ColumnDesc> columns; |
| 4118 | if (!schema.empty()) { |
| 4119 | ::fedb::codec::SchemaCodec codec; |
| 4120 | codec.Decode(schema, columns); |
| 4121 | } |
| 4122 | uint32_t column_num = columns.empty() ? 4 : columns.size() + 2; |
| 4123 | ::baidu::common::TPrinter tp(column_num, FLAGS_max_col_display_length); |
| 4124 | std::vector<std::string> row; |
| 4125 | if (schema.empty()) { |
| 4126 | row.push_back("#"); |
| 4127 | row.push_back("key"); |
| 4128 | row.push_back("ts"); |
| 4129 | row.push_back("data"); |
| 4130 | } else { |
| 4131 | row.push_back("#"); |
| 4132 | row.push_back("ts"); |
| 4133 | for (uint32_t i = 0; i < columns.size(); i++) { |
| 4134 | row.push_back(columns[i].name); |
| 4135 | } |
| 4136 | } |
no test coverage detected