1#include "ComplexKeyCacheDictionary.h"
2
3namespace DB
4{
5ComplexKeyCacheDictionary::Attribute
6ComplexKeyCacheDictionary::createAttributeWithType(const AttributeUnderlyingType type, const Field & null_value)
7{
8 Attribute attr{type, {}, {}};
9
10 switch (type)
11 {
12#define DISPATCH(TYPE) \
13 case AttributeUnderlyingType::ut##TYPE: \
14 attr.null_values = TYPE(null_value.get<NearestFieldType<TYPE>>()); \
15 attr.arrays = std::make_unique<ContainerType<TYPE>>(size); \
16 bytes_allocated += size * sizeof(TYPE); \
17 break;
18 DISPATCH(UInt8)
19 DISPATCH(UInt16)
20 DISPATCH(UInt32)
21 DISPATCH(UInt64)
22 DISPATCH(UInt128)
23 DISPATCH(Int8)
24 DISPATCH(Int16)
25 DISPATCH(Int32)
26 DISPATCH(Int64)
27 DISPATCH(Decimal32)
28 DISPATCH(Decimal64)
29 DISPATCH(Decimal128)
30 DISPATCH(Float32)
31 DISPATCH(Float64)
32#undef DISPATCH
33 case AttributeUnderlyingType::utString:
34 attr.null_values = null_value.get<String>();
35 attr.arrays = std::make_unique<ContainerType<StringRef>>(size);
36 bytes_allocated += size * sizeof(StringRef);
37 if (!string_arena)
38 string_arena = std::make_unique<ArenaWithFreeLists>();
39 break;
40 }
41
42 return attr;
43}
44
45}
46