Skip to content

Commit

Permalink
[BugFix] Fix restore download failure for the file of GIN (backport #…
Browse files Browse the repository at this point in the history
…44957) (#44972)

Co-authored-by: srlch <111035020+srlch@users.noreply.github.com>
  • Loading branch information
mergify[bot] and srlch committed Apr 29, 2024
1 parent e00ace8 commit 49bfec4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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");
}

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

0 comments on commit 49bfec4

Please sign in to comment.