pairinteraction
A Rydberg Interaction Calculator
ParquetManager.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Pairinteraction Developers
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#pragma once
5
6#include <filesystem>
7#include <regex>
8#include <shared_mutex>
9#include <string>
10#include <unordered_map>
11#include <vector>
12
13namespace duckdb {
14class Connection;
15} // namespace duckdb
16
17namespace pairinteraction {
18
19class GitHubDownloader;
20
22public:
23 struct PathInfo {
24 std::string path;
25 bool cached = false;
26 };
27
29 int version_minor = -1;
30 std::unordered_map<std::string, PathInfo> paths;
31 };
32
34 int version_minor = -1;
35 std::string endpoint;
36 };
37
38 ParquetManager(std::filesystem::path directory, const GitHubDownloader &downloader,
39 std::vector<std::string> repo_paths, duckdb::Connection &con, bool use_cache);
40 void scan_local();
41 void scan_remote();
42 std::string get_path(const std::string &key, const std::string &table);
43 std::string get_versions_info() const;
44
45private:
46 void react_on_rate_limit_reached(std::time_t reset_time);
47 void update_local_asset(const std::string &key);
48 void cache_table(std::unordered_map<std::string, PathInfo>::iterator table_it);
49
50 std::filesystem::path directory_;
51 const GitHubDownloader &downloader;
52 std::vector<std::string> repo_paths_;
53 duckdb::Connection &con;
54 bool use_cache_;
55 std::unordered_map<std::string, LocalAssetInfo> local_asset_info;
56 std::unordered_map<std::string, RemoteAssetInfo> remote_asset_info;
57 std::regex local_regex{R"(^(\w+)_v(\d+)\.(\d+)$)"};
58 std::regex remote_regex{R"(^(\w+)_v(\d+)\.(\d+)\.zip$)"};
59 std::shared_mutex mtx_local;
60};
61
62} // namespace pairinteraction
ParquetManager(std::filesystem::path directory, const GitHubDownloader &downloader, std::vector< std::string > repo_paths, duckdb::Connection &con, bool use_cache)
std::string get_versions_info() const
std::string get_path(const std::string &key, const std::string &table)
std::unordered_map< std::string, PathInfo > paths