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
3638Status 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
290293Status 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}
0 commit comments