17 #ifndef QUERYENGINE_AGGREGATEUTILS_H
18 #define QUERYENGINE_AGGREGATEUTILS_H
20 #include "../Shared/sqltypes.h"
29 const size_t index = 0) {
32 group_by_buffer[index] =
static_cast<int8_t
>(val);
36 int16_t* buffer_ptr =
reinterpret_cast<int16_t*
>(group_by_buffer);
37 buffer_ptr[index] = (int16_t)val;
41 int32_t* buffer_ptr =
reinterpret_cast<int32_t*
>(group_by_buffer);
42 buffer_ptr[index] = (int32_t)val;
46 int64_t* buffer_ptr =
reinterpret_cast<int64_t*
>(group_by_buffer);
47 buffer_ptr[index] = val;
60 if (nullable && val == *reinterpret_cast<const int32_t*>(may_alias_ptr(&null_float))) {
62 return *
reinterpret_cast<const int64_t*
>(may_alias_ptr(&null_double));
64 double res = *
reinterpret_cast<const float*
>(may_alias_ptr(&val));
65 return *
reinterpret_cast<const int64_t*
>(may_alias_ptr(&res));
69 const size_t cmpt_size,
70 const std::vector<int64_t>& init_vec,
72 std::vector<int64_t> cmpt_res(cmpt_size, 0);
73 int8_t* buffer_ptr =
reinterpret_cast<int8_t*
>(cmpt_res.data());
74 for (
size_t col_idx = 0, init_vec_idx = 0, col_count = query_mem_desc.
getSlotCount();
77 const auto chosen_bytes =
79 if (chosen_bytes == 0) {
82 if (chosen_bytes ==
sizeof(int64_t)) {
85 CHECK_LT(init_vec_idx, init_vec.size());
86 set_component(buffer_ptr, chosen_bytes, init_vec[init_vec_idx++]);
87 buffer_ptr += chosen_bytes;
91 #endif // QUERYENGINE_AGGREGATEUTILS_H
size_t getSlotCount() const
int64_t float_to_double_bin(int32_t val, bool nullable=false)
Macros and functions for groupby buffer compaction.
std::vector< int64_t > compact_init_vals(const size_t cmpt_size, const std::vector< int64_t > &init_vec, const QueryMemoryDescriptor &query_mem_desc)
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
void set_component(int8_t *group_by_buffer, const size_t comp_sz, const int64_t val, const size_t index=0)
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)