Skip to content

Commit

Permalink
fix test and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vagetablechicken committed Nov 10, 2023
1 parent cb98dd2 commit 9bec5d9
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 56 deletions.
11 changes: 6 additions & 5 deletions src/client/ns_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ bool NsClient::OfflineEndpoint(const std::string& endpoint, uint32_t concurrency
return false;
}

base::Status NsClient::Migrate(const std::string& src_endpoint, const std::string& name, const std::set<uint32_t>& pid_set,
const std::string& des_endpoint) {
base::Status NsClient::Migrate(const std::string& src_endpoint, const std::string& name,
const std::set<uint32_t>& pid_set, const std::string& des_endpoint) {
::openmldb::nameserver::MigrateRequest request;
::openmldb::nameserver::GeneralResponse response;
request.set_src_endpoint(src_endpoint);
Expand Down Expand Up @@ -584,7 +584,8 @@ bool NsClient::GetTablePartition(const std::string& name, uint32_t pid,
return false;
}

base::Status NsClient::UpdateTableAliveStatus(const std::string& endpoint, const std::string& name, uint32_t pid, bool is_alive) {
base::Status NsClient::UpdateTableAliveStatus(const std::string& endpoint, const std::string& name, uint32_t pid,
bool is_alive) {
::openmldb::nameserver::UpdateTableAliveRequest request;
::openmldb::nameserver::GeneralResponse response;
request.set_endpoint(endpoint);
Expand All @@ -594,8 +595,8 @@ base::Status NsClient::UpdateTableAliveStatus(const std::string& endpoint, const
if (pid < UINT32_MAX) {
request.set_pid(pid);
}
auto st = client_.SendRequestSt(&::openmldb::nameserver::NameServer_Stub::UpdateTableAliveStatus, &request, &response,
FLAGS_request_timeout_ms, 1);
auto st = client_.SendRequestSt(&::openmldb::nameserver::NameServer_Stub::UpdateTableAliveStatus, &request,
&response, FLAGS_request_timeout_ms, 1);
if (st.OK()) {
return {response.code(), response.msg()};
}
Expand Down
7 changes: 4 additions & 3 deletions src/client/tablet_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,13 @@ base::Status TabletClient::GetTableFollower(uint32_t tid, uint32_t pid, uint64_t
request.set_tid(tid);
request.set_pid(pid);
auto st = client_.SendRequestSt(&::openmldb::api::TabletServer_Stub::GetTableFollower, &request, &response,
FLAGS_request_timeout_ms, 1);
FLAGS_request_timeout_ms, 1);
if (st.OK()) {
if(response.code() == 0) {
if (response.code() == 0) {
offset = response.offset();
for (int idx = 0; idx < response.follower_info_size(); idx++) {
info_map.insert(std::make_pair(response.follower_info(idx).endpoint(), response.follower_info(idx).offset()));
info_map.insert(
std::make_pair(response.follower_info(idx).endpoint(), response.follower_info(idx).offset()));
}
return {};
} else {
Expand Down
75 changes: 36 additions & 39 deletions src/client/tablet_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ namespace sdk {
class SQLRequestRowBatch;
} // namespace sdk


namespace client {
using ::openmldb::api::TaskInfo;
const uint32_t INVALID_REMOTE_TID = UINT32_MAX;
Expand Down Expand Up @@ -78,7 +77,8 @@ class TabletClient : public Client {

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
std::string& msg);

Check warning on line 80 in src/client/tablet_client.h

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] reported by reviewdog 🐶 Is this a non-const reference? If so, make const or use a pointer: std::string& msg [runtime/references] [2] Raw Output: src/client/tablet_client.h:80: Is this a non-const reference? If so, make const or use a pointer: std::string& msg [runtime/references] [2]
; // NOLINT

bool Get(uint32_t tid, uint32_t pid, const std::string& pk, uint64_t time, const std::string& idx_name,
std::string& value, // NOLINT
Expand All @@ -89,21 +89,20 @@ class TabletClient : public Client {
std::string& msg); // NOLINT

base::Status Delete(uint32_t tid, uint32_t pid, const std::map<uint32_t, std::string>& index_val,
const std::string& ts_name, const std::optional<uint64_t> start_ts, const std::optional<uint64_t>& end_ts);
const std::string& ts_name, const std::optional<uint64_t> start_ts,
const std::optional<uint64_t>& end_ts);

bool Count(uint32_t tid, uint32_t pid, const std::string& pk, const std::string& idx_name, bool filter_expired_data,
uint64_t& value, std::string& msg); // NOLINT

std::shared_ptr<openmldb::base::ScanKvIterator> Scan(uint32_t tid, uint32_t pid, const std::string& pk,
const std::string& idx_name, uint64_t stime, uint64_t etime,
uint32_t limit, uint32_t skip_record_num,
std::string& msg); // NOLINT

std::shared_ptr<openmldb::base::ScanKvIterator> Scan(uint32_t tid, uint32_t pid,
const std::string& pk, const std::string& idx_name,
uint64_t stime, uint64_t etime,
uint32_t limit, uint32_t skip_record_num, std::string& msg); // NOLINT

std::shared_ptr<openmldb::base::ScanKvIterator> Scan(uint32_t tid, uint32_t pid,
const std::string& pk, const std::string& idx_name,
uint64_t stime, uint64_t etime,
uint32_t limit, std::string& msg); // NOLINT
std::shared_ptr<openmldb::base::ScanKvIterator> Scan(uint32_t tid, uint32_t pid, const std::string& pk,
const std::string& idx_name, uint64_t stime, uint64_t etime,
uint32_t limit, std::string& msg); // NOLINT

bool Scan(const ::openmldb::api::ScanRequest& request, brpc::Controller* cntl,
::openmldb::api::ScanResponse* response);
Expand Down Expand Up @@ -137,8 +136,8 @@ class TabletClient : public Client {

base::Status LoadTable(const std::string& name, uint32_t id, uint32_t pid, uint64_t ttl, uint32_t seg_cnt);

base::Status LoadTable(const std::string& name, uint32_t id, uint32_t pid, uint64_t ttl, bool leader, uint32_t seg_cnt,
std::shared_ptr<TaskInfo> task_info = std::shared_ptr<TaskInfo>());
base::Status LoadTable(const std::string& name, uint32_t id, uint32_t pid, uint64_t ttl, bool leader,
uint32_t seg_cnt, std::shared_ptr<TaskInfo> task_info = std::shared_ptr<TaskInfo>());

// for ns WrapTaskFun, must return bool
bool LoadTable(const ::openmldb::api::TableMeta& table_meta, std::shared_ptr<TaskInfo> task_info);
Expand All @@ -159,25 +158,25 @@ class TabletClient : public Client {

bool GetTermPair(uint32_t tid, uint32_t pid,
::openmldb::common::StorageMode storage_mode, // NOLINT
uint64_t& term, // NOLINT
uint64_t& offset, bool& has_table, // NOLINT
bool& is_leader); // NOLINT
uint64_t& term, // NOLINT
uint64_t& offset, bool& has_table, // NOLINT
bool& is_leader); // NOLINT

bool GetManifest(uint32_t tid, uint32_t pid, ::openmldb::common::StorageMode storage_mode,
::openmldb::api::Manifest& manifest); // NOLINT
::openmldb::api::Manifest& manifest); // NOLINT

base::Status GetTableStatus(::openmldb::api::GetTableStatusResponse& response); // NOLINT
base::Status GetTableStatus(uint32_t tid, uint32_t pid,
::openmldb::api::TableStatus& table_status); // NOLINT
::openmldb::api::TableStatus& table_status); // NOLINT
base::Status GetTableStatus(uint32_t tid, uint32_t pid, bool need_schema,
::openmldb::api::TableStatus& table_status); // NOLINT
::openmldb::api::TableStatus& table_status); // NOLINT

bool FollowOfNoOne(uint32_t tid, uint32_t pid, uint64_t term,
uint64_t& offset); // NOLINT

base::Status GetTableFollower(uint32_t tid, uint32_t pid,
uint64_t& offset, // NOLINT
std::map<std::string, uint64_t>& info_map); // NOLINT
uint64_t& offset, // NOLINT
std::map<std::string, uint64_t>& info_map); // NOLINT

bool GetAllSnapshotOffset(std::map<uint32_t, std::map<uint32_t, uint64_t>>& tid_pid_offset); // NOLINT

Expand All @@ -186,8 +185,9 @@ class TabletClient : public Client {
bool DisConnectZK();

std::shared_ptr<openmldb::base::TraverseKvIterator> Traverse(uint32_t tid, uint32_t pid,
const std::string& idx_name, const std::string& pk, uint64_t ts,
uint32_t limit, bool skip_current_pk, uint32_t ts_pos, uint32_t& count); // NOLINT
const std::string& idx_name, const std::string& pk,
uint64_t ts, uint32_t limit, bool skip_current_pk,
uint32_t ts_pos, uint32_t& count); // NOLINT

bool SetMode(bool mode);

Expand All @@ -196,9 +196,8 @@ class TabletClient : public Client {
bool AddIndex(uint32_t tid, uint32_t pid, const ::openmldb::common::ColumnKey& column_key,
std::shared_ptr<TaskInfo> task_info);

bool AddMultiIndex(uint32_t tid, uint32_t pid,
const std::vector<::openmldb::common::ColumnKey>& column_keys,
std::shared_ptr<TaskInfo> task_info);
bool AddMultiIndex(uint32_t tid, uint32_t pid, const std::vector<::openmldb::common::ColumnKey>& column_keys,
std::shared_ptr<TaskInfo> task_info);

bool GetCatalog(uint64_t* version);

Expand All @@ -208,8 +207,7 @@ class TabletClient : public Client {
bool LoadIndexData(uint32_t tid, uint32_t pid, uint32_t partition_num, std::shared_ptr<TaskInfo> task_info);

bool ExtractIndexData(uint32_t tid, uint32_t pid, uint32_t partition_num,
const std::vector<::openmldb::common::ColumnKey>& column_key,
uint64_t offset, bool dump_data,
const std::vector<::openmldb::common::ColumnKey>& column_key, uint64_t offset, bool dump_data,
std::shared_ptr<TaskInfo> task_info);

bool CancelOP(const uint64_t op_id);
Expand All @@ -228,9 +226,9 @@ class TabletClient : public Client {
uint64_t timeout_ms);

base::Status CallSQLBatchRequestProcedure(const std::string& db, const std::string& sp_name,
const base::Slice& meta, const base::Slice& data,
bool is_debug, uint64_t timeout_ms,
brpc::Controller* cntl, openmldb::api::SQLBatchRequestQueryResponse* response);
const base::Slice& meta, const base::Slice& data, bool is_debug,
uint64_t timeout_ms, brpc::Controller* cntl,
openmldb::api::SQLBatchRequestQueryResponse* response);

bool DropProcedure(const std::string& db_name, const std::string& sp_name);

Expand All @@ -254,14 +252,13 @@ class TabletClient : public Client {
uint64_t timeout_ms,
openmldb::RpcCallback<openmldb::api::SQLBatchRequestQueryResponse>* callback);

base::Status CallSQLBatchRequestProcedure(const std::string& db, const std::string& sp_name,
const base::Slice& meta, const base::Slice& data,
bool is_debug, uint64_t timeout_ms,
openmldb::RpcCallback<openmldb::api::SQLBatchRequestQueryResponse>* callback);
base::Status CallSQLBatchRequestProcedure(
const std::string& db, const std::string& sp_name, const base::Slice& meta, const base::Slice& data,
bool is_debug, uint64_t timeout_ms,
openmldb::RpcCallback<openmldb::api::SQLBatchRequestQueryResponse>* callback);

bool CreateAggregator(const ::openmldb::api::TableMeta& base_table_meta,
uint32_t aggr_tid, uint32_t aggr_pid, uint32_t index_pos,
const ::openmldb::base::LongWindowInfo& window_info);
bool CreateAggregator(const ::openmldb::api::TableMeta& base_table_meta, uint32_t aggr_tid, uint32_t aggr_pid,
uint32_t index_pos, const ::openmldb::base::LongWindowInfo& window_info);

bool GetAndFlushDeployStats(::openmldb::api::DeployStatsResponse* res);

Expand Down
18 changes: 10 additions & 8 deletions src/cmd/openmldb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ void HandleNSClientSetTTL(const std::vector<std::string>& parts, ::openmldb::cli
bool ok = client->UpdateTTL(parts[1], type, abs_ttl, lat_ttl, index_name, err);
if (ok) {
std::cout << "Set ttl ok ! Note that, "
"it will take effect after two garbage collection intervals (i.e. gc_interval)." << std::endl;
"it will take effect after two garbage collection intervals (i.e. gc_interval)."
<< std::endl;
} else {
std::cout << "Set ttl failed! " << err << std::endl;
}
Expand Down Expand Up @@ -907,8 +908,8 @@ void HandleNSClientChangeLeader(const std::vector<std::string>& parts, ::openmld
std::cout << "Invalid args. pid should be uint32_t" << std::endl;
return;
}
std::cout << "change leader ok. "
"If there are writing operations while changing a leader, it may cause data loss." << std::endl;
std::cout << "change leader ok. If there are writing operations while changing a leader, it may cause data loss."
<< std::endl;
}

void HandleNSClientOfflineEndpoint(const std::vector<std::string>& parts, ::openmldb::client::NsClient* client) {
Expand Down Expand Up @@ -2694,7 +2695,7 @@ void HandleNSClientUpdateTableAlive(const std::vector<std::string>& parts, ::ope
}
}

if (auto st = client->UpdateTableAliveStatus(endpoint, name, pid, is_alive);!st.OK()) {
if (auto st = client->UpdateTableAliveStatus(endpoint, name, pid, is_alive); !st.OK()) {
std::cout << "Fail to update table alive. error msg: " << st.GetMsg() << std::endl;
return;
}
Expand Down Expand Up @@ -3107,8 +3108,9 @@ void HandleClientGetTableStatus(const std::vector<std::string> parts, ::openmldb
if (parts.size() == 3) {
::openmldb::api::TableStatus table_status;
try {
if (auto st = client->GetTableStatus(boost::lexical_cast<uint32_t>(parts[1]), boost::lexical_cast<uint32_t>(parts[2]),
table_status); st.OK()) {
if (auto st = client->GetTableStatus(boost::lexical_cast<uint32_t>(parts[1]),
boost::lexical_cast<uint32_t>(parts[2]), table_status);
st.OK()) {
status_vec.push_back(table_status);
} else {
std::cout << "gettablestatus failed, error msg: " << st.GetMsg() << std::endl;
Expand Down Expand Up @@ -3676,8 +3678,8 @@ void StartNsClient() {
}
std::shared_ptr<::openmldb::zk::ZkClient> zk_client;
if (!FLAGS_zk_cluster.empty()) {
zk_client = std::make_shared<::openmldb::zk::ZkClient>(FLAGS_zk_cluster, "",
FLAGS_zk_session_timeout, "", FLAGS_zk_root_path);
zk_client = std::make_shared<::openmldb::zk::ZkClient>(FLAGS_zk_cluster, "", FLAGS_zk_session_timeout, "",
FLAGS_zk_root_path);
if (!zk_client->Init()) {
std::cout << "zk client init failed" << std::endl;
return;
Expand Down
3 changes: 2 additions & 1 deletion src/replica/snapshot_replica_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ TEST_P(SnapshotReplicaTest, AddReplicate) {
sleep(1);

::openmldb::api::TableStatus table_status;
ASSERT_TRUE(client.GetTableStatus(tid, pid, table_status));
auto st = client.GetTableStatus(tid, pid, table_status);
ASSERT_TRUE(st.OK()) << st.ToString();
ASSERT_EQ(::openmldb::api::kTableNormal, table_status.state());

ret = client.DelReplica(tid, pid, end_point);
Expand Down

0 comments on commit 9bec5d9

Please sign in to comment.