2023-08-29 18:19:23 +01:00
|
|
|
[info]
|
|
|
|
type_name = "std::unordered_multiset"
|
|
|
|
stub_template_params = [1,2,3]
|
|
|
|
ctype = "UNORDERED_MULTISET_TYPE"
|
|
|
|
header = "unordered_set"
|
|
|
|
|
|
|
|
# Old:
|
|
|
|
typeName = "std::unordered_multiset<"
|
|
|
|
ns = ["namespace std"]
|
|
|
|
numTemplateParams = 1
|
|
|
|
replaceTemplateParamIndex = [1, 2]
|
|
|
|
allocatorIndex = 3
|
|
|
|
|
|
|
|
[codegen]
|
|
|
|
decl = """
|
|
|
|
template <typename Key, typename Hasher, typename KeyEqual, typename Alloc>
|
|
|
|
void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& returnArg);
|
|
|
|
"""
|
|
|
|
|
|
|
|
func = """
|
|
|
|
template <typename Key, typename Hasher, typename KeyEqual, typename Alloc>
|
|
|
|
void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& returnArg)
|
|
|
|
{
|
|
|
|
constexpr size_t nodeSize = sizeof(typename %1%<Key, Hasher, KeyEqual, Alloc>::node_type);
|
|
|
|
size_t bucketCount = container.bucket_count();
|
|
|
|
size_t numElems = container.size();
|
|
|
|
SAVE_SIZE(sizeof(%1%<Key, Hasher, KeyEqual, Alloc>) + (numElems * nodeSize) + (bucketCount * sizeof(uintptr_t)));
|
|
|
|
|
|
|
|
SAVE_DATA((uintptr_t)nodeSize);
|
|
|
|
SAVE_DATA((uintptr_t)bucketCount);
|
|
|
|
SAVE_DATA((uintptr_t)numElems);
|
|
|
|
|
|
|
|
// The double ampersand is needed otherwise this loop doesn't work with vector<bool>
|
|
|
|
for (auto&& it: container) {
|
|
|
|
getSizeType(it, returnArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
traversal_func = """
|
|
|
|
auto tail = returnArg
|
|
|
|
.write((uintptr_t)&container)
|
|
|
|
.write(container.bucket_count())
|
|
|
|
.write(container.size());
|
|
|
|
|
|
|
|
for (const auto &it : container) {
|
2023-11-16 15:34:03 +00:00
|
|
|
tail = tail.delegate([&ctx, &it](auto ret) {
|
|
|
|
return OIInternal::getSizeType<Ctx>(ctx, it, ret);
|
2023-08-29 18:19:23 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return tail.finish();
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[codegen.processor]]
|
|
|
|
type = "types::st::VarInt<DB>"
|
|
|
|
func = """
|
|
|
|
el.pointer = std::get<ParsedData::VarInt>(d.val).value;
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[codegen.processor]]
|
|
|
|
type = "types::st::VarInt<DB>"
|
|
|
|
func = """
|
|
|
|
// Using the container's capacity to temporarily store the number of buckets
|
|
|
|
// TODO: Is there another way to pass a value across processors?
|
|
|
|
el.container_stats.emplace(result::Element::ContainerStats {
|
|
|
|
.capacity = std::get<ParsedData::VarInt>(d.val).value,
|
|
|
|
});
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[codegen.processor]]
|
2023-11-15 19:28:21 +00:00
|
|
|
type = "types::st::List<DB, typename TypeHandler<Ctx, T0>::type>"
|
2023-08-29 18:19:23 +01:00
|
|
|
func = """
|
|
|
|
#ifdef __GLIBCXX__
|
|
|
|
/* Use libstdc++ implementation __details to compute the size of Nodes and Buckets.
|
|
|
|
*
|
|
|
|
* See the source of <bits/hashtable_policy.h>:
|
|
|
|
* https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00536_source.html
|
|
|
|
*/
|
|
|
|
using OI_Hash_node =
|
|
|
|
std::__detail::_Hash_node<T0, std::__cache_default<T0, T1>::value>;
|
|
|
|
|
|
|
|
using OI_bucket = std::__detail::_Hash_node_base;
|
|
|
|
|
|
|
|
static constexpr size_t element_size = sizeof(OI_Hash_node);
|
|
|
|
static constexpr size_t bucket_size = sizeof(OI_bucket);
|
|
|
|
#else
|
|
|
|
static_assert(false && "No known element_size for sets. See types/set_type.toml");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
auto list = std::get<ParsedData::List>(d.val);
|
|
|
|
// Reading the bucket count that was stored in `capacity` by the processor above.
|
|
|
|
size_t bucket_count = el.container_stats->capacity;
|
|
|
|
el.exclusive_size += bucket_count * bucket_size;
|
|
|
|
el.exclusive_size += list.length * (element_size - sizeof(T0));
|
|
|
|
|
|
|
|
// Overwrite the bucket count stored in `capacity` with the actual container's values.
|
|
|
|
el.container_stats.emplace(result::Element::ContainerStats {
|
|
|
|
.capacity = list.length,
|
|
|
|
.length = list.length,
|
|
|
|
});
|
|
|
|
|
2023-11-15 19:28:21 +00:00
|
|
|
static constexpr auto childField = make_field<Ctx, T0>("[]");
|
2023-08-29 18:19:23 +01:00
|
|
|
for (size_t i = 0; i < list.length; i++)
|
2023-09-14 16:09:23 +01:00
|
|
|
stack_ins(childField);
|
2023-08-29 18:19:23 +01:00
|
|
|
"""
|