Skip to content

Commit

Permalink
[Enhancement] filesystem API for dropping local cache (StarRocks#14594)
Browse files Browse the repository at this point in the history
  • Loading branch information
sduzh authored Dec 5, 2022
1 parent 5f17804 commit 33980f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions be/src/fs/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ class FileSystem {

// Determines the information about the filesystem on which the pathname 'path' is located.
virtual StatusOr<SpaceInfo> space(const std::string& path) { return Status::NotSupported("FileSystem::space()"); }

// Given the path to a remote file, delete the file's cache on the local file system, if any.
// On success, Status::OK is returned. If there is no cache, Status::NotFound is returned.
virtual Status drop_local_cache(const std::string& path) { return Status::NotFound(path); }
};

// Creation-time options for WritableFile
Expand Down
9 changes: 9 additions & 0 deletions be/src/fs/fs_starlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,15 @@ class StarletFileSystem : public FileSystem {
return Status::NotSupported("StarletFileSystem::link_file");
}

Status drop_local_cache(const std::string& path) override {
ASSIGN_OR_RETURN(auto pair, parse_starlet_uri(path));
auto fs_st = get_shard_filesystem(pair.second);
if (!fs_st.ok()) {
return to_status(fs_st.status());
}
return to_status((*fs_st)->drop_cache(pair.first));
}

private:
absl::StatusOr<std::shared_ptr<staros::starlet::fslib::FileSystem>> get_shard_filesystem(int64_t shard_id) {
return g_worker->get_shard_filesystem(shard_id, _conf);
Expand Down

0 comments on commit 33980f8

Please sign in to comment.