Skip to content

Commit 5a84621

Browse files
authored
refactor: rm boost split (#4047)
1 parent e8c9cfa commit 5a84621

File tree

8 files changed

+25
-32
lines changed

8 files changed

+25
-32
lines changed

src/apiserver/api_server_impl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "apiserver/interface_provider.h"
2525

2626
#include "absl/cleanup/cleanup.h"
27+
#include "absl/strings/ascii.h"
2728
#include "brpc/server.h"
2829
#include "butil/time.h"
2930

@@ -160,7 +161,7 @@ void APIServerImpl::RegisterQuery() {
160161
writer << resp.Set("Json parse failed, " + req.status().ToString());
161162
return;
162163
}
163-
auto mode = boost::to_lower_copy(req.mode);
164+
auto mode = absl::AsciiStrToLower(req.mode);
164165
auto it = mode_map.find(mode);
165166
if (it == mode_map.end()) {
166167
writer << resp.Set("Invalid mode " + mode);

src/base/ddl_parser.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <vector>
2525
#include <set>
2626

27+
#include "absl/strings/str_split.h"
2728
#include "codec/schema_codec.h"
2829
#include "google/protobuf/util/message_differencer.h"
2930
#include "node/node_manager.h"
@@ -644,8 +645,7 @@ std::tuple<std::string, std::string, std::string, common::ColumnKey> IndexMapBui
644645
auto ts_sep = index_str.find(TS_MARK);
645646
auto keys_str = index_str.substr(key_sep + 1, ts_sep - key_sep - 1);
646647
// split keys
647-
std::vector<std::string> keys;
648-
boost::split(keys, keys_str, boost::is_any_of(std::string(1, KEY_SEP)));
648+
std::vector<std::string> keys = absl::StrSplit(keys_str, std::string(1, KEY_SEP));
649649
for (auto& key : keys) {
650650
DCHECK(!key.empty());
651651
column_key.add_col_name(key);

src/base/ddl_parser_test.cc

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <utility>
2020

2121
#include "absl/cleanup/cleanup.h"
22+
#include "absl/strings/strip.h"
23+
#include "absl/strings/str_split.h"
2224
#include "codec/schema_codec.h"
2325
#include "glog/logging.h"
2426
#include "google/protobuf/util/message_differencer.h"
@@ -81,23 +83,20 @@ void StrToTTLType(const std::string& ttl_type, type::TTLType* type) {
8183

8284
common::ColumnKey ParseIndex(const std::string& index_str) {
8385
common::ColumnKey key;
84-
std::vector<std::string> vec;
85-
boost::split(vec, index_str, boost::is_any_of(";"));
86+
std::vector<std::string> vec = absl::StrSplit(index_str, ";");
8687
if (vec.size() != 3) {
8788
LOG(WARNING) << "invalid index str " << index_str;
8889
return {};
8990
}
90-
std::vector<std::string> keys;
91-
boost::split(keys, vec[0], boost::is_any_of(","));
91+
std::vector<std::string> keys = absl::StrSplit(vec[0], ",");
9292
for (auto& k : keys) {
9393
key.add_col_name(k);
9494
}
9595
if (!vec[1].empty()) {
9696
key.set_ts_name(vec[1]);
9797
}
9898
// parse ttl in vec[2]
99-
std::vector<std::string> ttl_parts;
100-
boost::split(ttl_parts, vec[2], boost::is_any_of(","));
99+
std::vector<std::string> ttl_parts = absl::StrSplit(vec[2], ",");
101100
if (ttl_parts.size() != 3) {
102101
LOG(WARNING) << "invalid ttl str " << vec[2];
103102
return {};
@@ -184,8 +183,8 @@ class DDLParserTest : public ::testing::Test {
184183
// copy to trim
185184
auto name = col_name;
186185
auto type = col_type;
187-
boost::trim(name);
188-
boost::trim(type);
186+
absl::StripAsciiWhitespace(&name);
187+
absl::StripAsciiWhitespace(&type);
189188
auto col = table->add_columns();
190189
col->set_name(name);
191190
auto t = codec::DATA_TYPE_MAP.find(type);
@@ -214,13 +213,11 @@ class DDLParserTest : public ::testing::Test {
214213
const std::string& col_sep, const std::string& name_type_sep) {
215214
auto table = db->add_tables();
216215
table->set_name(table_name);
217-
std::vector<std::string> cols;
218-
boost::split(cols, cols_def, boost::is_any_of(col_sep));
216+
std::vector<std::string> cols = absl::StrSplit(cols_def, col_sep);
219217
for (auto col : cols) {
220218
// name: type
221-
std::vector<std::string> vec;
222-
boost::trim(col);
223-
boost::split(vec, col, boost::is_any_of(name_type_sep));
219+
absl::StripAsciiWhitespace(&col);
220+
std::vector<std::string> vec = absl::StrSplit(col, name_type_sep);
224221
EXPECT_EQ(vec.size(), 2);
225222

226223
auto name = vec[0];

src/cmd/openmldb.cc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <memory>
2525
#include <random>
2626

27+
#include "absl/strings/strip.h"
28+
#include "absl/strings/str_split.h"
2729
#include "base/file_util.h"
2830
#include "base/glog_wrapper.h"
2931
#include "base/hash.h"
@@ -38,7 +40,6 @@
3840
#endif
3941
#include "apiserver/api_server_impl.h"
4042
#include "auth/brpc_authenticator.h"
41-
#include "boost/algorithm/string.hpp"
4243
#include "boost/lexical_cast.hpp"
4344
#include "brpc/server.h"
4445
#include "client/ns_client.h"
@@ -371,8 +372,7 @@ int SplitPidGroup(const std::string& pid_group, std::set<uint32_t>& pid_set) {
371372
if (::openmldb::base::IsNumber(pid_group)) {
372373
pid_set.insert(boost::lexical_cast<uint32_t>(pid_group));
373374
} else if (pid_group.find('-') != std::string::npos) {
374-
std::vector<std::string> vec;
375-
boost::split(vec, pid_group, boost::is_any_of("-"));
375+
std::vector<std::string> vec = absl::StrSplit(pid_group, "-");
376376
if (vec.size() != 2 || !::openmldb::base::IsNumber(vec[0]) || !::openmldb::base::IsNumber(vec[1])) {
377377
return -1;
378378
}
@@ -383,8 +383,7 @@ int SplitPidGroup(const std::string& pid_group, std::set<uint32_t>& pid_set) {
383383
start_index++;
384384
}
385385
} else if (pid_group.find(',') != std::string::npos) {
386-
std::vector<std::string> vec;
387-
boost::split(vec, pid_group, boost::is_any_of(","));
386+
std::vector<std::string> vec = absl::StrSplit(pid_group, ",");
388387
for (const auto& pid_str : vec) {
389388
if (!::openmldb::base::IsNumber(pid_str)) {
390389
return -1;
@@ -3630,7 +3629,7 @@ void StartClient() {
36303629
}
36313630
if (line[0] != '\0' && line[0] != '/') {
36323631
buffer.assign(line);
3633-
boost::trim(buffer);
3632+
absl::StripAsciiWhitespace(&buffer);
36343633
if (!buffer.empty()) {
36353634
::openmldb::base::linenoiseHistoryAdd(line);
36363635
}
@@ -3780,7 +3779,7 @@ void StartNsClient() {
37803779

37813780
if (line[0] != '\0' && line[0] != '/') {
37823781
buffer.assign(line);
3783-
boost::trim(buffer);
3782+
absl::StripAsciiWhitespace(&buffer);
37843783
if (!buffer.empty()) {
37853784
::openmldb::base::linenoiseHistoryAdd(line);
37863785
}
@@ -3909,8 +3908,7 @@ void StartAPIServer() {
39093908

39103909
auto api_service = std::make_unique<::openmldb::apiserver::APIServerImpl>(real_endpoint);
39113910
if (!FLAGS_nameserver.empty()) {
3912-
std::vector<std::string> vec;
3913-
boost::split(vec, FLAGS_nameserver, boost::is_any_of(":"));
3911+
std::vector<std::string> vec = absl::StrSplit(FLAGS_nameserver, ":");
39143912
if (vec.size() != 2) {
39153913
PDLOG(WARNING, "Invalid nameserver format");
39163914
exit(1);

src/codec/row_codec.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <vector>
2222

2323
#include "base/glog_wrapper.h"
24-
#include "boost/algorithm/string.hpp"
2524
#include "boost/container/deque.hpp"
2625
#include "codec/schema_codec.h"
2726
#include "codec/row_codec.h"

src/codec/schema_codec.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "codec/fe_row_codec.h"
3333
#include "codec/field_codec.h"
3434
#include "proto/name_server.pb.h"
35-
#include <boost/algorithm/string.hpp>
3635

3736
namespace openmldb {
3837
namespace codec {

src/nameserver/name_server_impl.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "absl/strings/numbers.h"
2727
#include "absl/strings/str_cat.h"
28+
#include "absl/strings/str_join.h"
2829
#include "absl/strings/str_split.h"
2930
#include "absl/time/time.h"
3031
#include "nameserver/system_table.h"
@@ -41,7 +42,6 @@
4142
#include "base/proto_util.h"
4243
#include "base/status.h"
4344
#include "base/strings.h"
44-
#include "boost/algorithm/string.hpp"
4545
#include "boost/bind.hpp"
4646
#include "codec/row_codec.h"
4747
#include "gflags/gflags.h"
@@ -1456,7 +1456,7 @@ base::Status NameServerImpl::FlushPrivileges() {
14561456
}
14571457
if (failed_tablet_list.size() > 0) {
14581458
return {ReturnCode::kFlushPrivilegesFailed,
1459-
"Failed to flush privileges to tablets: " + boost::algorithm::join(failed_tablet_list, ", ")};
1459+
"Failed to flush privileges to tablets: " + absl::StrJoin(failed_tablet_list, ", ")};
14601460
}
14611461
return {};
14621462
}

src/zk/zk_client.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include <utility>
2121

2222
#include "absl/cleanup/cleanup.h"
23+
#include "absl/strings/str_split.h"
2324
#include "base/glog_wrapper.h"
2425
#include "base/strings.h"
25-
#include "boost/algorithm/string.hpp"
2626
#include "boost/lexical_cast.hpp"
2727
#include "gflags/gflags.h"
2828

@@ -617,8 +617,7 @@ bool ZkClient::MkdirNoLock(const std::string& path) {
617617
if (zk_ == NULL || !connected_) {
618618
return false;
619619
}
620-
std::vector<std::string> parts;
621-
boost::split(parts, path, boost::is_any_of("/"));
620+
std::vector<std::string> parts = absl::StrSplit(path, "/");
622621
std::string full_path = "/";
623622
std::vector<std::string>::iterator it = parts.begin();
624623
int32_t index = 0;

0 commit comments

Comments
 (0)