This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 46e0848404c [fix](be) Fix some implicit casting (#53524)
46e0848404c is described below

commit 46e0848404ceaeac9d715e2fe74e539e357d6215
Author: walter <[email protected]>
AuthorDate: Mon Jul 21 20:20:10 2025 +0800

    [fix](be) Fix some implicit casting (#53524)
---
 be/src/http/action/snapshot_action.cpp             |  4 +++-
 be/src/olap/data_dir.h                             |  6 +++---
 be/src/olap/row_cursor.cpp                         |  5 +++--
 be/src/olap/tablet_schema.cpp                      |  8 ++++----
 be/src/olap/tablet_schema.h                        | 21 ++++++++++++---------
 be/src/olap/task/engine_storage_migration_task.cpp | 14 ++++++++------
 be/src/olap/task/engine_storage_migration_task.h   |  6 +++---
 be/src/olap/version_graph.cpp                      | 18 +++++++++++++-----
 be/src/vec/common/schema_util.cpp                  |  2 +-
 9 files changed, 50 insertions(+), 34 deletions(-)

diff --git a/be/src/http/action/snapshot_action.cpp 
b/be/src/http/action/snapshot_action.cpp
index bd95ed160f4..b5cecac01ab 100644
--- a/be/src/http/action/snapshot_action.cpp
+++ b/be/src/http/action/snapshot_action.cpp
@@ -33,6 +33,7 @@
 #include "olap/storage_engine.h"
 
 namespace doris {
+#include "common/compile_check_begin.h"
 
 const std::string TABLET_ID = "tablet_id";
 const std::string SCHEMA_HASH = "schema_hash";
@@ -69,7 +70,7 @@ void SnapshotAction::handle(HttpRequest* req) {
     int32_t schema_hash;
     try {
         tablet_id = boost::lexical_cast<int64_t>(tablet_id_str);
-        schema_hash = boost::lexical_cast<int64_t>(schema_hash_str);
+        schema_hash = boost::lexical_cast<int32_t>(schema_hash_str);
     } catch (boost::bad_lexical_cast& e) {
         std::string error_msg = std::string("param format is invalid: ") + 
std::string(e.what());
         HttpChannel::send_reply(req, HttpStatus::BAD_REQUEST, error_msg);
@@ -114,4 +115,5 @@ int64_t SnapshotAction::_make_snapshot(int64_t tablet_id, 
int32_t schema_hash,
     return 0L;
 }
 
+#include "common/compile_check_end.h"
 } // end namespace doris
diff --git a/be/src/olap/data_dir.h b/be/src/olap/data_dir.h
index cfef9644373..a306cf38e57 100644
--- a/be/src/olap/data_dir.h
+++ b/be/src/olap/data_dir.h
@@ -81,7 +81,7 @@ public:
     Status set_cluster_id(int32_t cluster_id);
     void health_check();
 
-    uint64_t get_shard() {
+    int32_t get_shard() {
         return _current_shard.fetch_add(1, std::memory_order_relaxed) % 
MAX_SHARD_NUM;
     }
 
@@ -184,8 +184,8 @@ private:
     // This flag will be set true if this store was not in root path when 
reloading
     bool _to_be_deleted;
 
-    static constexpr uint64_t MAX_SHARD_NUM = 1024;
-    std::atomic<uint64_t> _current_shard {0};
+    static constexpr int32_t MAX_SHARD_NUM = 1024;
+    std::atomic<int32_t> _current_shard {0};
     // used to protect and _tablet_set
     mutable std::mutex _mutex;
     std::set<TabletInfo> _tablet_set;
diff --git a/be/src/olap/row_cursor.cpp b/be/src/olap/row_cursor.cpp
index bf3ae2c5219..799093ea842 100644
--- a/be/src/olap/row_cursor.cpp
+++ b/be/src/olap/row_cursor.cpp
@@ -97,7 +97,8 @@ Status RowCursor::_init_scan_key(TabletSchemaSPtr schema,
             _variable_len += scan_keys[cid].length();
         } else if (type == FieldType::OLAP_FIELD_TYPE_CHAR ||
                    type == FieldType::OLAP_FIELD_TYPE_ARRAY) {
-            _variable_len += std::max(scan_keys[cid].length(), 
column.length());
+            _variable_len +=
+                    std::max(scan_keys[cid].length(), 
static_cast<size_t>(column.length()));
         } else if (type == FieldType::OLAP_FIELD_TYPE_STRING) {
             ++_string_field_count;
         }
@@ -120,7 +121,7 @@ Status RowCursor::_init_scan_key(TabletSchemaSPtr schema,
         } else if (type == FieldType::OLAP_FIELD_TYPE_CHAR) {
             Slice* slice = reinterpret_cast<Slice*>(fixed_ptr + 1);
             slice->data = variable_ptr;
-            slice->size = std::max(scan_keys[cid].length(), column.length());
+            slice->size = std::max(scan_keys[cid].length(), 
static_cast<size_t>(column.length()));
             variable_ptr += slice->size;
         } else if (type == FieldType::OLAP_FIELD_TYPE_STRING) {
             _schema->mutable_column(cid)->set_long_text_buf(long_text_ptr);
diff --git a/be/src/olap/tablet_schema.cpp b/be/src/olap/tablet_schema.cpp
index 2692adfcde6..7c1db24659a 100644
--- a/be/src/olap/tablet_schema.cpp
+++ b/be/src/olap/tablet_schema.cpp
@@ -583,7 +583,7 @@ void TabletColumn::init_from_pb(const ColumnPB& column) {
                          << column.children_columns_size();
         }
     }
-    for (size_t i = 0; i < column.children_columns_size(); i++) {
+    for (int i = 0; i < column.children_columns_size(); i++) {
         TabletColumn child_column;
         child_column.init_from_pb(column.children_columns(i));
         add_sub_column(child_column);
@@ -598,9 +598,9 @@ void TabletColumn::init_from_pb(const ColumnPB& column) {
         _column_path = 
std::make_shared<vectorized::PathInData>(_col_name_lower_case);
     }
     for (const auto& column_pb : column.sparse_columns()) {
-        TabletColumn column;
-        column.init_from_pb(column_pb);
-        
_sparse_cols.emplace_back(std::make_shared<TabletColumn>(std::move(column)));
+        TabletColumn new_column;
+        new_column.init_from_pb(column_pb);
+        
_sparse_cols.emplace_back(std::make_shared<TabletColumn>(std::move(new_column)));
         _num_sparse_columns++;
     }
 }
diff --git a/be/src/olap/tablet_schema.h b/be/src/olap/tablet_schema.h
index dfe8556b9a4..52202080125 100644
--- a/be/src/olap/tablet_schema.h
+++ b/be/src/olap/tablet_schema.h
@@ -56,6 +56,8 @@ class PathInData;
 class IDataType;
 } // namespace vectorized
 
+#include "common/compile_check_begin.h"
+
 struct OlapTableIndexSchema;
 class TColumn;
 class TOlapTableIndex;
@@ -113,14 +115,14 @@ public:
                                                            int32_t 
parent_unique_id);
     bool has_default_value() const { return _has_default_value; }
     std::string default_value() const { return _default_value; }
-    size_t length() const { return _length; }
-    void set_length(size_t length) { _length = length; }
+    int32_t length() const { return _length; }
+    void set_length(int32_t length) { _length = length; }
     void set_default_value(const std::string& default_value) {
         _default_value = default_value;
         _has_default_value = true;
     }
-    size_t index_length() const { return _index_length; }
-    void set_index_length(size_t index_length) { _index_length = index_length; 
}
+    int32_t index_length() const { return _index_length; }
+    void set_index_length(int32_t index_length) { _index_length = 
index_length; }
     void set_is_key(bool is_key) { _is_key = is_key; }
     void set_is_nullable(bool is_nullable) { _is_nullable = is_nullable; }
     void set_is_auto_increment(bool is_auto_increment) { _is_auto_increment = 
is_auto_increment; }
@@ -305,12 +307,12 @@ using TabletIndexPtr = std::shared_ptr<TabletIndex>;
 
 class TabletSchema : public MetadataAdder<TabletSchema> {
 public:
-    enum ColumnType { NORMAL = 0, DROPPED = 1, VARIANT = 2 };
+    enum class ColumnType { NORMAL = 0, DROPPED = 1, VARIANT = 2 };
     // TODO(yingchun): better to make constructor as private to avoid
     // manually init members incorrectly, and define a new function like
     // void create_from_pb(const TabletSchemaPB& schema, TabletSchema* 
tablet_schema).
     TabletSchema();
-    virtual ~TabletSchema();
+    ~TabletSchema() override;
 
     // Init from pb
     // ignore_extracted_columns: ignore the extracted columns from variant 
column
@@ -580,13 +582,13 @@ private:
     using IndexKey = std::tuple<IndexType, int32_t, std::string>;
     struct IndexKeyHash {
         size_t operator()(const IndexKey& t) const {
-            std::size_t seed = 0;
+            uint32_t seed = 0;
             seed = doris::HashUtil::hash((const char*)&std::get<0>(t), 
sizeof(std::get<0>(t)),
                                          seed);
             seed = doris::HashUtil::hash((const char*)&std::get<1>(t), 
sizeof(std::get<1>(t)),
                                          seed);
-            seed = doris::HashUtil::hash((const char*)std::get<2>(t).c_str(), 
std::get<2>(t).size(),
-                                         seed);
+            seed = doris::HashUtil::hash((const char*)std::get<2>(t).c_str(),
+                                         
static_cast<uint32_t>(std::get<2>(t).size()), seed);
             return seed;
         }
     };
@@ -634,4 +636,5 @@ bool operator!=(const TabletSchema& a, const TabletSchema& 
b);
 
 using TabletSchemaSPtr = std::shared_ptr<TabletSchema>;
 
+#include "common/compile_check_end.h"
 } // namespace doris
diff --git a/be/src/olap/task/engine_storage_migration_task.cpp 
b/be/src/olap/task/engine_storage_migration_task.cpp
index 7694212e889..435236108ea 100644
--- a/be/src/olap/task/engine_storage_migration_task.cpp
+++ b/be/src/olap/task/engine_storage_migration_task.cpp
@@ -46,6 +46,7 @@
 #include "util/uid_util.h"
 
 namespace doris {
+#include "common/compile_check_begin.h"
 
 using std::stringstream;
 
@@ -63,7 +64,7 @@ Status EngineStorageMigrationTask::execute() {
     return _migrate();
 }
 
-Status EngineStorageMigrationTask::_get_versions(int32_t start_version, 
int32_t* end_version,
+Status EngineStorageMigrationTask::_get_versions(int64_t start_version, 
int64_t* end_version,
                                                  std::vector<RowsetSharedPtr>* 
consistent_rowsets) {
     std::shared_lock rdlock(_tablet->get_header_lock());
     // check if tablet is in cooldown, we don't support migration in this case
@@ -143,7 +144,7 @@ Status 
EngineStorageMigrationTask::_check_running_txns_until_timeout(
 }
 
 Status EngineStorageMigrationTask::_gen_and_write_header_to_hdr_file(
-        uint64_t shard, const std::string& full_path,
+        int32_t shard, const std::string& full_path,
         const std::vector<RowsetSharedPtr>& consistent_rowsets, int64_t 
end_version) {
     // need hold migration lock and push lock outside
     int64_t tablet_id = _tablet->tablet_id();
@@ -210,8 +211,8 @@ Status EngineStorageMigrationTask::_migrate() {
     }};
 
     DorisMetrics::instance()->storage_migrate_requests_total->increment(1);
-    int32_t start_version = 0;
-    int32_t end_version = 0;
+    int64_t start_version = 0;
+    int64_t end_version = 0;
     std::vector<RowsetSharedPtr> consistent_rowsets;
 
     // During migration, if the rowsets being migrated undergoes a compaction 
operation,
@@ -229,7 +230,7 @@ Status EngineStorageMigrationTask::_migrate() {
 
     // try hold migration lock first
     Status res;
-    uint64_t shard = 0;
+    int32_t shard = 0;
     std::string full_path;
     {
         std::unique_lock<std::shared_timed_mutex> 
migration_wlock(_tablet->get_migration_lock(),
@@ -343,7 +344,7 @@ Status EngineStorageMigrationTask::_migrate() {
 
 // TODO(ygl): lost some information here, such as cumulative layer point
 void EngineStorageMigrationTask::_generate_new_header(
-        uint64_t new_shard, const std::vector<RowsetSharedPtr>& 
consistent_rowsets,
+        int32_t new_shard, const std::vector<RowsetSharedPtr>& 
consistent_rowsets,
         TabletMetaSharedPtr new_tablet_meta, int64_t end_version) {
     _tablet->generate_tablet_meta_copy_unlocked(*new_tablet_meta);
 
@@ -450,4 +451,5 @@ Status 
EngineStorageMigrationTask::_copy_index_and_data_files(
     return Status::OK();
 }
 
+#include "common/compile_check_end.h"
 } // namespace doris
diff --git a/be/src/olap/task/engine_storage_migration_task.h 
b/be/src/olap/task/engine_storage_migration_task.h
index 7578b7de94f..3cb54e59a7a 100644
--- a/be/src/olap/task/engine_storage_migration_task.h
+++ b/be/src/olap/task/engine_storage_migration_task.h
@@ -47,7 +47,7 @@ private:
     Status _migrate();
     // check if task is timeout
     bool _is_timeout();
-    Status _get_versions(int32_t start_version, int32_t* end_version,
+    Status _get_versions(int64_t start_version, int64_t* end_version,
                          std::vector<RowsetSharedPtr>* consistent_rowsets);
     Status _check_running_txns();
     // caller should not hold migration lock, and 'migration_wlock' should not 
be nullptr
@@ -59,12 +59,12 @@ private:
     bool _is_rowsets_size_less_than_threshold(
             const std::vector<RowsetSharedPtr>& consistent_rowsets);
 
-    Status _gen_and_write_header_to_hdr_file(uint64_t shard, const 
std::string& full_path,
+    Status _gen_and_write_header_to_hdr_file(int32_t shard, const std::string& 
full_path,
                                              const 
std::vector<RowsetSharedPtr>& consistent_rowsets,
                                              int64_t end_version);
     Status _reload_tablet(const std::string& full_path);
 
-    void _generate_new_header(uint64_t new_shard,
+    void _generate_new_header(int32_t new_shard,
                               const std::vector<RowsetSharedPtr>& 
consistent_rowsets,
                               TabletMetaSharedPtr new_tablet_meta, int64_t 
end_version);
 
diff --git a/be/src/olap/version_graph.cpp b/be/src/olap/version_graph.cpp
index 010e7ce9fd8..1a888161fd2 100644
--- a/be/src/olap/version_graph.cpp
+++ b/be/src/olap/version_graph.cpp
@@ -31,6 +31,8 @@
 #include "common/logging.h"
 
 namespace doris {
+#include "common/compile_check_begin.h"
+
 using namespace ErrorCode;
 
 void TimestampedVersionTracker::_construct_versioned_tracker(
@@ -86,7 +88,7 @@ void TimestampedVersionTracker::_init_stale_version_path_map(
         int64_t a_diff = a->version().second - a->version().first;
         int64_t b_diff = b->version().second - b->version().first;
 
-        int diff = a_diff - b_diff;
+        int64_t diff = a_diff - b_diff;
         if (diff < 0) {
             return true;
         } else if (diff > 0) {
@@ -231,7 +233,9 @@ void 
TimestampedVersionTracker::get_stale_version_path_json_doc(rapidjson::Docum
         // Add `path_id` to item.
         auto path_id_str = std::to_string(path_id);
         rapidjson::Value path_id_value;
-        path_id_value.SetString(path_id_str.c_str(), path_id_str.length(), 
path_arr.GetAllocator());
+        path_id_value.SetString(path_id_str.c_str(),
+                                
static_cast<rapidjson::SizeType>(path_id_str.length()),
+                                path_arr.GetAllocator());
         item.AddMember("path id", path_id_value, path_arr.GetAllocator());
 
         // Add max create time to item.
@@ -241,7 +245,8 @@ void 
TimestampedVersionTracker::get_stale_version_path_json_doc(rapidjson::Docum
         auto create_time_str = cctz::format("%Y-%m-%d %H:%M:%S %z", tp, 
time_zone);
 
         rapidjson::Value create_time_value;
-        create_time_value.SetString(create_time_str.c_str(), 
create_time_str.length(),
+        create_time_value.SetString(create_time_str.c_str(),
+                                    
static_cast<rapidjson::SizeType>(create_time_str.length()),
                                     path_arr.GetAllocator());
         item.AddMember("last create time", create_time_value, 
path_arr.GetAllocator());
 
@@ -261,7 +266,9 @@ void 
TimestampedVersionTracker::get_stale_version_path_json_doc(rapidjson::Docum
         }
         std::string path_list = path_list_stream.str();
         rapidjson::Value path_list_value;
-        path_list_value.SetString(path_list.c_str(), path_list.length(), 
path_arr.GetAllocator());
+        path_list_value.SetString(path_list.c_str(),
+                                  
static_cast<rapidjson::SizeType>(path_list.length()),
+                                  path_arr.GetAllocator());
         item.AddMember("path list", path_list_value, path_arr.GetAllocator());
 
         // Add item to `path_arr`.
@@ -637,7 +644,8 @@ double VersionGraph::get_orphan_vertex_ratio() {
             ++orphan_vertex_num;
         }
     }
-    return orphan_vertex_num / (double)vertex_num;
+    return static_cast<double>(orphan_vertex_num) / 
static_cast<double>(vertex_num);
 }
 
+#include "common/compile_check_end.h"
 } // namespace doris
diff --git a/be/src/vec/common/schema_util.cpp 
b/be/src/vec/common/schema_util.cpp
index ef245665968..51be756cf94 100644
--- a/be/src/vec/common/schema_util.cpp
+++ b/be/src/vec/common/schema_util.cpp
@@ -224,7 +224,7 @@ void get_column_by_type(const vectorized::DataTypePtr& 
data_type, const std::str
     if (is_int_or_bool(data_type->get_primitive_type()) ||
         is_string_type(data_type->get_primitive_type()) ||
         is_float_or_double(data_type->get_primitive_type())) {
-        column.set_length(data_type->get_size_of_value_in_memory());
+        
column.set_length(cast_set<int32_t>(data_type->get_size_of_value_in_memory()));
         return;
     }
     // TODO handle more types like struct/date/datetime/decimal...


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to