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

yiguolei 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 f664764cefe [refactor](be) rename field id to field unique id (#51383)
f664764cefe is described below

commit f664764cefe0918f5319f93e3bdd7081cda9f061
Author: yiguolei <guo...@selectdb.com>
AuthorDate: Sat May 31 21:50:15 2025 +0800

    [refactor](be) rename field id to field unique id (#51383)
    
    ### What problem does this PR solve?
    
    field id is very ambiguous because column id is different from column
    unique id, so I rename it to unique id to make the code more clear.
---
 be/src/olap/tablet_schema.cpp | 34 +++++++++++++++++-----------------
 be/src/olap/tablet_schema.h   |  2 +-
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/be/src/olap/tablet_schema.cpp b/be/src/olap/tablet_schema.cpp
index 5f355677fdc..cc1fffa4815 100644
--- a/be/src/olap/tablet_schema.cpp
+++ b/be/src/olap/tablet_schema.cpp
@@ -905,7 +905,7 @@ void TabletSchema::append_column(TabletColumn column, 
ColumnType col_type) {
     } else if (UNLIKELY(column.name() == SKIP_BITMAP_COL)) {
         _skip_bitmap_col_idx = _num_columns;
     }
-    _field_id_to_index[column.unique_id()] = _num_columns;
+    _field_uniqueid_to_index[column.unique_id()] = _num_columns;
     _cols.push_back(std::make_shared<TabletColumn>(std::move(column)));
     // The dropped column may have same name with exsiting column, so that
     // not add to name to index map, only for uid to index map
@@ -985,7 +985,7 @@ void TabletSchema::remove_index(int64_t index_id) {
 void TabletSchema::clear_columns() {
     _field_path_to_index.clear();
     _field_name_to_index.clear();
-    _field_id_to_index.clear();
+    _field_uniqueid_to_index.clear();
     _num_columns = 0;
     _num_variant_columns = 0;
     _num_null_columns = 0;
@@ -1012,7 +1012,7 @@ void TabletSchema::init_from_pb(const TabletSchemaPB& 
schema, bool ignore_extrac
     _indexes.clear();
     _col_id_suffix_to_index.clear();
     _field_name_to_index.clear();
-    _field_id_to_index.clear();
+    _field_uniqueid_to_index.clear();
     _cluster_key_uids.clear();
     clear_column_cache_handlers();
     clear_index_cache_handlers();
@@ -1046,7 +1046,7 @@ void TabletSchema::init_from_pb(const TabletSchemaPB& 
schema, bool ignore_extrac
         _cols.emplace_back(std::move(column));
         if (!_cols.back()->is_extracted_column()) {
             _field_name_to_index.emplace(StringRef(_cols.back()->name()), 
_num_columns);
-            _field_id_to_index[_cols.back()->unique_id()] = _num_columns;
+            _field_uniqueid_to_index[_cols.back()->unique_id()] = _num_columns;
         }
         _num_columns++;
     }
@@ -1118,7 +1118,7 @@ void TabletSchema::shawdow_copy_without_columns(const 
TabletSchema& tablet_schem
     *this = tablet_schema;
     _field_path_to_index.clear();
     _field_name_to_index.clear();
-    _field_id_to_index.clear();
+    _field_uniqueid_to_index.clear();
     _num_columns = 0;
     _num_variant_columns = 0;
     _num_null_columns = 0;
@@ -1133,8 +1133,8 @@ void TabletSchema::update_index_info_from(const 
TabletSchema& tablet_schema) {
         if (col->unique_id() < 0) {
             continue;
         }
-        const auto iter = 
tablet_schema._field_id_to_index.find(col->unique_id());
-        if (iter == tablet_schema._field_id_to_index.end()) {
+        const auto iter = 
tablet_schema._field_uniqueid_to_index.find(col->unique_id());
+        if (iter == tablet_schema._field_uniqueid_to_index.end()) {
             continue;
         }
         auto col_idx = iter->second;
@@ -1184,7 +1184,7 @@ void TabletSchema::build_current_tablet_schema(int64_t 
index_id, int32_t version
     _indexes.clear();
     _col_id_suffix_to_index.clear();
     _field_name_to_index.clear();
-    _field_id_to_index.clear();
+    _field_uniqueid_to_index.clear();
     _delete_sign_idx = -1;
     _sequence_col_idx = -1;
     _version_col_idx = -1;
@@ -1218,7 +1218,7 @@ void TabletSchema::build_current_tablet_schema(int64_t 
index_id, int32_t version
         }
         _cols.emplace_back(std::make_shared<TabletColumn>(*column));
         _field_name_to_index.emplace(StringRef(_cols.back()->name()), 
_num_columns);
-        _field_id_to_index[_cols.back()->unique_id()] = _num_columns;
+        _field_uniqueid_to_index[_cols.back()->unique_id()] = _num_columns;
         _num_columns++;
     }
 
@@ -1246,7 +1246,7 @@ void TabletSchema::merge_dropped_columns(const 
TabletSchema& src_schema) {
         return;
     }
     for (const auto& src_col : src_schema.columns()) {
-        if (_field_id_to_index.find(src_col->unique_id()) == 
_field_id_to_index.end()) {
+        if (_field_uniqueid_to_index.find(src_col->unique_id()) == 
_field_uniqueid_to_index.end()) {
             CHECK(!src_col->is_key())
                     << src_col->name() << " is key column, should not be 
dropped.";
             ColumnPB src_col_pb;
@@ -1267,10 +1267,10 @@ TabletSchemaSPtr 
TabletSchema::copy_without_variant_extracted_columns() {
     return copy;
 }
 
-// Dropped column is in _field_id_to_index but not in _field_name_to_index
+// Dropped column is in _field_uniqueid_to_index but not in 
_field_name_to_index
 // Could refer to append_column method
 bool TabletSchema::is_dropped_column(const TabletColumn& col) const {
-    CHECK(_field_id_to_index.find(col.unique_id()) != _field_id_to_index.end())
+    CHECK(_field_uniqueid_to_index.find(col.unique_id()) != 
_field_uniqueid_to_index.end())
             << "could not find col with unique id = " << col.unique_id()
             << " and name = " << col.name() << " table_id=" << _table_id;
     auto it = _field_name_to_index.find(StringRef {col.name()});
@@ -1366,8 +1366,8 @@ int32_t TabletSchema::field_index(const 
vectorized::PathInData& path) const {
 }
 
 int32_t TabletSchema::field_index(int32_t col_unique_id) const {
-    const auto& found = _field_id_to_index.find(col_unique_id);
-    return (found == _field_id_to_index.end()) ? -1 : found->second;
+    const auto& found = _field_uniqueid_to_index.find(col_unique_id);
+    return (found == _field_uniqueid_to_index.end()) ? -1 : found->second;
 }
 
 const std::vector<TabletColumnPtr>& TabletSchema::columns() const {
@@ -1390,11 +1390,11 @@ const TabletColumn& 
TabletColumn::sparse_column_at(size_t ordinal) const {
 }
 
 const TabletColumn& TabletSchema::column_by_uid(int32_t col_unique_id) const {
-    return *_cols.at(_field_id_to_index.at(col_unique_id));
+    return *_cols.at(_field_uniqueid_to_index.at(col_unique_id));
 }
 
 TabletColumn& TabletSchema::mutable_column_by_uid(int32_t col_unique_id) {
-    return *_cols.at(_field_id_to_index.at(col_unique_id));
+    return *_cols.at(_field_uniqueid_to_index.at(col_unique_id));
 }
 
 TabletColumn& TabletSchema::mutable_column(size_t ordinal) {
@@ -1425,7 +1425,7 @@ bool TabletSchema::exist_column(const std::string& 
field_name) const {
 }
 
 bool TabletSchema::has_column_unique_id(int32_t col_unique_id) const {
-    return _field_id_to_index.contains(col_unique_id);
+    return _field_uniqueid_to_index.contains(col_unique_id);
 }
 
 Status TabletSchema::have_column(const std::string& field_name) const {
diff --git a/be/src/olap/tablet_schema.h b/be/src/olap/tablet_schema.h
index d7d7f041db1..c18b3a7e333 100644
--- a/be/src/olap/tablet_schema.h
+++ b/be/src/olap/tablet_schema.h
@@ -566,7 +566,7 @@ private:
     std::vector<TabletIndexPtr> _indexes;
     std::vector<Cache::Handle*> _index_cache_handlers;
     std::unordered_map<StringRef, int32_t, StringRefHash> _field_name_to_index;
-    std::unordered_map<int32_t, int32_t> _field_id_to_index;
+    std::unordered_map<int32_t, int32_t> _field_uniqueid_to_index;
     std::unordered_map<vectorized::PathInDataRef, int32_t, 
vectorized::PathInDataRef::Hash>
             _field_path_to_index;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to