Clickhouse Aggregator源码PODArray类型介绍

/** A dynamic array for POD types.POD类型的动态数组
* Designed for a small number of large arrays (rather than a lot of small ones).设计用于一些少量的大数组,而不是大量的小数组
* To be more precise - for use in ColumnVector.更准确的说——用在ColumnVector
* It differs from std::vector in that it does not initialize the elements.和std::vector的区别在于它不初始化元素
*
* Made noncopyable so that there are no accidential copies. You can copy the data using `assign` method.
*为了避免意想不到的拷贝,PODArray不允许拷贝。可以通过assign方法拷贝
* Only part of the std::vector interface is supported.
*支持std::vector的部分接口
* The default constructor creates an empty object that does not allocate memory.
* Then the memory is allocated at least initial_bytes bytes.
*默认构造函数只会创建空对象,而不会申请内存。然后按照最小的内存进行申请
* If you insert elements with push_back, without making a `reserve`, then PODArray is about 2.5 times faster than std::vector.
*如果使用push_back插入元素,而不进行reserve,PODArray的性能是std::vector的2.5倍。
* The template parameter `pad_right` - always allocate at the end of the array as many unused bytes.
* Can be used to make optimistic reading, writing, copying with unaligned SIMD instructions.
*模板参数pad_right总是在末尾申请未使用的字节数。可用于使用未对齐的SIMD指令进行乐观的读、写、复制
* The template parameter `pad_left` - always allocate memory before 0th element of the array (rounded up to the whole number of elements)
* and zero initialize -1th element. It allows to use -1th element that will have value 0.
* This gives performance benefits when converting an array of offsets to array of sizes.
*模板参数pad_left总是在数组的第0个元素之前分配内存(四舍五入到元素个数的整数)并用0初始化-1个元素。

它允许使用值为0的-1个元素。这在将偏移量数组转换为大小数组时提供了性能优势。
* Some methods using allocator have TAllocatorParams variadic arguments.
* These arguments will be passed to corresponding methods of TAllocator.
* Example: pointer to Arena, that is used for allocations.
*一些方法使用了TAllocatorParams可变长参数,这些参数会对应的传递给TAllocator方法。比如:Arena指针用来申请内存。
* Why Allocator is not passed through constructor, as it is done in C++ standard library?为什么不像C++标准库那样,将Allocator通过构造函数传递?
* Because sometimes we have many small objects, that share same allocator with same parameters,因为有时我们有许多小对象,他们使用同一个Allocator,拥有相同参数。
* and we must avoid larger object size due to storing the same parameters in each object.
* This is required for states of aggregate functions.
*而且我们必须避免由于在每个对象中存储相同的参数而导致对象大小过大。这是聚合函数的states所必需的。
* TODO Pass alignment to Allocator.对齐之后传给Allocator
* TODO Allow greater alignment than alignof(T). Example: array of char aligned to page size.允许比alignof(T)更大的对齐。比如:与页面大小对齐的字符数组。
*/

/** Base class that depend only on size of element, not on element itself.只依赖于元素大小而不是依赖于元素本身的基类
* You can static_cast to this class if you want to insert some data regardless to the actual type T.如果你想插入一些数据,而不考虑实际类型T,可以将其静态转换为此类。
*/

posted @ 2020-10-10 16:09  飞舞的小蛇  阅读(642)  评论(0)    收藏  举报