2022-12-19 14:37:51 +00:00
|
|
|
[info]
|
2023-05-23 22:26:38 +01:00
|
|
|
type_name = "folly::F14NodeMap"
|
|
|
|
stub_template_params = [2,3,4]
|
2022-12-19 14:37:51 +00:00
|
|
|
ctype = "F14_MAP"
|
|
|
|
header = "folly/container/F14Map.h"
|
2023-05-23 22:26:38 +01:00
|
|
|
|
|
|
|
# Old:
|
|
|
|
typeName = "folly::F14NodeMap<"
|
2022-12-19 14:37:51 +00:00
|
|
|
ns = ["folly::F14NodeMap"]
|
2023-05-23 22:26:38 +01:00
|
|
|
numTemplateParams = 2
|
2022-12-19 14:37:51 +00:00
|
|
|
replaceTemplateParamIndex = [2, 3]
|
|
|
|
allocatorIndex = 4
|
|
|
|
|
|
|
|
[codegen]
|
|
|
|
decl = """
|
|
|
|
template <typename Key, typename Mapped, typename Hasher, typename KeyEqual, typename Alloc>
|
|
|
|
void getSizeType(const %1%<Key, Mapped, Hasher, KeyEqual, Alloc> &container, size_t& dataSegOffset);
|
|
|
|
"""
|
|
|
|
|
|
|
|
func = """
|
|
|
|
template <typename Key, typename Mapped, typename Hasher, typename KeyEqual, typename Alloc>
|
|
|
|
void getSizeType(const %1%<Key, Mapped, Hasher, KeyEqual, Alloc> &container, size_t& returnArg)
|
|
|
|
{
|
|
|
|
size_t memorySize = container.getAllocatedMemorySize();
|
|
|
|
SAVE_SIZE(sizeof(%1%<Key, Mapped, Hasher, KeyEqual>) + memorySize);
|
|
|
|
|
|
|
|
SAVE_DATA(memorySize);
|
|
|
|
SAVE_DATA(container.bucket_count());
|
|
|
|
SAVE_DATA(container.size());
|
|
|
|
|
|
|
|
// The double ampersand is needed otherwise this loop doesn't work with vector<bool>
|
|
|
|
for (auto&& it: container) {
|
|
|
|
getSizeType(it.first, returnArg);
|
|
|
|
getSizeType(it.second, returnArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
2023-09-07 15:07:31 +01:00
|
|
|
|
|
|
|
traversal_func = """
|
|
|
|
auto tail = returnArg
|
2023-10-06 17:41:50 +01:00
|
|
|
.write((uintptr_t)container.getAllocatedMemorySize())
|
|
|
|
.write((uintptr_t)container.bucket_count())
|
2023-09-07 15:07:31 +01:00
|
|
|
.write(container.size());
|
|
|
|
|
|
|
|
for (auto &&entry: container) {
|
2023-11-16 15:34:03 +00:00
|
|
|
tail = tail.delegate([&ctx, &key = entry.first, &value = entry.second](auto ret) {
|
|
|
|
auto next = ret.delegate([&ctx, &key](typename TypeHandler<Ctx, T0>::type ret) {
|
|
|
|
return OIInternal::getSizeType<Ctx>(ctx, key, ret);
|
2023-09-07 15:07:31 +01:00
|
|
|
});
|
2023-11-16 15:34:03 +00:00
|
|
|
return OIInternal::getSizeType<Ctx>(ctx, value, next);
|
2023-09-07 15:07:31 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return tail.finish();
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[codegen.processor]]
|
|
|
|
type = "types::st::VarInt<DB>"
|
|
|
|
func = "el.pointer = std::get<ParsedData::VarInt>(d.val).value;"
|
|
|
|
|
2023-10-06 17:41:50 +01:00
|
|
|
[[codegen.processor]]
|
|
|
|
type = "types::st::VarInt<DB>"
|
|
|
|
func = """
|
|
|
|
el.container_stats.emplace(result::Element::ContainerStats {
|
|
|
|
.capacity = std::get<ParsedData::VarInt>(d.val).value,
|
|
|
|
});
|
|
|
|
"""
|
|
|
|
|
2023-09-07 15:07:31 +01:00
|
|
|
[[codegen.processor]]
|
|
|
|
type = """
|
|
|
|
types::st::List<DB, types::st::Pair<DB,
|
2023-11-15 19:28:21 +00:00
|
|
|
typename TypeHandler<Ctx, T0>::type,
|
|
|
|
typename TypeHandler<Ctx, T1>::type>>
|
2023-09-07 15:07:31 +01:00
|
|
|
"""
|
|
|
|
func = """
|
2023-10-06 17:41:50 +01:00
|
|
|
static constexpr size_t element_size = sizeof(typename container_type::value_type);
|
|
|
|
|
|
|
|
auto allocationSize = el.pointer.value();
|
|
|
|
el.pointer.reset();
|
|
|
|
|
2023-09-07 15:07:31 +01:00
|
|
|
auto list = std::get<ParsedData::List>(d.val);
|
2023-10-06 17:41:50 +01:00
|
|
|
el.container_stats->length = list.length;
|
|
|
|
|
|
|
|
el.exclusive_size += allocationSize - list.length * element_size;
|
2023-09-07 15:07:31 +01:00
|
|
|
|
|
|
|
static constexpr std::array<inst::Field, 2> element_fields{
|
2023-11-15 19:28:21 +00:00
|
|
|
make_field<Ctx, T0>("key"),
|
|
|
|
make_field<Ctx, T1>("value"),
|
2023-09-07 15:07:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr inst::Field element{
|
2023-10-06 17:41:50 +01:00
|
|
|
element_size,
|
|
|
|
element_size - sizeof(T0) - sizeof(T1),
|
|
|
|
"[]",
|
2023-09-07 15:07:31 +01:00
|
|
|
std::array<std::string_view, 0>{},
|
|
|
|
element_fields,
|
|
|
|
std::array<inst::ProcessorInst, 0>{},
|
2024-01-15 16:23:10 +00:00
|
|
|
element_fields[0].is_primitive && element_fields[1].is_primitive,
|
2023-09-07 15:07:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < list.length; i++)
|
2023-09-14 16:09:23 +01:00
|
|
|
stack_ins(element);
|
2023-09-07 15:07:31 +01:00
|
|
|
"""
|