Skip to content

Commit 4cda032

Browse files
authored
Remove sscan and sget command in tablet client (#1886)
1 parent 27e7ff6 commit 4cda032

File tree

1 file changed

+0
-252
lines changed

1 file changed

+0
-252
lines changed

src/cmd/openmldb.cc

-252
Original file line numberDiff line numberDiff line change
@@ -3051,10 +3051,6 @@ void HandleClientHelp(const std::vector<std::string> parts, ::openmldb::client::
30513051
printf("quit - exit client\n");
30523052
printf("recoversnapshot - recover snapshot\n");
30533053
printf("screate - create multi dimension table\n");
3054-
printf(
3055-
"sscan - get records for a period of time from multi dimension "
3056-
"table\n");
3057-
printf("sget - get only one record from multi dimension table\n");
30583054
printf("sendsnapshot - send snapshot to another endpoint\n");
30593055
printf("setexpire - enable or disable ttl\n");
30603056
printf("showschema - show schema\n");
@@ -3072,21 +3068,6 @@ void HandleClientHelp(const std::vector<std::string> parts, ::openmldb::client::
30723068
printf("desc: drop table\n");
30733069
printf("usage: drop tid pid\n");
30743070
printf("ex: drop 1 0\n");
3075-
} else if (parts[1] == "sscan") {
3076-
printf(
3077-
"desc: get records for a period of time from multi dimension "
3078-
"table\n");
3079-
printf(
3080-
"usage: sscan tid pid key key_name starttime endtime "
3081-
"[limit]\n");
3082-
printf("ex: sscan 1 0 card0 card 1528858466000 1528858300000\n");
3083-
printf("ex: sscan 1 0 card0 card 1528858466000 1528858300000 10\n");
3084-
printf("ex: sscan 1 0 card0 card 0 0 10\n");
3085-
} else if (parts[1] == "sget") {
3086-
printf("desc: get only one record from multi dimension table\n");
3087-
printf("usage: sget tid pid key key_name ts\n");
3088-
printf("ex: sget 1 0 card0 card 1528858466000\n");
3089-
printf("ex: sget 1 0 card0 card 0\n");
30903071
} else if (parts[1] == "delete") {
30913072
printf("desc: delete pk\n");
30923073
printf("usage: delete tid pid key [key_name]\n");
@@ -3642,235 +3623,6 @@ void HandleClientShowSchema(const std::vector<std::string>& parts, ::openmldb::c
36423623
}
36433624
}
36443625

3645-
void HandleClientSGet(const std::vector<std::string>& parts, ::openmldb::client::TabletClient* client) {
3646-
if (parts.size() < 5) {
3647-
std::cout << "Bad sget format, eg. sget tid pid key index_name ts | sget "
3648-
"table_name=xxx key=xxx index_name=xxx ts=xxx ts_name=xxx"
3649-
<< std::endl;
3650-
return;
3651-
}
3652-
std::map<std::string, std::string> parameter_map;
3653-
if (!GetParameterMap("tid", parts, "=", parameter_map)) {
3654-
std::cout << "sget format erro! eg. sget table_name=xxx key=xxx "
3655-
"index_name=xxx ts=xxx ts_name=xxx"
3656-
<< std::endl;
3657-
return;
3658-
}
3659-
bool is_pair_format = parameter_map.empty() ? false : true;
3660-
uint32_t tid = 0;
3661-
uint32_t pid = 0;
3662-
std::string key;
3663-
std::string index_name;
3664-
uint64_t timestamp = 0;
3665-
std::string ts_name;
3666-
auto iter = parameter_map.begin();
3667-
try {
3668-
if (is_pair_format) {
3669-
iter = parameter_map.find("tid");
3670-
if (iter != parameter_map.end()) {
3671-
tid = boost::lexical_cast<uint32_t>(iter->second);
3672-
} else {
3673-
std::cout << "sget format error: tid does not exist!" << std::endl;
3674-
return;
3675-
}
3676-
iter = parameter_map.find("pid");
3677-
if (iter != parameter_map.end()) {
3678-
pid = boost::lexical_cast<uint32_t>(iter->second);
3679-
} else {
3680-
std::cout << "sget format error: pid does not exist!" << std::endl;
3681-
return;
3682-
}
3683-
iter = parameter_map.find("key");
3684-
if (iter != parameter_map.end()) {
3685-
key = iter->second;
3686-
} else {
3687-
std::cout << "sget format error: key does not exist!" << std::endl;
3688-
return;
3689-
}
3690-
iter = parameter_map.find("index_name");
3691-
if (iter != parameter_map.end()) {
3692-
index_name = iter->second;
3693-
}
3694-
iter = parameter_map.find("ts");
3695-
if (iter != parameter_map.end()) {
3696-
timestamp = boost::lexical_cast<uint64_t>(iter->second);
3697-
}
3698-
iter = parameter_map.find("ts_name");
3699-
if (iter != parameter_map.end()) {
3700-
ts_name = iter->second;
3701-
}
3702-
} else {
3703-
tid = boost::lexical_cast<uint32_t>(parts[1]);
3704-
pid = boost::lexical_cast<uint32_t>(parts[2]);
3705-
key = parts[3];
3706-
index_name = parts[4];
3707-
if (parts.size() > 5) {
3708-
timestamp = boost::lexical_cast<uint64_t>(parts[5]);
3709-
}
3710-
}
3711-
} catch (std::exception const& e) {
3712-
std::cout << "Invalid args. tid pid should be uint32_t, ts should be "
3713-
"uint64_t, "
3714-
<< std::endl;
3715-
return;
3716-
}
3717-
::openmldb::api::TableMeta table_meta;
3718-
bool ok = client->GetTableSchema(tid, pid, table_meta);
3719-
if (!ok) {
3720-
std::cout << "No schema for table ,please use command get" << std::endl;
3721-
return;
3722-
}
3723-
std::string value;
3724-
uint64_t ts = 0;
3725-
std::string msg;
3726-
ok = client->Get(tid, pid, key, timestamp, index_name, ts_name, value, ts, msg);
3727-
if (!ok) {
3728-
std::cout << "Fail to sget value! error msg: " << msg << std::endl;
3729-
return;
3730-
}
3731-
::openmldb::api::TableStatus table_status;
3732-
if (!client->GetTableStatus(tid, pid, table_status)) {
3733-
std::cout << "Fail to get table status" << std::endl;
3734-
return;
3735-
}
3736-
::openmldb::type::CompressType compress_type = ::openmldb::type::CompressType::kNoCompress;
3737-
if (table_status.compress_type() == ::openmldb::type::CompressType::kSnappy) {
3738-
compress_type = ::openmldb::type::CompressType::kSnappy;
3739-
}
3740-
if (compress_type == ::openmldb::type::CompressType::kSnappy) {
3741-
std::string uncompressed;
3742-
::snappy::Uncompress(value.c_str(), value.length(), &uncompressed);
3743-
value = uncompressed;
3744-
}
3745-
// TODO(denglong): display schema
3746-
/*std::string schema = table_meta.schema();
3747-
std::vector<::openmldb::codec::ColumnDesc> raw;
3748-
::openmldb::codec::SchemaCodec codec;
3749-
codec.Decode(schema, raw);
3750-
::baidu::common::TPrinter tp(raw.size() + 2, FLAGS_max_col_display_length);
3751-
std::vector<std::string> row;
3752-
row.push_back("#");
3753-
row.push_back("ts");
3754-
for (uint32_t i = 0; i < raw.size(); i++) {
3755-
row.push_back(raw[i].name);
3756-
}
3757-
tp.AddRow(row);
3758-
row.clear();
3759-
row.push_back("1");
3760-
row.push_back(std::to_string(ts));
3761-
tp.AddRow(row);
3762-
tp.Print(true);*/
3763-
}
3764-
3765-
void HandleClientSScan(const std::vector<std::string>& parts, ::openmldb::client::TabletClient* client) {
3766-
if (parts.size() < 7) {
3767-
std::cout << "Bad scan format! eg.sscan tid pid key col_name start_time "
3768-
"end_time [limit] | sscan table_name=xxx key=xxx index_name=xxx "
3769-
"st=xxx et=xxx ts_name=xxx [limit=xxx]"
3770-
<< std::endl;
3771-
return;
3772-
}
3773-
std::map<std::string, std::string> parameter_map;
3774-
if (!GetParameterMap("tid", parts, "=", parameter_map)) {
3775-
std::cout << "scan format erro! eg. sscan table_name=xxx key=xxx "
3776-
"index_name=xxx st=xxx et=xxx ts_name=xxx [limit=xxx]"
3777-
<< std::endl;
3778-
return;
3779-
}
3780-
bool is_pair_format = parameter_map.empty() ? false : true;
3781-
uint32_t tid = 0;
3782-
uint32_t pid = 0;
3783-
std::string key;
3784-
std::string index_name;
3785-
uint64_t st = 0;
3786-
uint64_t et = 0;
3787-
std::string ts_name;
3788-
uint32_t limit = 0;
3789-
auto iter = parameter_map.begin();
3790-
try {
3791-
if (is_pair_format) {
3792-
iter = parameter_map.find("tid");
3793-
if (iter != parameter_map.end()) {
3794-
tid = boost::lexical_cast<uint32_t>(iter->second);
3795-
} else {
3796-
std::cout << "sscan format error: tid does not exist!" << std::endl;
3797-
return;
3798-
}
3799-
iter = parameter_map.find("pid");
3800-
if (iter != parameter_map.end()) {
3801-
pid = boost::lexical_cast<uint32_t>(iter->second);
3802-
} else {
3803-
std::cout << "sscan format error: pid does not exist!" << std::endl;
3804-
return;
3805-
}
3806-
iter = parameter_map.find("key");
3807-
if (iter != parameter_map.end()) {
3808-
key = iter->second;
3809-
} else {
3810-
std::cout << "sscan format error: key does not exist!" << std::endl;
3811-
return;
3812-
}
3813-
iter = parameter_map.find("index_name");
3814-
if (iter != parameter_map.end()) {
3815-
index_name = iter->second;
3816-
}
3817-
iter = parameter_map.find("st");
3818-
if (iter != parameter_map.end()) {
3819-
st = boost::lexical_cast<uint64_t>(iter->second);
3820-
} else {
3821-
std::cout << "sscan format error: st does not exist!" << std::endl;
3822-
return;
3823-
}
3824-
iter = parameter_map.find("et");
3825-
if (iter != parameter_map.end()) {
3826-
et = boost::lexical_cast<uint64_t>(iter->second);
3827-
} else {
3828-
std::cout << "sscan format error: et does not exist!" << std::endl;
3829-
return;
3830-
}
3831-
iter = parameter_map.find("ts_name");
3832-
if (iter != parameter_map.end()) {
3833-
ts_name = iter->second;
3834-
}
3835-
iter = parameter_map.find("limit");
3836-
if (iter != parameter_map.end()) {
3837-
limit = boost::lexical_cast<uint32_t>(iter->second);
3838-
}
3839-
} else {
3840-
if (parts.size() > 7) {
3841-
limit = boost::lexical_cast<uint32_t>(parts[7]);
3842-
}
3843-
tid = boost::lexical_cast<uint32_t>(parts[1]);
3844-
pid = boost::lexical_cast<uint32_t>(parts[2]);
3845-
key = parts[3];
3846-
index_name = parts[4];
3847-
st = boost::lexical_cast<uint64_t>(parts[5]);
3848-
et = boost::lexical_cast<uint64_t>(parts[6]);
3849-
}
3850-
} catch (std::exception const& e) {
3851-
std::cout << "Invalid args. tid pid should be uint32_t, st and et "
3852-
"should be uint64_t, limit should be uint32"
3853-
<< std::endl;
3854-
return;
3855-
}
3856-
std::string msg;
3857-
std::shared_ptr<::openmldb::base::KvIterator> it(client->Scan(tid, pid, key, index_name, st, et, limit, msg));
3858-
if (!it) {
3859-
std::cout << "Fail to scan table. error msg: " << msg << std::endl;
3860-
return;
3861-
}
3862-
::openmldb::api::TableMeta table_meta;
3863-
bool ok = client->GetTableSchema(tid, pid, table_meta);
3864-
if (!ok) {
3865-
std::cout << "table is not exist" << std::endl;
3866-
return;
3867-
}
3868-
std::vector<std::shared_ptr<::openmldb::base::KvIterator>> iter_vec;
3869-
iter_vec.push_back(std::move(it));
3870-
::openmldb::cmd::SDKIterator sdk_it(iter_vec, limit);
3871-
::openmldb::cmd::ShowTableRows(table_meta, &sdk_it);
3872-
}
3873-
38743626
void HandleClientDelete(const std::vector<std::string>& parts, ::openmldb::client::TabletClient* client) {
38753627
if (parts.size() < 4) {
38763628
std::cout << "Bad delete format" << std::endl;
@@ -3930,10 +3682,6 @@ void StartClient() {
39303682
::openmldb::base::SplitString(buffer, " ", parts);
39313683
if (parts.empty()) {
39323684
continue;
3933-
} else if (parts[0] == "sget") {
3934-
HandleClientSGet(parts, &client);
3935-
} else if (parts[0] == "sscan") {
3936-
HandleClientSScan(parts, &client);
39373685
} else if (parts[0] == "delete") {
39383686
HandleClientDelete(parts, &client);
39393687
} else if (parts[0] == "count") {

0 commit comments

Comments
 (0)