5
5
6
6
#include < boost/functional/hash.hpp>
7
7
8
- #include " homeobject/common .hpp"
8
+ #include " homeobject_impl .hpp"
9
9
10
10
namespace homeobject {
11
11
@@ -19,11 +19,37 @@ struct BlobRoute {
19
19
auto operator <=>(BlobRoute const &) const = default ;
20
20
sisl::blob to_blob () const { return sisl::blob{uintptr_cast (const_cast < BlobRoute* >(this )), sizeof (*this )}; }
21
21
};
22
+
23
+ // used for gc to quickly identify all the blob in the move_to chunk
24
+ struct BlobRouteByChunk {
25
+ // homestore::chunk_num_t == uint16_t
26
+ uint16_t chunk;
27
+ shard_id_t shard;
28
+ blob_id_t blob;
29
+ auto operator <=>(BlobRouteByChunk const &) const = default ;
30
+ sisl::blob to_blob () const {
31
+ return sisl::blob{uintptr_cast (const_cast < BlobRouteByChunk* >(this )), sizeof (*this )};
32
+ }
33
+ };
22
34
#pragma pack()
23
35
24
36
} // namespace homeobject
25
37
26
38
namespace fmt {
39
+ template <>
40
+ struct formatter < homeobject::BlobRouteByChunk > {
41
+ template < typename ParseContext >
42
+ constexpr auto parse (ParseContext& ctx) {
43
+ return ctx.begin ();
44
+ }
45
+
46
+ template < typename FormatContext >
47
+ auto format (homeobject::BlobRouteByChunk const & r, FormatContext& ctx) {
48
+ return format_to (ctx.out (), " {:04x}:{:04x}:{:012x}:{:016x}" , r.chunk , (r.shard >> homeobject::shard_width),
49
+ (r.shard & homeobject::shard_mask), r.blob );
50
+ }
51
+ };
52
+
27
53
template <>
28
54
struct formatter < homeobject::BlobRoute > {
29
55
template < typename ParseContext >
@@ -37,6 +63,7 @@ struct formatter< homeobject::BlobRoute > {
37
63
(r.shard & homeobject::shard_mask), r.blob );
38
64
}
39
65
};
66
+
40
67
} // namespace fmt
41
68
42
69
template <>
@@ -45,3 +72,10 @@ struct std::hash< homeobject::BlobRoute > {
45
72
return boost::hash_value< homeobject::blob_id_t >(std::make_pair (r.shard , r.blob ));
46
73
}
47
74
};
75
+
76
+ template <>
77
+ struct std ::hash< homeobject::BlobRouteByChunk > {
78
+ std::size_t operator ()(homeobject::BlobRouteByChunk const & r) const noexcept {
79
+ return boost::hash_value< homeobject::blob_id_t >(std::make_pair (r.shard , r.blob ));
80
+ }
81
+ };
0 commit comments