pool_t pool() const { return _pool; }
- template <KeyT KT>
- static shard_pool_t from_key(const full_key_t<KT>& key);
+ template <IsFullKey Key>
+ static shard_pool_t from_key(const Key& key) {
+ if constexpr (std::same_as<Key, key_view_t>) {
+ return key.shard_pool_packed();
+ } else {
+ return {key.shard(), key.pool()};
+ }
+ }
shard_t shard;
pool_t _pool;
struct crush_t {
auto operator<=>(const crush_t&) const = default;
- template <KeyT KT>
- static crush_t from_key(const full_key_t<KT>& key);
+ template <IsFullKey Key>
+ static crush_t from_key(const Key& key) {
+ if constexpr (std::same_as<Key, key_view_t>) {
+ return key.crush_packed();
+ } else {
+ return {key.crush()};
+ }
+ }
crush_hash_t crush;
} __attribute__((packed));
struct shard_pool_crush_t {
auto operator<=>(const shard_pool_crush_t&) const = default;
- template <KeyT KT>
- static shard_pool_crush_t from_key(const full_key_t<KT>& key);
+ template <IsFullKey Key>
+ static shard_pool_crush_t from_key(const Key& key) {
+ return {shard_pool_t::from_key(key), crush_t::from_key(key)};
+ }
shard_pool_t shard_pool;
crush_t crush;
struct snap_gen_t {
auto operator<=>(const snap_gen_t&) const = default;
- template <KeyT KT>
- static snap_gen_t from_key(const full_key_t<KT>& key);
+ template <IsFullKey Key>
+ static snap_gen_t from_key(const Key& key) {
+ if constexpr (std::same_as<Key, key_view_t>) {
+ return key.snap_gen_packed();
+ } else {
+ return {key.snap(), key.gen()};
+ }
+ }
snap_t snap;
gen_t gen;
return lhs <=> rhs == 0;
}
-template <KeyT KT>
-shard_pool_t shard_pool_t::from_key(const full_key_t<KT>& key) {
- if constexpr (KT == KeyT::VIEW) {
- return key.shard_pool_packed();
- } else {
- return {key.shard(), key.pool()};
- }
-}
-
-template <KeyT KT>
-crush_t crush_t::from_key(const full_key_t<KT>& key) {
- if constexpr (KT == KeyT::VIEW) {
- return key.crush_packed();
- } else {
- return {key.crush()};
- }
-}
-
-template <KeyT KT>
-shard_pool_crush_t shard_pool_crush_t::from_key(const full_key_t<KT>& key) {
- return {shard_pool_t::from_key<KT>(key), crush_t::from_key<KT>(key)};
-}
-
-template <KeyT KT>
-snap_gen_t snap_gen_t::from_key(const full_key_t<KT>& key) {
- if constexpr (KT == KeyT::VIEW) {
- return key.snap_gen_packed();
- } else {
- return {key.snap(), key.gen()};
- }
-}
-
template <KeyT KT>
node_offset_t ns_oid_view_t::estimate_size(const full_key_t<KT>& key) {
if constexpr (KT == KeyT::VIEW) {
node.get_key_start_offset(node.num_keys, node_size);
mut.shift_absolute(p_insert, p_shift_end - p_insert, estimate_insert_one());
mut.copy_in_absolute((void*)&node.num_keys, num_keys_t(node.num_keys + 1));
- append_key(mut, key_t::template from_key<KT>(key), p_insert);
+ append_key(mut, key_t::from_key(key), p_insert);
int new_offset = node.get_item_end_offset(index, node_size) - size_right;
assert(new_offset > 0);
assert(new_offset < (int)node_size);
auto p_insert = const_cast<char*>(p_shift_end) - size;
auto item = internal_sub_item_t{
- snap_gen_t::from_key<KT>(key), laddr_packed_t{value}};
+ snap_gen_t::from_key(key), laddr_packed_t{value}};
mut.copy_in_absolute(p_insert, item);
return &reinterpret_cast<internal_sub_item_t*>(p_insert)->value;
}
{
p_append -= sizeof(internal_sub_item_t);
auto item = internal_sub_item_t{
- snap_gen_t::from_key<KT>(key), laddr_packed_t{value}};
+ snap_gen_t::from_key(key), laddr_packed_t{value}};
p_mut->copy_in_absolute(p_append, item);
p_value = &reinterpret_cast<internal_sub_item_t*>(p_append)->value;
}
auto p_value = reinterpret_cast<value_header_t*>(p_insert);
p_value->initiate(mut, value);
p_insert += value.allocation_size();
- mut.copy_in_absolute(p_insert, snap_gen_t::template from_key<KT>(key));
+ mut.copy_in_absolute(p_insert, snap_gen_t::from_key(key));
assert(p_insert + sizeof(snap_gen_t) + sizeof(node_offset_t) == p_shift_end);
// c. compensate affected offsets
[&] (const kv_item_t& arg) {
assert(pp_value);
p_cur -= sizeof(snap_gen_t);
- p_mut->copy_in_absolute(p_cur, snap_gen_t::template from_key<KT>(*arg.p_key));
+ p_mut->copy_in_absolute(p_cur, snap_gen_t::from_key(*arg.p_key));
p_cur -= arg.value_config.allocation_size();
auto p_value = reinterpret_cast<value_header_t*>(p_cur);
p_value->initiate(*p_mut, arg.value_config);