Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix restore download failure for the file of GIN #44957

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion be/src/runtime/snapshot_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,10 +756,14 @@ bool SnapshotLoader::_end_with(const std::string& str, const std::string& match)
return false;
}

bool SnapshotLoader::_contains(const std::string& str, const std::string& match) {
return str.find(match) != std::string::npos;
}

bool SnapshotLoader::_is_index_files(const std::string& str) {
return _end_with(str, "fdt") || _end_with(str, "fdx") || _end_with(str, "fnm") || _end_with(str, "frq") ||
_end_with(str, "nrm") || _end_with(str, "prx") || _end_with(str, "tii") || _end_with(str, "tis") ||
_end_with(str, "null_bitmap") || _end_with(str, "segments_2") || _end_with(str, "segments.gen");
_end_with(str, "null_bitmap") || _contains(str, "segments");
trueeyu marked this conversation as resolved.
Show resolved Hide resolved
}

Status SnapshotLoader::_get_tablet_id_and_schema_hash_from_file_path(const std::string& src_path, int64_t* tablet_id,
Expand Down
1 change: 1 addition & 0 deletions be/src/runtime/snapshot_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class SnapshotLoader {
const std::string& new_name);

bool _end_with(const std::string& str, const std::string& match);
bool _contains(const std::string& str, const std::string& match);

bool _is_index_files(const std::string& str);

Expand Down
8 changes: 8 additions & 0 deletions be/test/runtime/snapshot_loader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ TEST_F(SnapshotLoaderTest, NormalCase) {
st = loader._get_tablet_id_from_remote_path("/__tbl_10004/__part_10003/__idx_10004/__10005", &tablet_id);
ASSERT_TRUE(st.ok());
ASSERT_EQ(10005, tablet_id);

ASSERT_TRUE(loader._contains("1234_2_5_12345_1.segments_1", "segments"));
ASSERT_TRUE(loader._contains("1234_2_5_12345_1.segments_2", "segments"));
ASSERT_TRUE(loader._contains("1234_2_5_12345_1.segments_3", "segments"));
ASSERT_TRUE(loader._contains("1234_2_5_12345_1.segments_4", "segments"));
ASSERT_TRUE(loader._contains("1234_2_5_12345_1.segments_5", "segments"));

ASSERT_TRUE(loader._contains("1234_2_5_12345_1.segments.gen", "segments"));
}

} // namespace starrocks
Loading