1 | /** |
2 | * This file contains some using-declarations that define various kinds of |
3 | * PODArray. |
4 | */ |
5 | #pragma once |
6 | |
7 | #include <Common/Allocator_fwd.h> |
8 | |
9 | namespace DB |
10 | { |
11 | |
12 | inline constexpr size_t integerRoundUp(size_t value, size_t dividend) |
13 | { |
14 | return ((value + dividend - 1) / dividend) * dividend; |
15 | } |
16 | |
17 | template <typename T, size_t initial_bytes = 4096, |
18 | typename TAllocator = Allocator<false>, size_t pad_right_ = 0, |
19 | size_t pad_left_ = 0> |
20 | class PODArray; |
21 | |
22 | /** For columns. Padding is enough to read and write xmm-register at the address of the last element. */ |
23 | template <typename T, size_t initial_bytes = 4096, typename TAllocator = Allocator<false>> |
24 | using PaddedPODArray = PODArray<T, initial_bytes, TAllocator, 15, 16>; |
25 | |
26 | /** A helper for declaring PODArray that uses inline memory. |
27 | * The initial size is set to use all the inline bytes, since using less would |
28 | * only add some extra allocation calls. |
29 | */ |
30 | template <typename T, size_t inline_bytes, |
31 | size_t rounded_bytes = integerRoundUp(inline_bytes, sizeof(T))> |
32 | using PODArrayWithStackMemory = PODArray<T, rounded_bytes, |
33 | AllocatorWithStackMemory<Allocator<false>, rounded_bytes, alignof(T)>>; |
34 | |
35 | } |
36 | |