Skip to content

[WIP] HTTPMetadataCache should also store OpenFileExtendedInfo #64

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion extension/httpfs/httpfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ HTTPFileHandle::HTTPFileHandle(FileSystem &fs, const OpenFileInfo &file, FileOpe
auto &info = file.extended_info->options;
auto lm_entry = info.find("last_modified");
if (lm_entry != info.end()) {
last_modified = 0; // keep clang-tidy happy
TimestampToTimeT(lm_entry->second.GetValue<timestamp_t>(), last_modified);
}
auto etag_entry = info.find("etag");
Expand All @@ -301,6 +302,8 @@ HTTPFileHandle::HTTPFileHandle(FileSystem &fs, const OpenFileInfo &file, FileOpe
// skip head request
initialized = true;
}
// copy the rest of the extended info
extended_info = file.extended_info;
}
}
unique_ptr<HTTPFileHandle> HTTPFileSystem::CreateHandle(const OpenFileInfo &file, FileOpenFlags flags,
Expand Down Expand Up @@ -672,6 +675,8 @@ void HTTPFileHandle::Initialize(optional_ptr<FileOpener> opener) {
last_modified = value.last_modified;
length = value.length;
etag = value.etag;
extended_info = value.extended_info;


if (flags.OpenForReading()) {
read_buffer = duckdb::unique_ptr<data_t[]>(new data_t[READ_BUFFER_LEN]);
Expand All @@ -689,7 +694,7 @@ void HTTPFileHandle::Initialize(optional_ptr<FileOpener> opener) {
FullDownload(hfs, should_write_cache);
}
if (should_write_cache) {
current_cache->Insert(path, {length, last_modified, etag});
current_cache->Insert(path, {length, last_modified, etag, extended_info});
}

// Initialize the read buffer now that we know the file exists
Expand Down
1 change: 1 addition & 0 deletions extension/httpfs/include/http_metadata_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct HTTPMetadataCacheEntry {
idx_t length;
time_t last_modified;
string etag;
shared_ptr<ExtendedOpenFileInfo> extended_info;
};

// Simple cache with a max age for an entry to be valid
Expand Down
1 change: 1 addition & 0 deletions extension/httpfs/include/httpfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class HTTPFileHandle : public FileHandle {
idx_t length;
time_t last_modified;
string etag;
shared_ptr<ExtendedOpenFileInfo> extended_info;
bool initialized = false;

// When using full file download, the full file will be written to a cached file handle
Expand Down
Loading