[refactor] replace boost smart ptr with stl (#6856)

1. replace all boost::shared_ptr to std::shared_ptr
2. replace all boost::scopted_ptr to std::unique_ptr
3. replace all boost::scoped_array to std::unique<T[]>
4. replace all boost:thread to std::thread
This commit is contained in:
Zhengguo Yang
2021-11-17 10:18:35 +08:00
committed by GitHub
parent 4bc5ba8819
commit 6c6380969b
383 changed files with 3443 additions and 3396 deletions

View File

@ -16,8 +16,6 @@
// under the License.
#include "exprs/string_functions.h"
#include "util/vectorized-tool/lower.h"
#include "util/vectorized-tool/upper.h"
#include <re2/re2.h>
@ -30,6 +28,8 @@
#include "runtime/string_value.hpp"
#include "runtime/tuple_row.h"
#include "util/url_parser.h"
#include "util/vectorized-tool/lower.h"
#include "util/vectorized-tool/upper.h"
// NOTE: be careful not to use string::append. It is not performant.
namespace doris {
@ -120,7 +120,7 @@ StringVal StringFunctions::substring(FunctionContext* context, const StringVal&
// string left(string input, int len)
// This behaves identically to the mysql implementation.
StringVal StringFunctions::left(FunctionContext* context, const StringVal& str, const IntVal& len) {
if (len.val >= str.len) return str;
if (len.val >= str.len) return str;
return substring(context, str, 1, len);
}
@ -320,8 +320,8 @@ StringVal StringFunctions::append_trailing_char_if_absent(
// Implementation of LENGTH
// int length(string input)
// Returns the length in bytes of input. If input == NULL, returns
// NULL per MySQL
// Returns the length in bytes of input. If input == nullptr, returns
// nullptr per MySQL
IntVal StringFunctions::length(FunctionContext* context, const StringVal& str) {
if (str.is_null) {
return IntVal::null();
@ -331,8 +331,8 @@ IntVal StringFunctions::length(FunctionContext* context, const StringVal& str) {
// Implementation of CHAR_LENGTH
// int char_utf8_length(string input)
// Returns the length of characters of input. If input == NULL, returns
// NULL per MySQL
// Returns the length of characters of input. If input == nullptr, returns
// nullptr per MySQL
IntVal StringFunctions::char_utf8_length(FunctionContext* context, const StringVal& str) {
if (str.is_null) {
return IntVal::null();
@ -544,7 +544,7 @@ bool StringFunctions::set_re2_options(const StringVal& match_parameter, std::str
return true;
}
// The caller owns the returned regex. Returns NULL if the pattern could not be compiled.
// The caller owns the returned regex. Returns nullptr if the pattern could not be compiled.
static re2::RE2* compile_regex(const StringVal& pattern, std::string* error_str,
const StringVal& match_parameter) {
re2::StringPiece pattern_sp(reinterpret_cast<char*>(pattern.ptr), pattern.len);
@ -557,7 +557,7 @@ static re2::RE2* compile_regex(const StringVal& pattern, std::string* error_str,
options.set_dot_nl(true);
if (!match_parameter.is_null &&
!StringFunctions::set_re2_options(match_parameter, error_str, &options)) {
return NULL;
return nullptr;
}
re2::RE2* re = new re2::RE2(pattern_sp, options);
if (!re->ok()) {
@ -566,7 +566,7 @@ static re2::RE2* compile_regex(const StringVal& pattern, std::string* error_str,
<< "Error: " << re->error();
*error_str = ss.str();
delete re;
return NULL;
return nullptr;
}
return re;
}
@ -586,7 +586,7 @@ void StringFunctions::regexp_prepare(FunctionContext* context,
}
std::string error_str;
re2::RE2* re = compile_regex(*pattern, &error_str, StringVal::null());
if (re == NULL) {
if (re == nullptr) {
context->set_error(error_str.c_str());
return;
}
@ -614,11 +614,11 @@ StringVal StringFunctions::regexp_extract(FunctionContext* context, const String
re2::RE2* re = reinterpret_cast<re2::RE2*>(
context->get_function_state(FunctionContext::FRAGMENT_LOCAL));
std::unique_ptr<re2::RE2> scoped_re; // destroys re if we have to locally compile it
if (re == NULL) {
if (re == nullptr) {
DCHECK(!context->is_arg_constant(1));
std::string error_str;
re = compile_regex(pattern, &error_str, StringVal::null());
if (re == NULL) {
if (re == nullptr) {
context->add_warning(error_str.c_str());
return StringVal::null();
}
@ -650,12 +650,12 @@ StringVal StringFunctions::regexp_replace(FunctionContext* context, const String
re2::RE2* re = reinterpret_cast<re2::RE2*>(
context->get_function_state(FunctionContext::FRAGMENT_LOCAL));
std::unique_ptr<re2::RE2> scoped_re; // destroys re if state->re is NULL
if (re == NULL) {
std::unique_ptr<re2::RE2> scoped_re; // destroys re if state->re is nullptr
if (re == nullptr) {
DCHECK(!context->is_arg_constant(1));
std::string error_str;
re = compile_regex(pattern, &error_str, StringVal::null());
if (re == NULL) {
if (re == nullptr) {
context->add_warning(error_str.c_str());
return StringVal::null();
}
@ -807,7 +807,7 @@ StringVal StringFunctions::parse_url(FunctionContext* ctx, const StringVal& url,
StringVal newPart = AnyValUtil::from_string_temp(ctx, part_str);
void* state = ctx->get_function_state(FunctionContext::FRAGMENT_LOCAL);
UrlParser::UrlPart url_part;
if (state != NULL) {
if (state != nullptr) {
url_part = *reinterpret_cast<UrlParser::UrlPart*>(state);
} else {
DCHECK(!ctx->is_arg_constant(1));
@ -850,7 +850,7 @@ StringVal StringFunctions::parse_url_key(FunctionContext* ctx, const StringVal&
}
void* state = ctx->get_function_state(FunctionContext::FRAGMENT_LOCAL);
UrlParser::UrlPart url_part;
if (state != NULL) {
if (state != nullptr) {
url_part = *reinterpret_cast<UrlParser::UrlPart*>(state);
} else {
DCHECK(!ctx->is_arg_constant(1));
@ -892,7 +892,8 @@ StringVal StringFunctions::money_format(FunctionContext* context, const DecimalV
DecimalV2Value rounded(0);
DecimalV2Value::from_decimal_val(v).round(&rounded, 2, HALF_UP);
return do_money_format<int64_t, 26>(context, rounded.int_value(), abs(rounded.frac_value() / 10000000));
return do_money_format<int64_t, 26>(context, rounded.int_value(),
abs(rounded.frac_value() / 10000000));
}
StringVal StringFunctions::money_format(FunctionContext* context, const BigIntVal& v) {
@ -973,9 +974,9 @@ StringVal StringFunctions::replace(FunctionContext* context, const StringVal& or
if (origStr.is_null || oldStr.is_null || newStr.is_null) {
return StringVal::null();
}
// Empty string is a substring of all strings.
// Empty string is a substring of all strings.
// If old str is an empty string, the std::string.find(oldStr) is always return 0.
// With an empty old str, there is no need to do replace.
// With an empty old str, there is no need to do replace.
if (oldStr.len == 0) {
return origStr;
}
@ -993,8 +994,8 @@ StringVal StringFunctions::replace(FunctionContext* context, const StringVal& or
}
// Implementation of BIT_LENGTH
// int bit_length(string input)
// Returns the length in bits of input. If input == NULL, returns
// NULL per MySQL
// Returns the length in bits of input. If input == nullptr, returns
// nullptr per MySQL
IntVal StringFunctions::bit_length(FunctionContext* context, const StringVal& str) {
if (str.is_null) {
return IntVal::null();