#pragma once #include #include namespace DB { struct FileCacheKey { using KeyHash = UInt128; KeyHash key; std::string toString() const; FileCacheKey() = default; static FileCacheKey random(); static FileCacheKey fromPath(const std::string & path); static FileCacheKey fromKey(const UInt128 & key); static FileCacheKey fromKeyString(const std::string & key_str); bool operator==(const FileCacheKey & other) const { return key == other.key; } bool operator<(const FileCacheKey & other) const { return key < other.key; } private: explicit FileCacheKey(const UInt128 & key_); }; using FileCacheKeyAndOffset = std::pair; struct FileCacheKeyAndOffsetHash { std::size_t operator()(const FileCacheKeyAndOffset & key) const { return std::hash()(key.first.key) ^ std::hash()(key.second); } }; } namespace std { template <> struct hash { std::size_t operator()(const DB::FileCacheKey & k) const { return hash()(k.key); } }; } template <> struct fmt::formatter : fmt::formatter { template auto format(const DB::FileCacheKey & key, FormatCtx & ctx) const { return fmt::formatter::format(key.toString(), ctx); } };