Skip to content

Commit 569d0bb

Browse files
lingbinimay
authored andcommitted
Replace all remaining boost::split() with strings::split() (apache#2302)
1 parent f716fd2 commit 569d0bb

10 files changed

Lines changed: 59 additions & 75 deletions

File tree

be/src/exec/csv_scan_node.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
#include <string>
2121
#include <vector>
2222

23-
#include <boost/algorithm/string.hpp>
24-
#include <boost/filesystem.hpp>
25-
#include <boost/foreach.hpp>
26-
2723
#include <thrift/protocol/TDebugProtocol.h>
2824

2925
#include "exec/text_converter.hpp"
@@ -61,7 +57,6 @@ class StringRef {
6157
}
6258

6359
char const* c_str() const {
64-
6560
return _begin;
6661
}
6762
char const* begin() const {
@@ -559,7 +554,6 @@ bool CsvScanNode::split_check_fill(const std::string& line, RuntimeState* state)
559554
std::vector<StringRef> fields;
560555
{
561556
SCOPED_TIMER(_split_line_timer);
562-
// boost::split(fields, line, boost::is_any_of(_column_separator));
563557
split_line(line, _column_separator[0], fields);
564558
}
565559

be/src/runtime/routine_load/data_consumer.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <string>
2323
#include <vector>
2424

25+
#include "gutil/strings/split.h"
26+
2527
#include "common/status.h"
2628
#include "service/backend_options.h"
2729
#include "runtime/small_file_mgr.h"
@@ -34,14 +36,14 @@ namespace doris {
3436
// init kafka consumer will only set common configs such as
3537
// brokers, groupid
3638
Status KafkaDataConsumer::init(StreamLoadContext* ctx) {
37-
std::unique_lock<std::mutex> l(_lock);
39+
std::unique_lock<std::mutex> l(_lock);
3840
if (_init) {
3941
// this consumer has already been initialized.
4042
return Status::OK();
4143
}
4244

4345
RdKafka::Conf *conf = RdKafka::Conf::create(RdKafka::Conf::CONF_GLOBAL);
44-
46+
4547
// conf has to be deleted finally
4648
auto conf_deleter = [conf] () { delete conf; };
4749
DeferOp delete_conf(std::bind<void>(conf_deleter));
@@ -84,8 +86,8 @@ Status KafkaDataConsumer::init(StreamLoadContext* ctx) {
8486
for (auto& item : ctx->kafka_info->properties) {
8587
if (boost::algorithm::starts_with(item.second, "FILE:")) {
8688
// file property should has format: FILE:file_id:md5
87-
std::vector<std::string> parts;
88-
boost::split(parts, item.second, boost::is_any_of(":"));
89+
std::vector<std::string> parts = strings::Split(
90+
item.second, ":", strings::SkipWhitespace());
8991
if (parts.size() != 3) {
9092
return Status::InternalError("PAUSE: Invalid file property of kafka: " + item.second);
9193
}
@@ -94,7 +96,8 @@ Status KafkaDataConsumer::init(StreamLoadContext* ctx) {
9496
Status st = ctx->exec_env()->small_file_mgr()->get_file(file_id, parts[2], &file_path);
9597
if (!st.ok()) {
9698
std::stringstream ss;
97-
ss << "PAUSE: failed to get file for config: " << item.first << ", error: " << st.get_error_msg();
99+
ss << "PAUSE: failed to get file for config: " << item.first
100+
<< ", error: " << st.get_error_msg();
98101
return Status::InternalError(ss.str());
99102
}
100103
RETURN_IF_ERROR(set_conf(item.first, file_path));
@@ -112,7 +115,7 @@ Status KafkaDataConsumer::init(StreamLoadContext* ctx) {
112115
}
113116

114117
// create consumer
115-
_k_consumer = RdKafka::KafkaConsumer::create(conf, errstr);
118+
_k_consumer = RdKafka::KafkaConsumer::create(conf, errstr);
116119
if (!_k_consumer) {
117120
LOG(WARNING) << "PAUSE: failed to create kafka consumer: " << errstr;
118121
return Status::InternalError("PAUSE: failed to create kafka consumer: " + errstr);
@@ -263,7 +266,7 @@ Status KafkaDataConsumer::get_partition_meta(std::vector<int32_t>* partition_ids
263266
if ((*it)->topic() != _topic) {
264267
continue;
265268
}
266-
269+
267270
if ((*it)->err() != RdKafka::ERR_NO_ERROR) {
268271
std::stringstream ss;
269272
ss << "error: " << err2str((*it)->err());
@@ -284,7 +287,7 @@ Status KafkaDataConsumer::get_partition_meta(std::vector<int32_t>* partition_ids
284287
return Status::InternalError("no partition in this topic");
285288
}
286289

287-
return Status::OK();
290+
return Status::OK();
288291
}
289292

290293
Status KafkaDataConsumer::cancel(StreamLoadContext* ctx) {
@@ -309,7 +312,7 @@ Status KafkaDataConsumer::commit(std::vector<RdKafka::TopicPartition*>& offset)
309312
if (err != RdKafka::ERR_NO_ERROR) {
310313
std::stringstream ss;
311314
ss << "failed to commit kafka offset : " << RdKafka::err2str(err);
312-
return Status::InternalError(ss.str());
315+
return Status::InternalError(ss.str());
313316
}
314317
return Status::OK();
315318
}

be/src/runtime/small_file_mgr.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
#include <stdio.h>
2222
#include <sstream>
2323

24-
#include <boost/algorithm/string/split.hpp> // boost::split
2524
#include <boost/algorithm/string/predicate.hpp> // boost::algorithm::starts_with
2625
#include <boost/algorithm/string/classification.hpp> // boost::is_any_of
2726

27+
#include "gutil/strings/split.h"
28+
2829
#include "common/status.h"
2930
#include "env/env.h"
3031
#include "gen_cpp/HeartbeatService.h"
@@ -74,14 +75,13 @@ Status SmallFileMgr::_load_single_file(
7475
const std::string& file_name) {
7576
// file name format should be like:
7677
// file_id.md5
77-
std::vector<std::string> parts;
78-
boost::split(parts, file_name, boost::is_any_of("."));
78+
std::vector<std::string> parts = strings::Split(file_name, ".");
7979
if (parts.size() != 2) {
8080
return Status::InternalError("Not a valid file name: " + file_name);
8181
}
8282
int64_t file_id = std::stol(parts[0]);
8383
std::string md5 = parts[1];
84-
84+
8585
if (_file_cache.find(file_id) != _file_cache.end()) {
8686
return Status::InternalError("File with same id is already been loaded: " + file_id);
8787
}
@@ -95,7 +95,7 @@ Status SmallFileMgr::_load_single_file(
9595
CacheEntry entry;
9696
entry.path = path + "/" + file_name;
9797
entry.md5 = file_md5;
98-
98+
9999
_file_cache.emplace(file_id, entry);
100100
return Status::OK();
101101
}
@@ -106,7 +106,7 @@ Status SmallFileMgr::get_file(
106106
std::string* file_path) {
107107

108108
std::unique_lock<std::mutex> l(_lock);
109-
// find in cache
109+
// find in cache
110110
auto it = _file_cache.find(file_id);
111111
if (it != _file_cache.end()) {
112112
// find the cached file, check it
@@ -130,7 +130,7 @@ Status SmallFileMgr::get_file(
130130
// file not found in cache. download it from FE
131131
RETURN_IF_ERROR(_download_file(file_id, md5, file_path));
132132

133-
return Status::OK();
133+
return Status::OK();
134134
}
135135

136136
Status SmallFileMgr::_check_file(const CacheEntry& entry, const std::string& md5) {
@@ -226,7 +226,7 @@ Status SmallFileMgr::_download_file(
226226
entry.md5 = md5;
227227
_file_cache.emplace(file_id, entry);
228228

229-
*file_path = real_file_path;
229+
*file_path = real_file_path;
230230

231231
LOG(INFO) << "finished to download file: " << file_path;
232232
return Status::OK();

be/src/runtime/user_function_cache.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
#include <vector>
2121
#include <regex>
2222

23-
#include <boost/algorithm/string/split.hpp> // boost::split
2423
#include <boost/algorithm/string/predicate.hpp> // boost::algorithm::ends_with
2524
#include <boost/algorithm/string/classification.hpp> // boost::is_any_of
2625

26+
#include "gutil/strings/split.h"
27+
2728
#include "env/env.h"
2829
#include "http/http_client.h"
2930
#include "util/dynamic_util.h"
@@ -35,7 +36,7 @@ namespace doris {
3536

3637
static const int kLibShardNum = 128;
3738

38-
// function cache entry, store information for
39+
// function cache entry, store information for
3940
struct UserFunctionCacheEntry {
4041
UserFunctionCacheEntry(int64_t fid_, const std::string& checksum_,
4142
const std::string& lib_file_)
@@ -118,7 +119,7 @@ Status UserFunctionCache::init(const std::string& lib_dir) {
118119
_lib_dir = lib_dir;
119120
// 1. dynamic open current process
120121
RETURN_IF_ERROR(dynamic_open(nullptr, &_current_process_handle));
121-
// 2. load all cached
122+
// 2. load all cached
122123
RETURN_IF_ERROR(_load_cached_lib());
123124
return Status::OK();
124125
}
@@ -128,8 +129,7 @@ Status UserFunctionCache::_load_entry_from_lib(const std::string& dir, const std
128129
return Status::InternalError("unknown library file format");
129130
}
130131

131-
std::vector<std::string> split_parts;
132-
boost::split(split_parts, file, boost::is_any_of("."));
132+
std::vector<std::string> split_parts = strings::Split(file, ".");
133133
if (split_parts.size() != 3) {
134134
return Status::InternalError("user function's name should be function_id.checksum.so");
135135
}
@@ -283,7 +283,7 @@ void UserFunctionCache::_destroy_cache_entry(UserFunctionCacheEntry* entry) {
283283
entry->unref();
284284
}
285285
entry->should_delete_library.store(true);
286-
// now we need to drop
286+
// now we need to drop
287287
if (entry->unref()) {
288288
delete entry;
289289
}
@@ -353,7 +353,7 @@ Status UserFunctionCache::_download_lib(
353353
<< ", errno=" << errno << ", errmsg=" << strerror_r(errno, buf, 64);
354354
return Status::InternalError("fail to rename file");
355355
}
356-
356+
357357
// check download
358358
entry->is_downloaded = true;
359359
return Status::OK();

be/src/service/backend_options.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include <algorithm>
2121

22-
#include <boost/algorithm/string.hpp>
22+
#include "gutil/strings/split.h"
2323

2424
#include "common/logging.h"
2525
#include "common/status.h"
@@ -87,8 +87,8 @@ bool BackendOptions::analyze_priority_cidrs() {
8787
}
8888
LOG(INFO) << "priority cidrs in conf: " << config::priority_networks;
8989

90-
std::vector<std::string> cidr_strs;
91-
boost::split(cidr_strs, config::priority_networks, boost::is_any_of(PRIORITY_CIDR_SEPARATOR));
90+
std::vector<std::string> cidr_strs = strings::Split(
91+
config::priority_networks, PRIORITY_CIDR_SEPARATOR);
9292

9393
for (auto& cidr_str : cidr_strs) {
9494
CIDR cidr;

be/src/util/cidr.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include <arpa/inet.h>
2121

22-
#include <boost/algorithm/string.hpp>
22+
#include "gutil/strings/split.h"
2323

2424
#include "common/logging.h"
2525

@@ -44,8 +44,7 @@ bool CIDR::reset(const std::string& cidr_str) {
4444
}
4545
VLOG(2) << "cidr format str: " << cidr_format_str;
4646

47-
std::vector<std::string> cidr_items;
48-
boost::split(cidr_items, cidr_format_str, boost::is_any_of("/"));
47+
std::vector<std::string> cidr_items = strings::Split(cidr_format_str, "/");
4948
if (cidr_items.size() != 2) {
5049
LOG(WARNING) << "wrong CIDR format. network=" << cidr_str;
5150
return false;

be/src/util/disk_info.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include <boost/algorithm/string.hpp>
3030
#include <boost/algorithm/string/join.hpp>
3131

32+
#include "gutil/strings/split.h"
33+
3234
namespace doris {
3335

3436
bool DiskInfo::_s_initialized;
@@ -52,8 +54,7 @@ void DiskInfo::get_device_names() {
5254
getline(partitions, line);
5355
boost::trim(line);
5456

55-
std::vector<std::string> fields;
56-
boost::split(fields, line, boost::is_any_of(" "), boost::token_compress_on);
57+
std::vector<std::string> fields = strings::Split(line, " ", strings::SkipWhitespace());
5758

5859
if (fields.size() != 4) {
5960
continue;

0 commit comments

Comments
 (0)