Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rm format_version in put #1913

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions src/client/tablet_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,11 @@ bool TabletClient::UpdateTableMetaForAddField(uint32_t tid, const std::vector<op

bool TabletClient::Put(uint32_t tid, uint32_t pid, uint64_t time, const std::string& value,
const std::vector<std::pair<std::string, uint32_t>>& dimensions) {
return Put(tid, pid, time, value, dimensions, 0);
}

bool TabletClient::Put(uint32_t tid, uint32_t pid, uint64_t time, const std::string& value,
const std::vector<std::pair<std::string, uint32_t>>& dimensions, uint32_t format_version) {
::openmldb::api::PutRequest request;
request.set_time(time);
request.set_value(value);
request.set_tid(tid);
request.set_pid(pid);
request.set_format_version(format_version);
for (size_t i = 0; i < dimensions.size(); i++) {
::openmldb::api::Dimension* d = request.add_dimensions();
d->set_key(dimensions[i].first);
Expand All @@ -267,17 +261,15 @@ bool TabletClient::Put(uint32_t tid, uint32_t pid, uint64_t time, const std::str
return false;
}

bool TabletClient::Put(uint32_t tid, uint32_t pid, const char* pk, uint64_t time, const char* value, uint32_t size,
uint32_t format_version) {
bool TabletClient::Put(uint32_t tid, uint32_t pid, const std::string& pk, uint64_t time, const std::string& value) {
::openmldb::api::PutRequest request;
auto dim = request.add_dimensions();
dim->set_key(pk);
dim->set_idx(0);
request.set_time(time);
request.set_value(value, size);
request.set_value(value);
request.set_tid(tid);
request.set_pid(pid);
request.set_format_version(format_version);
::openmldb::api::PutResponse response;

bool ok =
Expand All @@ -289,11 +281,6 @@ bool TabletClient::Put(uint32_t tid, uint32_t pid, const char* pk, uint64_t time
return false;
}

bool TabletClient::Put(uint32_t tid, uint32_t pid, const std::string& pk, uint64_t time, const std::string& value,
uint32_t format_version) {
return Put(tid, pid, pk.c_str(), time, value.c_str(), value.size(), format_version);
}

bool TabletClient::MakeSnapshot(uint32_t tid, uint32_t pid, uint64_t offset, std::shared_ptr<TaskInfo> task_info) {
::openmldb::api::GeneralRequest request;
request.set_tid(tid);
Expand Down
11 changes: 1 addition & 10 deletions src/client/tablet_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,11 @@ class TabletClient : public Client {
std::shared_ptr<::openmldb::sdk::SQLRequestRowBatch>, brpc::Controller* cntl,
::openmldb::api::SQLBatchRequestQueryResponse* response, const bool is_debug = false);

bool Put(uint32_t tid, uint32_t pid, const std::string& pk, uint64_t time, const std::string& value,
uint32_t format_version = 0);

bool Put(uint32_t tid, uint32_t pid, const char* pk, uint64_t time, const char* value, uint32_t size,
uint32_t format_version = 0);
bool Put(uint32_t tid, uint32_t pid, const std::string& pk, uint64_t time, const std::string& value);

bool Put(uint32_t tid, uint32_t pid, uint64_t time, const std::string& value,
const std::vector<std::pair<std::string, uint32_t>>& dimensions);

bool Put(uint32_t tid, uint32_t pid, uint64_t time, const std::string& value,
const std::vector<std::pair<std::string, uint32_t>>& dimensions, uint32_t format_version);



bool Get(uint32_t tid, uint32_t pid, const std::string& pk, uint64_t time, std::string& value, // NOLINT
uint64_t& ts, // NOLINT
std::string& msg); ; // NOLINT
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/openmldb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ int PutData(uint32_t tid, const std::map<uint32_t, std::vector<std::pair<std::st
}
}

if (!clients[endpoint]->Put(tid, pid, ts, value, iter->second, format_version)) {
if (!clients[endpoint]->Put(tid, pid, ts, value, iter->second)) {
printf("put failed. tid %u pid %u endpoint %s ts %lu \n", tid, pid, endpoint.c_str(), ts);
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/mini_cluster_batch_bm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static void BM_SimpleQueryFunction(benchmark::State& state) { // NOLINT
uint32_t tid = sdk.GetTableId(db, name);
{
for (int32_t i = 0; i < 1000; i++) {
ok = tablet[0]->GetClient()->Put(tid, 0, pk, ts + i, value, 1);
ok = tablet[0]->GetClient()->Put(tid, 0, pk, ts + i, value);
}
}
std::string sql = "select col1, col2 + 1, col3, col4, col5 from " + name + " ;";
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/sql_cluster_router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ bool SQLClusterRouter::PutRow(uint32_t tid, const std::shared_ptr<SQLInsertRow>&
if (client) {
DLOG(INFO) << "put data to endpoint " << client->GetEndpoint() << " with dimensions size "
<< kv.second.size();
bool ret = client->Put(tid, pid, cur_ts, row->GetRow(), kv.second, 1);
bool ret = client->Put(tid, pid, cur_ts, row->GetRow(), kv.second);
if (!ret) {
status->msg = "fail to make a put request to table. tid " + std::to_string(tid);
LOG(WARNING) << status->msg;
Expand Down
2 changes: 1 addition & 1 deletion src/tablet/tablet_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ int32_t TabletImpl::GetIndex(const ::openmldb::api::GetRequest* request, const :
}
bool enable_project = false;
openmldb::codec::RowProject row_project(vers_schema, request->projection());
if (request->projection().size() > 0 && meta.format_version() == 1) {
if (request->projection().size() > 0) {
if (meta.compress_type() == ::openmldb::type::kSnappy) {
return -1;
}
Expand Down