yiguolei commented on code in PR #66472:
URL: https://github.com/apache/doris/pull/66472#discussion_r3763265165


##########
be/src/storage/schema.h:
##########
@@ -37,110 +39,181 @@
 
 namespace doris {
 
-// The class is used to represent row's format in memory.  Each row contains
-// multiple columns, some of which are key-columns (the rest are 
value-columns).
-// NOTE: If both key-columns and value-columns exist, then the key-columns
-// must be placed before value-columns.
-//
-// To compare two rows whose schemas are different, but they are from the same 
origin
-// we store all column schema maybe accessed here. And default access through 
column id
-class Schema;
-using SchemaSPtr = std::shared_ptr<const Schema>;
-class Schema {
+class ReadSchema;
+class Block;
+using ReadSchemaSPtr = std::shared_ptr<ReadSchema>;
+class ReadSchema {
 public:
-    // All the columns of one table may exist in the columns param, but 
col_ids is only a subset.
-    Schema(const std::vector<TabletColumnPtr>& columns, const 
std::vector<ColumnId>& col_ids) {
-        size_t num_key_columns = 0;
-        for (int i = 0; i < columns.size(); ++i) {
-            if (columns[i]->is_key()) {
-                ++num_key_columns;
-            }
-            if (columns[i]->name() == DELETE_SIGN) {
-                _delete_sign_idx = i;
-            }
-            if (columns[i]->name() == BeConsts::ROWID_COL ||
-                columns[i]->name().starts_with(BeConsts::GLOBAL_ROWID_COL)) {
-                _rowid_col_idx = i;
-            }
-            if (columns[i]->name() == VERSION_COL) {
-                _version_col_idx = i;
-            }
-            if (columns[i]->name() == BINLOG_TSO_COL) {
-                _tso_col_idx = i;
-            }
-            if (columns[i]->name() == BINLOG_LSN_COL) {
-                _lsn_col_idx = i;
-            }
-            if (columns[i]->name() == BINLOG_OP_COL) {
-                _op_col_idx = i;
-            }
-            if (columns[i]->name() == COMMIT_TSO_COL) {
-                _commit_tso_col_idx = i;
-            }
-        }
-        _init(columns, col_ids, num_key_columns);
-    }
+    using SequenceMap = std::unordered_map<ColumnId, std::vector<ColumnId>>;
 
-    Schema(const Schema&);
-    Schema& operator=(const Schema& other);
+    explicit ReadSchema(std::vector<TabletColumnPtr> columns);
 
-    ~Schema();
+    explicit ReadSchema(const std::vector<TabletColumnPtr>& columns,
+                        const std::vector<ColumnId>& cids);
 
-    static DataTypePtr get_data_type_ptr(const TabletColumn& column);
+    // Initially every column is a caller-visible FE slot. Storage-only columns
+    // may be appended later without changing `num_block_columns()`.
+    explicit ReadSchema(std::vector<TabletColumnPtr> columns, 
std::vector<DataTypePtr> read_types);
 
     static IColumn::MutablePtr get_predicate_column_ptr(const DataTypePtr& 
data_type,
                                                         const ReaderType 
reader_type);
 
-    const std::vector<TabletColumnPtr>& columns() const { return _cols; }
+    const std::vector<TabletColumnPtr>& columns() const { return 
_read_columns; }
 
-    const TabletColumn* column(ColumnId cid) const { return _cols[cid].get(); }
+    DataTypePtr data_type(size_t ordinal) const {
+        DCHECK_LT(ordinal, _read_types.size());
+        return _read_types[ordinal];
+    }
+
+    // Append a storage-only column without extending the caller-visible slot 
prefix.
+    ColumnId append_column(TabletColumnPtr column) {

Review Comment:
   这里得解释why?
   另外,把实现的逻辑都移动到cpp里



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to