airborne12 commented on code in PR #51591:
URL: https://github.com/apache/doris/pull/51591#discussion_r2153561552


##########
cloud/src/recycler/checker.cpp:
##########
@@ -737,8 +798,77 @@ int InstanceChecker::do_inverted_check() {
 
         return 0;
     };
+    auto check_inverted_index_file = [&](const std::string& obj_key) {
+        std::vector<std::string> str;
+        butil::SplitString(obj_key, '/', &str);
+        // data/{tablet_id}/{rowset_id}_{seg_num}_{idx_id}{idx_suffix}.idx
+        if (str.size() < 3) {
+            return -1;
+        }
 
-    // TODO(Xiaocc): Currently we haven't implemented one generator-like s3 
accessor list function
+        int64_t tablet_id = atol(str[1].c_str());
+        if (tablet_id <= 0) {
+            LOG(WARNING) << "failed to parse tablet_id, key=" << obj_key;
+            return -1;
+        }
+
+        if (!str.back().ends_with(".idx")) {
+            return 0; // Not an index file
+        }
+
+        int64_t index_id;
+
+        if (auto pos = str.back().find_last_of('_'); pos != std::string::npos) 
{
+            index_id = atol(str.back().substr(pos + 1, str.back().size() - 
4).c_str());

Review Comment:
   we need more robust code check for wrong format idx like xxx_aaa.idx_
   ```
   size_t pos = last_str.find_last_of('_');
       if (pos == std::string::npos || pos + 1 >= last_str.size() - 4) {
           LOG(WARNING) << "Invalid index_id format, key=" << obj_key;
           return -1;
       }
   ```
       



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