dataroaring commented on code in PR #23218:
URL: https://github.com/apache/doris/pull/23218#discussion_r1299379435


##########
be/src/olap/storage_engine.cpp:
##########
@@ -458,33 +458,74 @@ Status StorageEngine::set_cluster_id(int32_t cluster_id) {
 
 std::vector<DataDir*> StorageEngine::get_stores_for_create_tablet(
         TStorageMedium::type storage_medium) {
-    std::vector<DataDir*> stores;
+    struct DirInfo {
+        DataDir* data_dir;
+        int tablet_size;
+        int used_pct_level;
+
+        bool operator<(const DirInfo& other) {
+            if (used_pct_level != other.used_pct_level) {
+                return used_pct_level < other.used_pct_level;
+            }
+            if (tablet_size != other.tablet_size) {
+                return tablet_size < other.tablet_size;
+            }
+            return data_dir->path_hash() < other.data_dir->path_hash();
+        }
+    };
+    std::vector<DirInfo> dir_infos;
+    int next_index = 0;
     {
         std::lock_guard<std::mutex> l(_store_lock);
+        next_index = _store_next_index[storage_medium]++;
+        if (next_index < 0) {
+            next_index = 0;
+            _store_next_index[storage_medium] = 0;

Review Comment:
   index 0 is used twice, this time and the next one.



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