HappenLee commented on code in PR #32156:
URL: https://github.com/apache/doris/pull/32156#discussion_r1522464198


##########
be/src/exec/tablet_info.cpp:
##########
@@ -610,4 +615,68 @@ Status VOlapTablePartitionParam::add_partitions(
     return Status::OK();
 }
 
+Status VOlapTablePartitionParam::replace_partitions(
+        const std::vector<VOlapTablePartition*>& origin_partitions,
+        const std::vector<TOlapTablePartition>& new_partitions) {
+    // replace partitions
+    std::set<int64_t> origin_ids;
+    for (const auto* part : origin_partitions) {
+        origin_ids.insert(part->id);
+    }
+    for (auto it = _partitions.begin(); it != _partitions.end(); it++) {
+        if (origin_ids.contains((*it)->id)) {
+            it = _partitions.erase(it);
+        }
+    }
+    //TODO: erase old value from map
+
+    for (const auto& t_part : new_partitions) {
+        auto* part = _obj_pool.add(new VOlapTablePartition(&_partition_block));
+        part->id = t_part.id;
+        part->is_mutable = t_part.is_mutable;
+
+        part->num_buckets = t_part.num_buckets;
+        auto num_indexes = _schema->indexes().size();
+        if (t_part.indexes.size() != num_indexes) {
+            return Status::InternalError(
+                    "number of partition's index is not equal with schema's"
+                    ", num_part_indexes={}, num_schema_indexes={}",
+                    t_part.indexes.size(), num_indexes);
+        }
+        part->indexes = t_part.indexes;
+        std::sort(part->indexes.begin(), part->indexes.end(),
+                  [](const OlapTableIndexTablets& lhs, const 
OlapTableIndexTablets& rhs) {
+                      return lhs.index_id < rhs.index_id;
+                  });
+        // check index
+        for (int j = 0; j < num_indexes; ++j) {
+            if (part->indexes[j].index_id != _schema->indexes()[j]->index_id) {
+                std::stringstream ss;

Review Comment:
   do not use `std::stringstream`



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to