gavinchou commented on code in PR #40226:
URL: https://github.com/apache/doris/pull/40226#discussion_r1741141223
##########
be/src/io/cache/fs_file_cache_storage.cpp:
##########
@@ -183,29 +209,51 @@ Status FSFileCacheStorage::remove(const FileCacheKey&
key) {
return Status::OK();
}
-Status FSFileCacheStorage::change_key_meta(const FileCacheKey& key, const
KeyMeta& new_meta) {
- // TTL change
- if (key.meta.expiration_time != new_meta.expiration_time) {
+Status FSFileCacheStorage::change_key_meta_type(const FileCacheKey& key, const
FileCacheType type) {
+ // file operation
+ if (key.meta.type != type) {
+ // TTL type file dose not need to change the suffix
+ DCHECK(key.meta.type != FileCacheType::TTL && type !=
FileCacheType::TTL);
+ std::string dir = get_path_in_local_cache(key.hash,
key.meta.expiration_time);
+ std::string original_file = get_path_in_local_cache(dir, key.offset,
key.meta.type);
+ std::string new_file = get_path_in_local_cache(dir, key.offset, type);
+ RETURN_IF_ERROR(fs->rename(original_file, new_file));
+ }
+ return Status::OK();
+}
+
+Status FSFileCacheStorage::change_key_meta_expiration(const FileCacheKey& key,
+ const uint64_t
expiration) {
+ // directory operation
+ if (key.meta.expiration_time != expiration) {
std::string original_dir = get_path_in_local_cache(key.hash,
key.meta.expiration_time);
- std::string new_dir = get_path_in_local_cache(key.hash,
new_meta.expiration_time);
+ std::string new_dir = get_path_in_local_cache(key.hash, expiration);
// It will be concurrent, but we don't care who rename
Status st = fs->rename(original_dir, new_dir);
if (!st.ok() && !st.is<ErrorCode::NOT_FOUND>()) {
return st;
}
- } else if (key.meta.type != new_meta.type) {
- std::string dir = get_path_in_local_cache(key.hash,
key.meta.expiration_time);
- std::string original_file = get_path_in_local_cache(dir, key.offset,
key.meta.type);
- std::string new_file = get_path_in_local_cache(dir, key.offset,
new_meta.type);
- RETURN_IF_ERROR(fs->rename(original_file, new_file));
}
return Status::OK();
}
std::string FSFileCacheStorage::get_path_in_local_cache(const std::string&
dir, size_t offset,
FileCacheType type,
bool is_tmp) {
- return Path(dir) / (std::to_string(offset) +
- (is_tmp ? "_tmp" :
BlockFileCache::cache_type_to_string(type)));
+ if (is_tmp) {
Review Comment:
make "_tmp" a constant, since it is used frequently, and get rid of possible
typo
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]