yiguolei commented on a change in pull request #1930: Replace std::regex with RE2 URL: https://github.com/apache/incubator-doris/pull/1930#discussion_r333375444
########## File path: be/src/olap/tablet_manager.cpp ########## @@ -682,42 +682,19 @@ TabletSharedPtr TabletManager::get_tablet(TTabletId tablet_id, SchemaHash schema return nullptr; } // get_tablet -bool TabletManager::get_tablet_id_and_schema_hash_from_path(const std::string& path, - TTabletId* tablet_id, TSchemaHash* schema_hash) { - std::vector<DataDir*> data_dirs = StorageEngine::instance()->get_stores<true>(); - for (auto data_dir : data_dirs) { - const std::string& data_dir_path = data_dir->path(); - if (path.find(data_dir_path) != std::string::npos) { - std::string pattern = data_dir_path + "/data/\\d+/(\\d+)/?(\\d+)?"; - std::regex rgx (pattern.c_str()); - std::smatch sm; - bool ret = std::regex_search(path, sm, rgx); - if (ret) { - if (sm.size() == 3) { - *tablet_id = std::strtoll(sm.str(1).c_str(), nullptr, 10); - *schema_hash = std::strtoll(sm.str(2).c_str(), nullptr, 10); - return true; - } else { - LOG(WARNING) << "invalid match. match size:" << sm.size(); - return false; - } - } - } - } - return false; +bool TabletManager::get_tablet_id_and_schema_hash_from_path( + const std::string& path, TTabletId* tablet_id, TSchemaHash* schema_hash) { + static re2::LazyRE2 re = {"/data/\\d+/(\\d+)/(\\d+)"}; + return RE2::PartialMatch(path, *re, tablet_id, schema_hash); Review comment: Should check if the path is DORIS's data path. ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org