blob: e788cd5e7cdc865781865b2c49d9c28b64ed642a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#pragma once
#include <Core/Types.h>
#include <fmt/format.h>
namespace DB
{
struct FileCacheKey
{
using KeyHash = UInt128;
KeyHash key;
std::string toString() const;
FileCacheKey() = default;
explicit FileCacheKey(const std::string & path);
explicit FileCacheKey(const UInt128 & key_);
static FileCacheKey random();
bool operator==(const FileCacheKey & other) const { return key == other.key; }
static FileCacheKey fromKeyString(const std::string & key_str);
};
using FileCacheKeyAndOffset = std::pair<FileCacheKey, size_t>;
struct FileCacheKeyAndOffsetHash
{
std::size_t operator()(const FileCacheKeyAndOffset & key) const
{
return std::hash<UInt128>()(key.first.key) ^ std::hash<UInt64>()(key.second);
}
};
}
namespace std
{
template <>
struct hash<DB::FileCacheKey>
{
std::size_t operator()(const DB::FileCacheKey & k) const { return hash<UInt128>()(k.key); }
};
}
template <>
struct fmt::formatter<DB::FileCacheKey> : fmt::formatter<std::string>
{
template <typename FormatCtx>
auto format(const DB::FileCacheKey & key, FormatCtx & ctx) const
{
return fmt::formatter<std::string>::format(key.toString(), ctx);
}
};
|