This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 2ded5c72388 branch-4.0: [fix] remove useless const_cast and explain
const_cast(2) #56427 (#58009)
2ded5c72388 is described below
commit 2ded5c723888a7b9683a24e062fa4353d09ede42
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Nov 14 14:25:35 2025 +0800
branch-4.0: [fix] remove useless const_cast and explain const_cast(2)
#56427 (#58009)
Cherry-picked from #56427
Co-authored-by: admiring_xm <[email protected]>
---
be/src/exec/olap_common.h | 10 +++---
be/src/exec/rowid_fetcher.cpp | 3 ++
be/src/olap/tablet_meta.cpp | 2 +-
be/src/pipeline/exec/exchange_sink_buffer.cpp | 3 +-
be/src/pipeline/exec/scan_operator.cpp | 41 ++++++++++++----------
be/src/pipeline/exec/scan_operator.h | 2 +-
be/src/util/disk_info_mac.cpp | 1 +
be/src/util/encryption_util.cpp | 2 +-
be/src/util/jni-util.cpp | 1 +
be/src/util/jsonb_document.h | 26 ++++++++++++--
be/src/util/lru_multi_cache.h | 2 +-
be/src/util/lru_multi_cache.inline.h | 4 +--
be/src/util/proto_util.h | 14 +++-----
be/src/util/slice.h | 2 +-
be/src/util/url_parser.cpp | 30 ++++++++--------
.../data_types/serde/data_type_struct_serde.cpp | 2 +-
16 files changed, 85 insertions(+), 60 deletions(-)
diff --git a/be/src/exec/olap_common.h b/be/src/exec/olap_common.h
index b9eb268fd6f..5d9f3741c51 100644
--- a/be/src/exec/olap_common.h
+++ b/be/src/exec/olap_common.h
@@ -329,16 +329,18 @@ public:
int scale() const { return _scale; }
- static void add_fixed_value_range(ColumnValueRange<primitive_type>& range,
CppType* value) {
+ static void add_fixed_value_range(ColumnValueRange<primitive_type>& range,
+ const CppType* value) {
static_cast<void>(range.add_fixed_value(*value));
}
- static void remove_fixed_value_range(ColumnValueRange<primitive_type>&
range, CppType* value) {
+ static void remove_fixed_value_range(ColumnValueRange<primitive_type>&
range,
+ const CppType* value) {
range.remove_fixed_value(*value);
}
static void add_value_range(ColumnValueRange<primitive_type>& range,
SQLFilterOp op,
- CppType* value) {
+ const CppType* value) {
static_cast<void>(range.add_range(op, *value));
}
@@ -755,7 +757,7 @@ void
ColumnValueRange<primitive_type>::convert_to_range_value() {
}
template <PrimitiveType primitive_type>
-Status ColumnValueRange<primitive_type>::add_range(SQLFilterOp op, CppType
value) {
+Status ColumnValueRange<primitive_type>::add_range(SQLFilterOp op, const
CppType value) {
if (INVALID_TYPE == _column_type) {
return Status::InternalError("AddRange failed, Invalid type");
}
diff --git a/be/src/exec/rowid_fetcher.cpp b/be/src/exec/rowid_fetcher.cpp
index 189923f974c..0f4619e1303 100644
--- a/be/src/exec/rowid_fetcher.cpp
+++ b/be/src/exec/rowid_fetcher.cpp
@@ -519,6 +519,7 @@ Status RowIdStorageReader::read_by_rowids(const
PMultiGetRequestV2& request,
PMultiGetResponseV2* response) {
if (request.request_block_descs_size()) {
auto tquery_id = ((UniqueId)request.query_id()).to_thrift();
+ // todo: use mutableBlock instead of block
std::vector<vectorized::Block>
result_blocks(request.request_block_descs_size());
OlapReaderStatistics stats;
@@ -949,6 +950,8 @@ Status RowIdStorageReader::read_batch_external_row(
// Insert the read data into result_block.
for (size_t column_id = 0; column_id < result_block.get_columns().size();
column_id++) {
+ // The non-const Block(result_block) is passed in read_by_rowids, but
columns[i] in get_columns
+ // is at bottom an immutable_ptr of Cow<IColumn>, so use const_cast
auto dst_col =
const_cast<vectorized::IColumn*>(result_block.get_columns()[column_id].get());
diff --git a/be/src/olap/tablet_meta.cpp b/be/src/olap/tablet_meta.cpp
index 2757ab0ec2e..b489bb42edd 100644
--- a/be/src/olap/tablet_meta.cpp
+++ b/be/src/olap/tablet_meta.cpp
@@ -1179,7 +1179,7 @@ static void decode_agg_cache_key(const std::string&
key_str, int64_t& tablet_id,
const char* ptr = key_str.data();
tablet_id = *reinterpret_cast<const int64_t*>(ptr);
ptr += sizeof(tablet_id);
- auto* t =
reinterpret_cast<DeleteBitmap::BitmapKey*>(const_cast<char*>(ptr));
+ const auto* t = reinterpret_cast<const DeleteBitmap::BitmapKey*>(ptr);
std::get<RowsetId>(bmk).version = std::get<RowsetId>(*t).version;
std::get<RowsetId>(bmk).hi = std::get<RowsetId>(*t).hi;
std::get<RowsetId>(bmk).mi = std::get<RowsetId>(*t).mi;
diff --git a/be/src/pipeline/exec/exchange_sink_buffer.cpp
b/be/src/pipeline/exec/exchange_sink_buffer.cpp
index 92a2766c930..0342bfd16c4 100644
--- a/be/src/pipeline/exec/exchange_sink_buffer.cpp
+++ b/be/src/pipeline/exec/exchange_sink_buffer.cpp
@@ -424,8 +424,7 @@ Status ExchangeSinkBuffer::_send_rpc(RpcInstance&
instance_data) {
add_block->set_compressed(block->compressed());
add_block->set_compression_type(block->compression_type());
add_block->set_uncompressed_size(block->uncompressed_size());
- add_block->set_allocated_column_values(
- const_cast<std::string*>(&block->column_values()));
+
add_block->set_allocated_column_values(block->mutable_column_values());
}
}
} else {
diff --git a/be/src/pipeline/exec/scan_operator.cpp
b/be/src/pipeline/exec/scan_operator.cpp
index e1afa1960fe..60536cbbbc9 100644
--- a/be/src/pipeline/exec/scan_operator.cpp
+++ b/be/src/pipeline/exec/scan_operator.cpp
@@ -547,14 +547,14 @@ Status
ScanLocalState<Derived>::_eval_const_conjuncts(vectorized::VExpr* vexpr,
vectorized::VExprContext* expr_ctx,
PushDownType* pdt) {
// Used to handle constant expressions, such as '1 = 1'
_eval_const_conjuncts does not handle cases like 'colA = 1'
- char* constant_val = nullptr;
+ const char* constant_val = nullptr;
if (vexpr->is_constant()) {
std::shared_ptr<ColumnPtrWrapper> const_col_wrapper;
RETURN_IF_ERROR(vexpr->get_const_col(expr_ctx, &const_col_wrapper));
if (const auto* const_column =
check_and_get_column<vectorized::ColumnConst>(
const_col_wrapper->column_ptr.get())) {
- constant_val =
const_cast<char*>(const_column->get_data_at(0).data);
- if (constant_val == nullptr ||
!*reinterpret_cast<bool*>(constant_val)) {
+ constant_val = const_column->get_data_at(0).data;
+ if (constant_val == nullptr || !*reinterpret_cast<const
bool*>(constant_val)) {
*pdt = PushDownType::ACCEPTABLE;
_eos = true;
_scan_dependency->set_ready();
@@ -571,8 +571,8 @@ Status
ScanLocalState<Derived>::_eval_const_conjuncts(vectorized::VExpr* vexpr,
DCHECK_EQ(bool_column->size(), 1);
/// TODO: There is a DCHECK here, but an additional check is still
needed. It should return an error code.
if (bool_column->size() == 1) {
- constant_val =
const_cast<char*>(bool_column->get_data_at(0).data);
- if (constant_val == nullptr ||
!*reinterpret_cast<bool*>(constant_val)) {
+ constant_val = bool_column->get_data_at(0).data;
+ if (constant_val == nullptr || !*reinterpret_cast<const
bool*>(constant_val)) {
*pdt = PushDownType::ACCEPTABLE;
_eos = true;
_scan_dependency->set_ready();
@@ -658,7 +658,7 @@ Status
ScanLocalState<Derived>::_normalize_in_and_eq_predicate(vectorized::VExpr
// column in (nullptr) is always false so continue to
// dispose next item
DCHECK(iter->get_value() != nullptr);
- auto* value = const_cast<void*>(iter->get_value());
+ const auto* value = iter->get_value();
RETURN_IF_ERROR(_change_value_range<true>(
temp_range, value,
ColumnValueRange<T>::add_fixed_value_range, ""));
iter->next();
@@ -696,7 +696,7 @@ Status
ScanLocalState<Derived>::_normalize_in_and_eq_predicate(vectorized::VExpr
value.size, sizeof(typename
PrimitiveTypeTraits<T>::CppType));
}
RETURN_IF_ERROR(_change_value_range<true>(
- temp_range,
reinterpret_cast<void*>(const_cast<char*>(value.data)),
+ temp_range, reinterpret_cast<const void*>(value.data),
ColumnValueRange<T>::add_fixed_value_range, fn_name));
}
range.intersection(temp_range);
@@ -801,7 +801,7 @@ Status
ScanLocalState<Derived>::_normalize_not_in_and_not_eq_predicate(
while (iter->has_next()) {
// column not in (nullptr) is always true
DCHECK(iter->get_value() != nullptr);
- auto value = const_cast<void*>(iter->get_value());
+ const auto value = iter->get_value();
if (is_fixed_range) {
RETURN_IF_ERROR(_change_value_range<true>(
range, value,
ColumnValueRange<T>::remove_fixed_value_range, fn_name));
@@ -843,11 +843,11 @@ Status
ScanLocalState<Derived>::_normalize_not_in_and_not_eq_predicate(
} else {
if (is_fixed_range) {
RETURN_IF_ERROR(_change_value_range<true>(
- range,
reinterpret_cast<void*>(const_cast<char*>(value.data)),
+ range, reinterpret_cast<const void*>(value.data),
ColumnValueRange<T>::remove_fixed_value_range,
fn_name));
} else {
RETURN_IF_ERROR(_change_value_range<true>(
- not_in_range,
reinterpret_cast<void*>(const_cast<char*>(value.data)),
+ not_in_range, reinterpret_cast<const
void*>(value.data),
ColumnValueRange<T>::add_fixed_value_range,
fn_name));
}
}
@@ -873,7 +873,7 @@ Status
ScanLocalState<Derived>::_normalize_not_in_and_not_eq_predicate(
template <typename Derived>
template <bool IsFixed, PrimitiveType PrimitiveType, typename
ChangeFixedValueRangeFunc>
Status
ScanLocalState<Derived>::_change_value_range(ColumnValueRange<PrimitiveType>&
temp_range,
- void* value,
+ const void* value,
const
ChangeFixedValueRangeFunc& func,
const std::string& fn_name,
int slot_ref_child) {
@@ -899,18 +899,19 @@ Status
ScanLocalState<Derived>::_change_value_range(ColumnValueRange<PrimitiveTy
} else if constexpr (PrimitiveType == TYPE_DATETIME) {
if constexpr (IsFixed) {
func(temp_range,
- reinterpret_cast<typename
PrimitiveTypeTraits<PrimitiveType>::CppType*>(value));
+ reinterpret_cast<const typename
PrimitiveTypeTraits<PrimitiveType>::CppType*>(
+ value));
} else {
func(temp_range, to_olap_filter_type(fn_name, slot_ref_child),
- reinterpret_cast<typename
PrimitiveTypeTraits<PrimitiveType>::CppType*>(
- reinterpret_cast<char*>(value)));
+ reinterpret_cast<const typename
PrimitiveTypeTraits<PrimitiveType>::CppType*>(
+ reinterpret_cast<const char*>(value)));
}
} else if constexpr (PrimitiveType == TYPE_HLL) {
if constexpr (IsFixed) {
- func(temp_range, reinterpret_cast<StringRef*>(value));
+ func(temp_range, reinterpret_cast<const StringRef*>(value));
} else {
func(temp_range, to_olap_filter_type(fn_name, slot_ref_child),
- reinterpret_cast<StringRef*>(value));
+ reinterpret_cast<const StringRef*>(value));
}
} else if constexpr ((PrimitiveType == TYPE_DECIMALV2) || (PrimitiveType
== TYPE_CHAR) ||
(PrimitiveType == TYPE_VARCHAR) || (PrimitiveType ==
TYPE_DATETIMEV2) ||
@@ -924,10 +925,12 @@ Status
ScanLocalState<Derived>::_change_value_range(ColumnValueRange<PrimitiveTy
(PrimitiveType == TYPE_BOOLEAN) || (PrimitiveType ==
TYPE_DATEV2)) {
if constexpr (IsFixed) {
func(temp_range,
- reinterpret_cast<typename
PrimitiveTypeTraits<PrimitiveType>::CppType*>(value));
+ reinterpret_cast<const typename
PrimitiveTypeTraits<PrimitiveType>::CppType*>(
+ value));
} else {
func(temp_range, to_olap_filter_type(fn_name, slot_ref_child),
- reinterpret_cast<typename
PrimitiveTypeTraits<PrimitiveType>::CppType*>(value));
+ reinterpret_cast<const typename
PrimitiveTypeTraits<PrimitiveType>::CppType*>(
+ value));
}
} else {
static_assert(always_false_v<PrimitiveType>);
@@ -1000,7 +1003,7 @@ Status
ScanLocalState<Derived>::_normalize_noneq_binary_predicate(
fn_name,
slot_ref_child));
} else {
RETURN_IF_ERROR(_change_value_range<false>(
- range,
reinterpret_cast<void*>(const_cast<char*>(value.data)),
+ range, reinterpret_cast<const void*>(value.data),
ColumnValueRange<T>::add_value_range, fn_name,
slot_ref_child));
}
*pdt = temp_pdt;
diff --git a/be/src/pipeline/exec/scan_operator.h
b/be/src/pipeline/exec/scan_operator.h
index 919e6b53c6f..92362921b78 100644
--- a/be/src/pipeline/exec/scan_operator.h
+++ b/be/src/pipeline/exec/scan_operator.h
@@ -280,7 +280,7 @@ protected:
bool _ignore_cast(SlotDescriptor* slot, vectorized::VExpr* expr);
template <bool IsFixed, PrimitiveType PrimitiveType, typename
ChangeFixedValueRangeFunc>
- Status _change_value_range(ColumnValueRange<PrimitiveType>& range, void*
value,
+ Status _change_value_range(ColumnValueRange<PrimitiveType>& range, const
void* value,
const ChangeFixedValueRangeFunc& func, const
std::string& fn_name,
int slot_ref_child = -1);
diff --git a/be/src/util/disk_info_mac.cpp b/be/src/util/disk_info_mac.cpp
index ef35a01cec9..170faa05c19 100644
--- a/be/src/util/disk_info_mac.cpp
+++ b/be/src/util/disk_info_mac.cpp
@@ -157,6 +157,7 @@ Status DiskInfo::get_disk_devices(const
std::vector<std::string>& paths,
match_dev = info.first;
}
if (max_mount_size > 0) {
+ // The library function uses char* and `match_dev` is std::string,
so use const_cast.
devices->emplace(basename(const_cast<char*>(match_dev.c_str())));
}
}
diff --git a/be/src/util/encryption_util.cpp b/be/src/util/encryption_util.cpp
index bf6777a5c88..02dc512dcfa 100644
--- a/be/src/util/encryption_util.cpp
+++ b/be/src/util/encryption_util.cpp
@@ -318,7 +318,7 @@ static int do_gcm_decrypt(EVP_CIPHER_CTX* cipher_ctx, const
EVP_CIPHER* cipher,
}
encrypt += real_encrypt_length;
decrypt_content += u_len;
-
+ // Since a third-party library was used, `encrypt` ultimately remained
unmodified, so `const_cast` can be used.
void* tag = const_cast<void*>(reinterpret_cast<const void*>(encrypt));
ret = EVP_CIPHER_CTX_ctrl(cipher_ctx, EVP_CTRL_GCM_SET_TAG,
EncryptionUtil::GCM_TAG_SIZE, tag);
if (ret != 1) {
diff --git a/be/src/util/jni-util.cpp b/be/src/util/jni-util.cpp
index f3865f30899..f0ed67394ba 100644
--- a/be/src/util/jni-util.cpp
+++ b/be/src/util/jni-util.cpp
@@ -138,6 +138,7 @@ const std::string GetKerb5ConfPath() {
options.push_back(GetKerb5ConfPath());
std::unique_ptr<JavaVMOption[]> jvm_options(new
JavaVMOption[options.size()]);
for (int i = 0; i < options.size(); ++i) {
+ // To convert a string to a char*, const_cast is used.
jvm_options[i] = {const_cast<char*>(options[i].c_str()), nullptr};
}
diff --git a/be/src/util/jsonb_document.h b/be/src/util/jsonb_document.h
index 30f3ea040b9..34f47fa0b01 100644
--- a/be/src/util/jsonb_document.h
+++ b/be/src/util/jsonb_document.h
@@ -885,10 +885,14 @@ struct ObjectVal : public ContainerVal {
using const_iterator = JsonbFwdIteratorT<const_pointer, ObjectVal>;
const_iterator search(const char* key) const {
+ // Calling a non-const method on a const variable and does not modify
the
+ // variable; using const_cast is permissible
return const_cast<ObjectVal*>(this)->search(key);
}
const_iterator search(const char* key, unsigned int klen) const {
+ // Calling a non-const method on a const variable and does not modify
the
+ // variable; using const_cast is permissible
return const_cast<ObjectVal*>(this)->search(key, klen);
}
@@ -923,9 +927,15 @@ struct ObjectVal : public ContainerVal {
return num;
}
- JsonbValue* find(const char* key) const { return
const_cast<ObjectVal*>(this)->find(key); }
+ const JsonbValue* find(const char* key) const {
+ // Calling a non-const method on a const variable and does not modify
the
+ // variable; using const_cast is permissible
+ return const_cast<ObjectVal*>(this)->find(key);
+ }
- JsonbValue* find(const char* key, unsigned int klen) const {
+ const JsonbValue* find(const char* key, unsigned int klen) const {
+ // Calling a non-const method on a const variable and does not modify
the
+ // variable; using const_cast is permissible
return const_cast<ObjectVal*>(this)->find(key, klen);
}
@@ -1237,7 +1247,7 @@ inline bool JsonbValue::contains(JsonbValue* rhs) const {
const auto* obj_value1 = unpack<ObjectVal>();
const auto* obj_value2 = rhs->unpack<ObjectVal>();
for (auto it = obj_value2->begin(); it != obj_value2->end(); ++it)
{
- JsonbValue* value = obj_value1->find(it->getKeyStr(),
it->klen());
+ const JsonbValue* value = obj_value1->find(it->getKeyStr(),
it->klen());
if (value == nullptr || !value->contains(it->value())) {
return false;
}
@@ -1399,6 +1409,8 @@ inline bool JsonbPath::parse_array(Stream* stream,
JsonbPath* path) {
}
if (stream->peek() == WILDCARD) {
+ // Called by function_jsonb.cpp, the variables passed in originate
from a mutable block;
+ // using const_cast is acceptable.
stream->set_leg_ptr(const_cast<char*>(stream->position()));
stream->add_leg_len();
stream->skip(1);
@@ -1418,6 +1430,8 @@ inline bool JsonbPath::parse_array(Stream* stream,
JsonbPath* path) {
}
}
+ // Called by function_jsonb.cpp, the variables passed in originate from a
mutable block;
+ // using const_cast is acceptable.
stream->set_leg_ptr(const_cast<char*>(stream->position()));
for (; !stream->exhausted() && stream->peek() != END_ARRAY;
stream->advance()) {
@@ -1488,6 +1502,8 @@ inline bool JsonbPath::parse_member(Stream* stream,
JsonbPath* path) {
}
if (stream->peek() == WILDCARD) {
+ // Called by function_jsonb.cpp, the variables passed in originate
from a mutable block;
+ // using const_cast is acceptable.
stream->set_leg_ptr(const_cast<char*>(stream->position()));
stream->add_leg_len();
stream->skip(1);
@@ -1498,6 +1514,8 @@ inline bool JsonbPath::parse_member(Stream* stream,
JsonbPath* path) {
return true;
}
+ // Called by function_jsonb.cpp, the variables passed in originate from a
mutable block;
+ // using const_cast is acceptable.
stream->set_leg_ptr(const_cast<char*>(stream->position()));
const char* left_quotation_marks = nullptr;
@@ -1519,6 +1537,8 @@ inline bool JsonbPath::parse_member(Stream* stream,
JsonbPath* path) {
} else if (stream->peek() == DOUBLE_QUOTE) {
if (left_quotation_marks == nullptr) {
left_quotation_marks = stream->position();
+ // Called by function_jsonb.cpp, the variables passed in
originate from a mutable block;
+ // using const_cast is acceptable.
stream->set_leg_ptr(const_cast<char*>(++left_quotation_marks));
continue;
} else {
diff --git a/be/src/util/lru_multi_cache.h b/be/src/util/lru_multi_cache.h
index 509625c8bdb..381385f0af0 100644
--- a/be/src/util/lru_multi_cache.h
+++ b/be/src/util/lru_multi_cache.h
@@ -220,7 +220,7 @@ public:
/// Returns a pointer to the stored key;
/// Returns nullptr if it's an empty accessor;
- KeyType* get_key() const;
+ const KeyType* get_key() const;
/// Explicit release of the object
void release();
diff --git a/be/src/util/lru_multi_cache.inline.h
b/be/src/util/lru_multi_cache.inline.h
index b201d50dd8e..dfd836f1053 100644
--- a/be/src/util/lru_multi_cache.inline.h
+++ b/be/src/util/lru_multi_cache.inline.h
@@ -75,9 +75,9 @@ ValueType* LruMultiCache<KeyType, ValueType>::Accessor::get()
{
}
template <typename KeyType, typename ValueType>
-KeyType* LruMultiCache<KeyType, ValueType>::Accessor::get_key() const {
+const KeyType* LruMultiCache<KeyType, ValueType>::Accessor::get_key() const {
if (_p_value_internal) {
- return const_cast<KeyType*>(&(_p_value_internal->key));
+ return &(_p_value_internal->key);
}
return nullptr;
diff --git a/be/src/util/proto_util.h b/be/src/util/proto_util.h
index ef28c806ae8..d93f2df5aa9 100644
--- a/be/src/util/proto_util.h
+++ b/be/src/util/proto_util.h
@@ -135,16 +135,13 @@ Status request_embed_attachmentv2(Params* brpc_request,
const std::string& data,
// Extract the brpc request and block from the controller attachment,
// and put the block into the request.
template <typename Params>
-Status attachment_extract_request_contain_block(const Params* brpc_request,
- brpc::Controller* cntl) {
- Params* req = const_cast<Params*>(brpc_request);
- auto block = req->mutable_block();
- return attachment_extract_request(req, cntl,
block->mutable_column_values());
+Status attachment_extract_request_contain_block(Params* brpc_request,
brpc::Controller* cntl) {
+ auto block = brpc_request->mutable_block();
+ return attachment_extract_request(brpc_request, cntl,
block->mutable_column_values());
}
template <typename Params>
-Status attachment_extract_request(const Params* brpc_request,
brpc::Controller* cntl,
- std::string* data) {
+Status attachment_extract_request(Params* brpc_request, brpc::Controller*
cntl, std::string* data) {
const butil::IOBuf& io_buf = cntl->request_attachment();
// step1: deserialize request string to brpc_request from attachment.
@@ -152,8 +149,7 @@ Status attachment_extract_request(const Params*
brpc_request, brpc::Controller*
io_buf.copy_to(&req_str_size, sizeof(req_str_size), 0);
std::string req_str;
io_buf.copy_to(&req_str, req_str_size, sizeof(req_str_size));
- Params* req = const_cast<Params*>(brpc_request);
- req->ParseFromString(req_str);
+ brpc_request->ParseFromString(req_str);
// step2: extract data from attachment.
int64_t data_size;
diff --git a/be/src/util/slice.h b/be/src/util/slice.h
index c8b1629b8bd..9c2ff1253f6 100644
--- a/be/src/util/slice.h
+++ b/be/src/util/slice.h
@@ -91,7 +91,7 @@ public:
const char* get_data() const { return data; }
/// @return A mutable pointer to the beginning of the referenced data.
- char* mutable_data() { return const_cast<char*>(data); }
+ char* mutable_data() { return data; }
/// @return The length (in bytes) of the referenced data.
size_t get_size() const { return size; }
diff --git a/be/src/util/url_parser.cpp b/be/src/util/url_parser.cpp
index ee29a4138bf..d8da344c9ec 100644
--- a/be/src/util/url_parser.cpp
+++ b/be/src/util/url_parser.cpp
@@ -28,21 +28,21 @@
namespace doris {
#include "common/compile_check_begin.h"
-const StringRef UrlParser::_s_url_authority(const_cast<char*>("AUTHORITY"), 9);
-const StringRef UrlParser::_s_url_file(const_cast<char*>("FILE"), 4);
-const StringRef UrlParser::_s_url_host(const_cast<char*>("HOST"), 4);
-const StringRef UrlParser::_s_url_path(const_cast<char*>("PATH"), 4);
-const StringRef UrlParser::_s_url_protocol(const_cast<char*>("PROTOCOL"), 8);
-const StringRef UrlParser::_s_url_query(const_cast<char*>("QUERY"), 5);
-const StringRef UrlParser::_s_url_ref(const_cast<char*>("REF"), 3);
-const StringRef UrlParser::_s_url_userinfo(const_cast<char*>("USERINFO"), 8);
-const StringRef UrlParser::_s_url_port(const_cast<char*>("PORT"), 4);
-const StringRef UrlParser::_s_protocol(const_cast<char*>("://"), 3);
-const StringRef UrlParser::_s_at(const_cast<char*>("@"), 1);
-const StringRef UrlParser::_s_slash(const_cast<char*>("/"), 1);
-const StringRef UrlParser::_s_colon(const_cast<char*>(":"), 1);
-const StringRef UrlParser::_s_question(const_cast<char*>("?"), 1);
-const StringRef UrlParser::_s_hash(const_cast<char*>("#"), 1);
+const StringRef UrlParser::_s_url_authority("AUTHORITY", 9);
+const StringRef UrlParser::_s_url_file("FILE", 4);
+const StringRef UrlParser::_s_url_host("HOST", 4);
+const StringRef UrlParser::_s_url_path("PATH", 4);
+const StringRef UrlParser::_s_url_protocol("PROTOCOL", 8);
+const StringRef UrlParser::_s_url_query("QUERY", 5);
+const StringRef UrlParser::_s_url_ref("REF", 3);
+const StringRef UrlParser::_s_url_userinfo("USERINFO", 8);
+const StringRef UrlParser::_s_url_port("PORT", 4);
+const StringRef UrlParser::_s_protocol("://", 3);
+const StringRef UrlParser::_s_at("@", 1);
+const StringRef UrlParser::_s_slash("/", 1);
+const StringRef UrlParser::_s_colon(":", 1);
+const StringRef UrlParser::_s_question("?", 1);
+const StringRef UrlParser::_s_hash("#", 1);
const StringSearch UrlParser::_s_protocol_search(&_s_protocol);
const StringSearch UrlParser::_s_at_search(&_s_at);
const StringSearch UrlParser::_s_slash_search(&_s_slash);
diff --git a/be/src/vec/data_types/serde/data_type_struct_serde.cpp
b/be/src/vec/data_types/serde/data_type_struct_serde.cpp
index c901b608756..18b77fe2367 100644
--- a/be/src/vec/data_types/serde/data_type_struct_serde.cpp
+++ b/be/src/vec/data_types/serde/data_type_struct_serde.cpp
@@ -381,7 +381,7 @@ Status
DataTypeStructSerDe::deserialize_column_from_jsonb(IColumn& column,
for (size_t i = 0; i < elem_names.size(); ++i) {
const auto& field_name = elem_names[i];
- JsonbValue* value = jsonb_object->find(field_name.data(),
(int)field_name.size());
+ const JsonbValue* value = jsonb_object->find(field_name.data(),
(int)field_name.size());
RETURN_IF_ERROR(elem_serdes_ptrs[i]->deserialize_column_from_jsonb(
struct_column.get_column(i), value, castParms));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]