yujun777 commented on code in PR #48704:
URL: https://github.com/apache/doris/pull/48704#discussion_r1986751466


##########
fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java:
##########
@@ -1056,11 +1073,103 @@ public void modifyPartitionsProperty(Database db,
         Env.getCurrentEnv().getEditLog().logBatchModifyPartition(info);
     }
 
+    public void setReplicasToDrop(Partition partition,
+                                 ReplicaAllocation oldReplicaAlloc,
+                                 ReplicaAllocation newReplicaAlloc,
+                                 Map<Long, Long> tableBeToReplicaNumMap) {
+        Set<Tag> scaleInTags = getScaleInTags(oldReplicaAlloc, 
newReplicaAlloc);
+        SystemInfoService systemInfoService = Env.getCurrentSystemInfo();
+        List<Long> aliveBes = systemInfoService.getAllBackendIds(true);
+
+        for (Tag tag : scaleInTags) {
+            int replicasToDrop = oldReplicaAlloc.getReplicaNumByTag(tag) - 
newReplicaAlloc.getReplicaNumByTag(tag);
+            if (replicasToDrop <= 0) {
+                return;
+            }
+
+            processReplicasInPartition(partition, tag, replicasToDrop,
+                    tableBeToReplicaNumMap, systemInfoService, 
oldReplicaAlloc, aliveBes);
+        }
+    }
+
+    private void processReplicasInPartition(Partition partition, Tag tag, int 
replicasToDrop,
+                                            Map<Long, Long> 
tableBeToReplicaNumMap, SystemInfoService systemInfoService,
+                                            ReplicaAllocation oldReplicaAlloc,
+                                            List<Long> aliveBes) {
+        for (MaterializedIndex index : 
partition.getMaterializedIndices(MaterializedIndex.IndexExtState.VISIBLE)) {

Review Comment:
   maybe no pass tag in this function is better ? for each tablet collect 
map<tag, list<replica>>, then for each tag, process the list<replica>



-- 
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