You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ad...@apache.org on 2023/04/11 11:21:28 UTC
[doris] branch branch-1.2-lts updated: [chore](build) Fix deprecated-declarations errors (#18552)
This is an automated email from the ASF dual-hosted git repository.
adonisling pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
new 7d1c0d9dbf [chore](build) Fix deprecated-declarations errors (#18552)
7d1c0d9dbf is described below
commit 7d1c0d9dbfc740bc2fbabbd4f8337c5357c80e75
Author: Adonis Ling <ad...@gmail.com>
AuthorDate: Tue Apr 11 19:21:21 2023 +0800
[chore](build) Fix deprecated-declarations errors (#18552)
Backport #16670 #16991 .
Co-authored-by: Jack Drogon <ja...@gmail.com>
---
be/src/exec/table_connector.cpp | 40 ++++++++++++++++++++++++++++++++++++----
be/src/gutil/stl_util.h | 15 +++++----------
be/src/gutil/strings/numbers.h | 9 ++++-----
be/src/gutil/strings/util.h | 5 ++---
be/src/util/container_util.hpp | 4 ++--
5 files changed, 49 insertions(+), 24 deletions(-)
diff --git a/be/src/exec/table_connector.cpp b/be/src/exec/table_connector.cpp
index 00114adee8..b803d7fea5 100644
--- a/be/src/exec/table_connector.cpp
+++ b/be/src/exec/table_connector.cpp
@@ -17,9 +17,10 @@
#include "exec/table_connector.h"
+#include <fmt/core.h>
#include <gen_cpp/Types_types.h>
-
-#include <codecvt>
+#include <glog/logging.h>
+#include <iconv.h>
#include "exprs/expr.h"
#include "runtime/define_primitive_type.h"
@@ -47,8 +48,39 @@ void TableConnector::init_profile(doris::RuntimeProfile* profile) {
}
std::u16string TableConnector::utf8_to_u16string(const char* first, const char* last) {
- std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> utf8_utf16_cvt;
- return utf8_utf16_cvt.from_bytes(first, last);
+ auto deleter = [](auto convertor) {
+ if (convertor == reinterpret_cast<decltype(convertor)>(-1)) {
+ return;
+ }
+ iconv_close(convertor);
+ };
+ std::unique_ptr<std::remove_pointer_t<iconv_t>, decltype(deleter)> convertor(
+ iconv_open("UTF-16LE", "UTF-8"), deleter);
+
+ char* in = const_cast<char*>(first);
+ size_t inbytesleft = last - first;
+
+ char16_t buffer[1024];
+ char* out = reinterpret_cast<char*>(&buffer[0]);
+ size_t outbytesleft = sizeof(buffer);
+
+ std::u16string result;
+ while (inbytesleft > 0) {
+ if (iconv(convertor.get(), &in, &inbytesleft, &out, &outbytesleft)) {
+ if (errno == E2BIG) {
+ result += std::u16string_view(buffer,
+ (sizeof(buffer) - outbytesleft) / sizeof(char16_t));
+ out = reinterpret_cast<char*>(&buffer[0]);
+ outbytesleft = sizeof(buffer);
+ } else {
+ LOG(WARNING) << fmt::format("Failed to convert the UTF-8 string {} to UTF-16LE",
+ std::string(first, last));
+ return result;
+ }
+ }
+ }
+ result += std::u16string_view(buffer, (sizeof(buffer) - outbytesleft) / sizeof(char16_t));
+ return result;
}
Status TableConnector::append(const std::string& table_name, RowBatch* batch,
diff --git a/be/src/gutil/stl_util.h b/be/src/gutil/stl_util.h
index b2bc50a2da..c528465ada 100644
--- a/be/src/gutil/stl_util.h
+++ b/be/src/gutil/stl_util.h
@@ -41,7 +41,6 @@ using std::swap;
#include <deque>
using std::deque;
#include <functional>
-using std::binary_function;
using std::less;
#include <iterator>
using std::back_insert_iterator;
@@ -641,7 +640,7 @@ bool STLIncludes(const SortedSTLContainerA& a, const SortedSTLContainerB& b) {
// the contents of an STL map. For other sample usage, see the unittest.
template <typename Pair, typename UnaryOp>
-class UnaryOperateOnFirst : public std::unary_function<Pair, typename UnaryOp::result_type> {
+class UnaryOperateOnFirst {
public:
UnaryOperateOnFirst() {}
@@ -660,7 +659,7 @@ UnaryOperateOnFirst<Pair, UnaryOp> UnaryOperate1st(const UnaryOp& f) {
}
template <typename Pair, typename UnaryOp>
-class UnaryOperateOnSecond : public std::unary_function<Pair, typename UnaryOp::result_type> {
+class UnaryOperateOnSecond {
public:
UnaryOperateOnSecond() {}
@@ -679,8 +678,7 @@ UnaryOperateOnSecond<Pair, UnaryOp> UnaryOperate2nd(const UnaryOp& f) {
}
template <typename Pair, typename BinaryOp>
-class BinaryOperateOnFirst
- : public std::binary_function<Pair, Pair, typename BinaryOp::result_type> {
+class BinaryOperateOnFirst {
public:
BinaryOperateOnFirst() {}
@@ -702,8 +700,7 @@ BinaryOperateOnFirst<Pair, BinaryOp> BinaryOperate1st(const BinaryOp& f) {
}
template <typename Pair, typename BinaryOp>
-class BinaryOperateOnSecond
- : public std::binary_function<Pair, Pair, typename BinaryOp::result_type> {
+class BinaryOperateOnSecond {
public:
BinaryOperateOnSecond() {}
@@ -736,9 +733,7 @@ BinaryOperateOnSecond<Pair, BinaryOp> BinaryOperate2nd(const BinaryOp& f) {
// F has to be a model of AdaptableBinaryFunction.
// G1 and G2 have to be models of AdabtableUnaryFunction.
template <typename F, typename G1, typename G2>
-class BinaryComposeBinary
- : public binary_function<typename G1::argument_type, typename G2::argument_type,
- typename F::result_type> {
+class BinaryComposeBinary {
public:
BinaryComposeBinary(F f, G1 g1, G2 g2) : f_(f), g1_(g1), g2_(g2) {}
diff --git a/be/src/gutil/strings/numbers.h b/be/src/gutil/strings/numbers.h
index fd53353945..b5b74e332c 100644
--- a/be/src/gutil/strings/numbers.h
+++ b/be/src/gutil/strings/numbers.h
@@ -11,7 +11,6 @@
#include <time.h>
#include <functional>
-using std::binary_function;
using std::less;
#include <limits>
using std::numeric_limits;
@@ -329,25 +328,25 @@ bool AutoDigitLessThan(const char* a, int alen, const char* b, int blen);
bool StrictAutoDigitLessThan(const char* a, int alen, const char* b, int blen);
-struct autodigit_less : public binary_function<const string&, const string&, bool> {
+struct autodigit_less {
bool operator()(const string& a, const string& b) const {
return AutoDigitLessThan(a.data(), a.size(), b.data(), b.size());
}
};
-struct autodigit_greater : public binary_function<const string&, const string&, bool> {
+struct autodigit_greater {
bool operator()(const string& a, const string& b) const {
return AutoDigitLessThan(b.data(), b.size(), a.data(), a.size());
}
};
-struct strict_autodigit_less : public binary_function<const string&, const string&, bool> {
+struct strict_autodigit_less {
bool operator()(const string& a, const string& b) const {
return StrictAutoDigitLessThan(a.data(), a.size(), b.data(), b.size());
}
};
-struct strict_autodigit_greater : public binary_function<const string&, const string&, bool> {
+struct strict_autodigit_greater {
bool operator()(const string& a, const string& b) const {
return StrictAutoDigitLessThan(b.data(), b.size(), a.data(), a.size());
}
diff --git a/be/src/gutil/strings/util.h b/be/src/gutil/strings/util.h
index 92db70f663..5aaa058f48 100644
--- a/be/src/gutil/strings/util.h
+++ b/be/src/gutil/strings/util.h
@@ -34,7 +34,6 @@
#endif
#include <functional>
-using std::binary_function;
using std::less;
#include <string>
using std::string;
@@ -253,7 +252,7 @@ char* AdjustedLastPos(const char* str, char separator, int n);
// Compares two char* strings for equality. (Works with NULL, which compares
// equal only to another NULL). Useful in hash tables:
// hash_map<const char*, Value, hash<const char*>, streq> ht;
-struct streq : public binary_function<const char*, const char*, bool> {
+struct streq {
bool operator()(const char* s1, const char* s2) const {
return ((s1 == 0 && s2 == 0) || (s1 && s2 && *s1 == *s2 && strcmp(s1, s2) == 0));
}
@@ -262,7 +261,7 @@ struct streq : public binary_function<const char*, const char*, bool> {
// Compares two char* strings. (Works with NULL, which compares greater than any
// non-NULL). Useful in maps:
// map<const char*, Value, strlt> m;
-struct strlt : public binary_function<const char*, const char*, bool> {
+struct strlt {
bool operator()(const char* s1, const char* s2) const {
return (s1 != s2) && (s2 == 0 || (s1 != 0 && strcmp(s1, s2) < 0));
}
diff --git a/be/src/util/container_util.hpp b/be/src/util/container_util.hpp
index 25b6104ef7..9f11c46983 100644
--- a/be/src/util/container_util.hpp
+++ b/be/src/util/container_util.hpp
@@ -35,11 +35,11 @@ inline std::size_t hash_value(const TNetworkAddress& host_port) {
return HashUtil::hash(&host_port.port, sizeof(host_port.port), hash);
}
-struct HashTNetworkAddressPtr : public std::unary_function<TNetworkAddress*, size_t> {
+struct HashTNetworkAddressPtr {
size_t operator()(const TNetworkAddress* const& p) const { return hash_value(*p); }
};
-struct TNetworkAddressPtrEquals : public std::unary_function<TNetworkAddress*, bool> {
+struct TNetworkAddressPtrEquals {
bool operator()(const TNetworkAddress* const& p1, const TNetworkAddress* const& p2) const {
return p1->hostname == p2->hostname && p1->port == p2->port;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org