Skip to content

Commit

Permalink
fix issue 3689 (#3691)
Browse files Browse the repository at this point in the history
  • Loading branch information
lhuang09287750 authored Nov 14, 2023
1 parent 0f9f196 commit 6c38a76
Showing 1 changed file with 6 additions and 15 deletions.
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

0 comments on commit 6c38a76

Please sign in to comment.