imay commented on a change in pull request #1610: Add bitmap agg type and udaf
URL: https://github.com/apache/incubator-doris/pull/1610#discussion_r316949798
 
 

 ##########
 File path: be/src/olap/schema.cpp
 ##########
 @@ -37,41 +37,53 @@ void Schema::copy_from(const Schema& other) {
     _col_ids = other._col_ids;
     _col_offsets = other._col_offsets;
     _cols.resize(other._cols.size(), nullptr);
-
     for (auto cid : _col_ids) {
-        _cols[cid] =  new Field(*other._cols[cid]);
+        _cols[cid] =  other._cols[cid]->clone();
     }
 }
 
+void Schema::init_field(const std::vector<TabletColumn>& columns,
+                        const std::vector<ColumnId>& col_ids) {
+    _cols.resize(columns.size(), nullptr);
+    // we must make sure that the offset is the same with RowBlock's
+    std::unordered_set<uint32_t> column_set(col_ids.begin(), col_ids.end());
+    for (int cid = 0; cid < columns.size(); ++cid) {
+        if (column_set.find(cid) == column_set.end()) {
+            continue;
+        }
+        _cols[cid] = FieldFactory::create(columns[cid]);
+    }
+}
 
-void Schema::reset(const std::vector<Field>& cols, size_t num_key_columns) {
-    std::vector<ColumnId> col_ids(cols.size());
-    for (uint32_t cid = 0; cid < cols.size(); ++cid) {
-        col_ids[cid] = cid;
+void Schema::init_field(const std::vector<const Field*>& cols,
+                const std::vector<ColumnId>& col_ids) {
+    _cols.resize(cols.size(), nullptr);
+    // we must make sure that the offset is the same with RowBlock's
+    std::unordered_set<uint32_t> column_set(col_ids.begin(), col_ids.end());
+    for (int cid = 0; cid < cols.size(); ++cid) {
+        if (column_set.find(cid) == column_set.end()) {
+            continue;
+        }
+        _cols[cid] = cols[cid]->clone();
     }
-    reset(cols, col_ids, num_key_columns);
 }
 
-void Schema::reset(const std::vector<Field>& cols,
+void Schema::init(const size_t& field_size,
 
 Review comment:
   Can we use _cols.size() instead of field_size?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to