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

[GLUTEN-3689][CH]use s3 file last modified time as cache update line #3691

Merged
merged 1 commit into from
Nov 14, 2023
Merged
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
21 changes: 6 additions & 15 deletions cpp-ch/local-engine/Storages/SubstraitSource/ReadBufferBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,35 +380,26 @@ class S3FileReadBufferBuilder : public ReadBufferBuilder
std::string bucket = file_uri.getHost();
const auto client = getClient(bucket);
std::string key = file_uri.getPath().substr(1);
size_t object_size = DB::S3::getObjectSize(*client, bucket, key, "");
DB::S3::ObjectInfo object_info = DB::S3::getObjectInfo(*client, bucket, key, "");
size_t object_size = object_info.size;
Int64 object_modified_time = object_info.last_modification_time;

if (new_settings.enable_filesystem_cache)
{
const auto & settings = context->getSettingsRef();
String accept_cache_time_str = getSetting(settings, "", "spark.kylin.local-cache.accept-cache-time");
Int64 accept_cache_time;
if (accept_cache_time_str.empty())
{
accept_cache_time = DateTimeUtil::currentTimeMillis();
}
else
{
accept_cache_time = std::stoll(accept_cache_time_str);
}

auto file_cache_key = DB::FileCacheKey(key);
auto last_cache_time = files_cache_time_map.get(file_cache_key);
// quick check
if (last_cache_time != std::nullopt && last_cache_time.has_value())
{
if (last_cache_time.value() < accept_cache_time)
if (last_cache_time.value() < object_modified_time*1000l) //second to milli second
{
files_cache_time_map.update_cache_time(file_cache_key, key, accept_cache_time, file_cache);
files_cache_time_map.update_cache_time(file_cache_key, key, object_modified_time*1000l, file_cache);
}
}
else
{
files_cache_time_map.update_cache_time(file_cache_key, key, accept_cache_time, file_cache);
files_cache_time_map.update_cache_time(file_cache_key, key, object_modified_time*1000l, file_cache);
}
}

Expand Down
Loading