yangzhg commented on a change in pull request #3641:
URL: https://github.com/apache/incubator-doris/pull/3641#discussion_r427867432



##########
File path: be/src/tools/meta_tool.cpp
##########
@@ -122,13 +126,131 @@ void delete_meta(DataDir* data_dir) {
     std::cout << "delete meta successfully" << std::endl;
 }
 
+Status init_data_dir(const std::string dir, DataDir** ret) {
+    std::string root_path;
+    Status st = FileUtils::canonicalize(dir, &root_path);
+    if (!st.ok()) {
+        std::cout << "invalid root path:" << FLAGS_root_path
+            << ", error: " << st.to_string() << std::endl;
+        return Status::InternalError("invalid root path");
+    }
+    doris::StorePath path;
+    auto res = parse_root_path(root_path, &path);
+    if (res != OLAP_SUCCESS) {
+        std::cout << "parse root path failed:" << root_path << std::endl;
+        return Status::InternalError("parse root path failed");
+    }
+
+    *ret = new (std::nothrow) DataDir(path.path, path.capacity_bytes, 
path.storage_medium);
+    if (*ret == nullptr) {
+        std::cout << "new data dir failed" << std::endl;
+        return Status::InternalError("new data dir failed");
+    }
+    st = (*ret)->init();
+    if (!st.ok()) {
+        std::cout << "data_dir load failed" << std::endl;
+        return Status::InternalError("data_dir load failed");
+    }
+
+    return Status::OK();
+}
+
+void batch_delete_meta(const std::string tablet_file) {
+    // each line in tablet file indicate a tablet to delete, format is:
+    //      data_dir tablet_id schema_hash
+    // eg:
+    //      /data1/palo.HDD 100010 11212389324
+    //      /data2/palo.HDD 100010 23049230234
+    std::ifstream infile(tablet_file);
+    std::string line;
+    int err_num = 0;
+    int delete_num = 0;
+    int total_num = 0;
+    std::unordered_map<std::string, std::unique_ptr<DataDir>> dir_map;
+    while (std::getline(infile, line)) {
+        total_num++;
+        vector<string> v = strings::Split(line, " ");

Review comment:
       I think its better to use ',' as split




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