35 #include <llvm/ExecutionEngine/GenericValue.h>
46 return entry_count > 100000;
55 std::vector<int64_t>
make_key(
const int64_t* buff,
56 const size_t entry_count,
57 const size_t key_count) {
58 std::vector<int64_t> key;
60 for (
size_t i = 0;
i < key_count; ++
i) {
61 key.push_back(buff[off]);
68 const size_t dst_entry_count,
69 const int64_t* src_buff,
70 const size_t src_entry_idx,
71 const size_t src_entry_count,
76 for (
size_t i = 0, dst_slot_off = 0;
i < slot_count;
77 ++
i, dst_slot_off += dst_entry_count) {
78 dst_entry[dst_slot_off] =
82 const auto row_ptr = src_buff +
get_row_qw_count(query_mem_desc) * src_entry_idx;
84 for (
size_t i = 0;
i < slot_count; ++
i) {
85 dst_entry[
i] = row_ptr[slot_off_quad +
i];
92 for (
size_t i = 0;
i < key_count; ++
i) {
99 for (
size_t i = 0;
i < key_count; ++
i) {
105 const size_t comp_sz,
106 const size_t index = 0) {
107 int64_t ret = std::numeric_limits<int64_t>::min();
110 ret = group_by_buffer[index];
114 const int16_t* buffer_ptr =
reinterpret_cast<const int16_t*
>(group_by_buffer);
115 ret = buffer_ptr[index];
119 const int32_t* buffer_ptr =
reinterpret_cast<const int32_t*
>(group_by_buffer);
120 ret = buffer_ptr[index];
124 const int64_t* buffer_ptr =
reinterpret_cast<const int64_t*
>(group_by_buffer);
125 ret = buffer_ptr[index];
136 const int8_t* that_buff,
137 const int32_t start_entry_index,
138 const int32_t end_entry_index,
139 const int32_t that_entry_count,
140 const void* this_qmd,
141 const void* that_qmd,
142 const void* serialized_varlen_buffer) {
145 err = reduction_code.
func_ptr(this_buff,
152 serialized_varlen_buffer);
171 throw std::runtime_error(
"Multiple distinct values encountered");
174 throw std::runtime_error(
175 "Query execution has exceeded the time limit or was interrupted during result "
183 const size_t key_count,
184 const size_t key_width) {
187 auto key_ptr_i32 =
reinterpret_cast<int32_t*
>(key_ptr);
192 auto key_ptr_i64 =
reinterpret_cast<int64_t*
>(key_ptr);
204 const std::vector<std::string>& serialized_varlen_buffer,
219 CHECK_GE(entry_count, that_entry_count);
222 CHECK_EQ(entry_count, that_entry_count);
224 auto this_buff =
buff_;
226 auto that_buff = that.
buff_;
230 if (!serialized_varlen_buffer.empty()) {
231 throw std::runtime_error(
232 "Projection of variable length targets with baseline hash group by is not yet "
233 "supported in Distributed mode");
237 std::vector<std::future<void>> reduction_threads;
238 for (
size_t thread_idx = 0; thread_idx < thread_count; ++thread_idx) {
239 const auto thread_entry_count =
240 (that_entry_count + thread_count - 1) / thread_count;
241 const auto start_index = thread_idx * thread_entry_count;
242 const auto end_index =
243 std::min(start_index + thread_entry_count, that_entry_count);
244 reduction_threads.emplace_back(std::async(
265 for (
size_t entry_idx = start_index; entry_idx < end_index; ++entry_idx) {
267 this_buff, that_buff, entry_idx, that_entry_count, that);
272 for (
auto& reduction_thread : reduction_threads) {
273 reduction_thread.wait();
275 for (
auto& reduction_thread : reduction_threads) {
276 reduction_thread.get();
290 for (
size_t i = 0;
i < that_entry_count; ++
i) {
299 std::vector<std::future<void>> reduction_threads;
300 for (
size_t thread_idx = 0; thread_idx < thread_count; ++thread_idx) {
301 const auto thread_entry_count = (entry_count + thread_count - 1) / thread_count;
302 const auto start_index = thread_idx * thread_entry_count;
303 const auto end_index = std::min(start_index + thread_entry_count, entry_count);
304 if (query_mem_desc_.didOutputColumnar()) {
305 reduction_threads.emplace_back(std::async(std::launch::async,
312 &serialized_varlen_buffer] {
313 reduceEntriesNoCollisionsColWise(
319 serialized_varlen_buffer);
322 reduction_threads.emplace_back(std::async(std::launch::async,
331 &serialized_varlen_buffer] {
332 CHECK(reduction_code.ir_reduce_loop);
341 &that.query_mem_desc_,
342 &serialized_varlen_buffer);
346 for (
auto& reduction_thread : reduction_threads) {
347 reduction_thread.wait();
349 for (
auto& reduction_thread : reduction_threads) {
350 reduction_thread.get();
353 if (query_mem_desc_.didOutputColumnar()) {
354 reduceEntriesNoCollisionsColWise(this_buff,
358 query_mem_desc_.getEntryCount(),
359 serialized_varlen_buffer);
361 CHECK(reduction_code.ir_reduce_loop);
369 &that.query_mem_desc_,
370 &serialized_varlen_buffer);
381 throw std::runtime_error(
382 "Query execution has exceeded the time limit or was interrupted during result "
391 const int8_t* that_buff,
393 const size_t start_index,
394 const size_t end_index,
395 const std::vector<std::string>& serialized_varlen_buffer)
const {
398 CHECK(serialized_varlen_buffer.empty());
404 for (
size_t target_idx = 0; target_idx <
targets_.size(); ++target_idx) {
405 const auto& agg_info =
targets_[target_idx];
406 const auto& slots_for_col = col_slot_context.getSlotsForCol(target_idx);
408 bool two_slot_target{
false};
409 if (agg_info.is_agg &&
410 (agg_info.agg_kind ==
kAVG ||
411 (agg_info.agg_kind ==
kSAMPLE && agg_info.sql_type.is_varlen()))) {
415 two_slot_target =
true;
418 for (
size_t target_slot_idx = slots_for_col.front();
419 target_slot_idx < slots_for_col.back() + 1;
420 target_slot_idx += 2) {
426 for (
size_t entry_idx = start_index; entry_idx < end_index; ++entry_idx) {
441 int8_t* this_ptr2{
nullptr};
442 const int8_t* that_ptr2{
nullptr};
460 slots_for_col.front(),
461 serialized_varlen_buffer);
464 this_crt_col_ptr = this_next_col_ptr;
465 that_crt_col_ptr = that_next_col_ptr;
482 const int8_t* that_buff)
const {
487 const auto column_offset_bytes =
489 auto lhs_key_ptr = this_buff + column_offset_bytes;
490 auto rhs_key_ptr = that_buff + column_offset_bytes;
493 *(
reinterpret_cast<int64_t*
>(lhs_key_ptr) + entry_idx) =
494 *(
reinterpret_cast<const int64_t*
>(rhs_key_ptr) + entry_idx);
497 *(
reinterpret_cast<int32_t*
>(lhs_key_ptr) + entry_idx) =
498 *(
reinterpret_cast<const int32_t*
>(rhs_key_ptr) + entry_idx);
501 *(
reinterpret_cast<int16_t*
>(lhs_key_ptr) + entry_idx) =
502 *(
reinterpret_cast<const int16_t*
>(rhs_key_ptr) + entry_idx);
505 *(
reinterpret_cast<int8_t*
>(lhs_key_ptr) + entry_idx) =
506 *(
reinterpret_cast<const int8_t*
>(rhs_key_ptr) + entry_idx);
518 const std::vector<std::string>& serialized_varlen_buffer)
const {
519 if (serialized_varlen_buffer.empty()) {
529 for (
size_t i = 0;
i < entry_count; ++
i) {
535 auto rowwise_targets_ptr =
537 size_t target_slot_idx = 0;
538 for (
size_t target_logical_idx = 0; target_logical_idx <
targets_.size();
539 ++target_logical_idx) {
540 const auto& target_info =
targets_[target_logical_idx];
541 if (target_info.sql_type.is_varlen() && target_info.is_agg) {
543 auto ptr1 = rowwise_targets_ptr;
544 auto slot_idx = target_slot_idx;
546 auto offset = *
reinterpret_cast<const int64_t*
>(ptr1);
548 const auto& elem_ti = target_info.sql_type.get_elem_type();
549 size_t length_to_elems =
550 target_info.sql_type.is_string() || target_info.sql_type.is_geometry()
552 : elem_ti.get_size();
553 if (target_info.sql_type.is_geometry()) {
554 for (
int j = 0;
j < target_info.sql_type.get_physical_coord_cols();
j++) {
561 CHECK_LT(static_cast<size_t>(offset), serialized_varlen_buffer.size());
562 const auto& varlen_bytes_str = serialized_varlen_buffer[offset++];
564 reinterpret_cast<const int8_t*
>(varlen_bytes_str.c_str());
566 *
reinterpret_cast<int64_t*
>(ptr1) = reinterpret_cast<const int64_t>(str_ptr);
568 *
reinterpret_cast<int64_t*
>(ptr2) =
569 static_cast<int64_t>(varlen_bytes_str.size() / length_to_elems);
572 CHECK_LT(static_cast<size_t>(offset), serialized_varlen_buffer.size());
573 const auto& varlen_bytes_str = serialized_varlen_buffer[offset];
574 const auto str_ptr =
reinterpret_cast<const int8_t*
>(varlen_bytes_str.c_str());
576 *
reinterpret_cast<int64_t*
>(ptr1) = reinterpret_cast<const int64_t>(str_ptr);
578 *
reinterpret_cast<int64_t*
>(ptr2) =
579 static_cast<int64_t>(varlen_bytes_str.size() / length_to_elems);
584 rowwise_targets_ptr, target_info, target_slot_idx,
query_mem_desc_,
false);
585 target_slot_idx =
advance_slot(target_slot_idx, target_info,
false);
595 #define mapd_cas(address, compare, val) \
596 InterlockedCompareExchange(reinterpret_cast<volatile long*>(address), \
597 static_cast<long>(val), \
598 static_cast<long>(compare))
600 #define mapd_cas(address, compare, val) __sync_val_compare_and_swap(address, compare, val)
606 const uint32_t key_qw_count,
607 const size_t entry_count) {
611 for (
size_t i = 0;
i < key_qw_count; ++
i) {
612 groups_buffer[off] = key[
i];
615 return {&groups_buffer[off],
true};
618 for (
size_t i = 0;
i < key_qw_count; ++
i) {
619 if (groups_buffer[off] != key[
i]) {
620 return {
nullptr,
true};
624 return {&groups_buffer[off],
false};
631 int64_t* groups_buffer,
632 const uint32_t groups_buffer_entry_count,
634 const uint32_t key_qw_count) {
635 uint32_t h =
key_hash(key, key_qw_count,
sizeof(int64_t)) % groups_buffer_entry_count;
637 groups_buffer, h, key, key_qw_count, groups_buffer_entry_count);
638 if (matching_gvi.first) {
641 uint32_t h_probe = (h + 1) % groups_buffer_entry_count;
642 while (h_probe != h) {
644 groups_buffer, h_probe, key, key_qw_count, groups_buffer_entry_count);
645 if (matching_gvi.first) {
648 h_probe = (h_probe + 1) % groups_buffer_entry_count;
650 return {
nullptr,
true};
654 #define cas_cst(ptr, expected, desired) \
655 (InterlockedCompareExchangePointer(reinterpret_cast<void* volatile*>(ptr), \
656 reinterpret_cast<void*>(&desired), \
657 expected) == expected)
658 #define store_cst(ptr, val) \
659 InterlockedExchangePointer(reinterpret_cast<void* volatile*>(ptr), \
660 reinterpret_cast<void*>(val))
661 #define load_cst(ptr) \
662 InterlockedCompareExchange(reinterpret_cast<volatile long*>(ptr), 0, 0)
664 #define cas_cst(ptr, expected, desired) \
665 __atomic_compare_exchange_n( \
666 ptr, expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
667 #define store_cst(ptr, val) __atomic_store_n(ptr, val, __ATOMIC_SEQ_CST)
668 #define load_cst(ptr) __atomic_load_n(ptr, __ATOMIC_SEQ_CST)
671 template <
typename T =
int64_t>
673 int64_t* groups_buffer,
676 const uint32_t key_count,
678 const int64_t* that_buff_i64,
679 const size_t that_entry_idx,
680 const size_t that_entry_count,
681 const uint32_t row_size_quad) {
682 auto off = h * row_size_quad;
683 T empty_key = get_empty_key<T>();
684 T write_pending = get_empty_key<T>() - 1;
685 auto row_ptr =
reinterpret_cast<T*
>(groups_buffer + off);
687 const bool success =
cas_cst(row_ptr, &empty_key, write_pending);
689 fill_slots(groups_buffer + off + slot_off_quad,
696 memcpy(row_ptr + 1, key + 1, (key_count - 1) *
sizeof(
T));
699 return {groups_buffer + off + slot_off_quad,
true};
701 while (
load_cst(row_ptr) == write_pending) {
705 for (
size_t i = 0;
i < key_count; ++
i) {
707 return {
nullptr,
true};
710 return {groups_buffer + off + slot_off_quad,
false};
718 int64_t* groups_buffer,
721 const uint32_t key_count,
722 const size_t key_width,
724 const int64_t* that_buff_i64,
725 const size_t that_entry_idx,
726 const size_t that_entry_count,
727 const uint32_t row_size_quad) {
732 reinterpret_cast<const int32_t*>(key),
751 return {
nullptr,
true};
758 int64_t* groups_buffer,
759 const uint32_t groups_buffer_entry_count,
761 const uint32_t key_count,
762 const size_t key_width,
764 const int64_t* that_buff_i64,
765 const size_t that_entry_idx,
766 const size_t that_entry_count,
767 const uint32_t row_size_quad) {
768 uint32_t h =
key_hash(key, key_count, key_width) % groups_buffer_entry_count;
779 if (matching_gvi.first) {
782 uint32_t h_probe = (h + 1) % groups_buffer_entry_count;
783 while (h_probe != h) {
794 if (matching_gvi.first) {
797 h_probe = (h_probe + 1) % groups_buffer_entry_count;
799 return {
nullptr,
true};
805 const int8_t* that_buff,
806 const size_t that_entry_idx,
807 const size_t that_entry_count,
820 auto this_buff_i64 =
reinterpret_cast<int64_t*
>(this_buff);
821 auto that_buff_i64 =
reinterpret_cast<const int64_t*
>(that_buff);
822 const auto key =
make_key(&that_buff_i64[key_off], that_entry_count, key_count);
825 CHECK(this_entry_slots);
836 this_entry_slots, that_buff_i64, that_entry_idx, that_entry_count, that);
840 const int64_t* that_buff,
841 const size_t that_entry_idx,
842 const size_t that_entry_count,
847 size_t init_agg_val_idx = 0;
848 for (
size_t target_logical_idx = 0; target_logical_idx <
targets_.size();
849 ++target_logical_idx) {
850 const auto& target_info =
targets_[target_logical_idx];
852 that_entry_idx, init_agg_val_idx, key_count, that_entry_count);
865 init_agg_val_idx =
advance_slot(init_agg_val_idx, target_info,
false);
868 init_agg_val_idx =
advance_slot(init_agg_val_idx, target_info,
false);
876 const size_t this_slot,
877 const int64_t* that_buff,
878 const size_t that_entry_count,
879 const size_t that_slot,
881 const size_t target_logical_idx,
882 const size_t target_slot_idx,
883 const size_t init_agg_val_idx,
886 int8_t* this_ptr2{
nullptr};
887 const int8_t* that_ptr2{
nullptr};
892 const auto that_count_off = that_entry_count;
893 this_ptr2 =
reinterpret_cast<int8_t*
>(&this_buff[this_slot + this_count_off]);
894 that_ptr2 =
reinterpret_cast<const int8_t*
>(&that_buff[that_slot + that_count_off]);
896 reduceOneSlot(reinterpret_cast<int8_t*>(&this_buff[this_slot]),
898 reinterpret_cast<const int8_t*>(&that_buff[that_slot]),
912 template <
class KeyType>
914 const size_t new_entry_count)
const {
917 auto new_buff_i64 =
reinterpret_cast<int64_t*
>(new_buff);
921 const auto src_buff =
reinterpret_cast<const int64_t*
>(
buff_);
927 std::vector<std::future<void>> move_threads;
929 for (
size_t thread_idx = 0; thread_idx < thread_count; ++thread_idx) {
930 const auto thread_entry_count =
932 const auto start_index = thread_idx * thread_entry_count;
933 const auto end_index =
935 move_threads.emplace_back(std::async(
946 for (
size_t entry_idx = start_index; entry_idx < end_index; ++entry_idx) {
947 moveOneEntryToBuffer<KeyType>(entry_idx,
957 for (
auto& move_thread : move_threads) {
960 for (
auto& move_thread : move_threads) {
965 moveOneEntryToBuffer<KeyType>(entry_idx,
976 template <
class KeyType>
978 int64_t* new_buff_i64,
979 const size_t new_entry_count,
980 const size_t key_count,
981 const size_t row_qw_count,
982 const int64_t* src_buff,
983 const size_t key_byte_width)
const {
987 : row_qw_count * entry_index;
988 const auto key_ptr =
reinterpret_cast<const KeyType*
>(&src_buff[key_off]);
989 if (*key_ptr == get_empty_key<KeyType>()) {
992 int64_t* new_entries_ptr{
nullptr};
1006 CHECK(new_entries_ptr);
1016 if (query_mem_desc_.didOutputColumnar()) {
1017 storage_->initializeColWise();
1019 storage_->initializeRowWise();
1027 CHECK(!result_sets.empty());
1028 auto result_rs = result_sets.front();
1029 CHECK(result_rs->storage_);
1030 auto& first_result = *result_rs->storage_;
1031 auto result = &first_result;
1032 const auto row_set_mem_owner = result_rs->row_set_mem_owner_;
1033 for (
const auto result_set : result_sets) {
1034 CHECK_EQ(row_set_mem_owner, result_set->row_set_mem_owner_);
1036 const auto catalog = result_rs->catalog_;
1037 for (
const auto result_set : result_sets) {
1038 CHECK_EQ(catalog, result_set->catalog_);
1040 if (first_result.query_mem_desc_.getQueryDescriptionType() ==
1042 const auto total_entry_count =
1046 [](
const size_t init,
const ResultSet* rs) {
1047 return init + rs->query_mem_desc_.getEntryCount();
1049 CHECK(total_entry_count);
1052 rs_.reset(
new ResultSet(first_result.targets_,
1059 auto result_storage =
rs_->allocateStorage(first_result.target_init_vals_);
1060 rs_->initializeStorage();
1063 first_result.moveEntriesToBuffer<int32_t>(result_storage->getUnderlyingBuffer(),
1067 first_result.moveEntriesToBuffer<int64_t>(result_storage->getUnderlyingBuffer(),
1074 result_rs =
rs_.get();
1077 auto& serialized_varlen_buffer = result_sets.front()->serialized_varlen_buffer_;
1078 if (!serialized_varlen_buffer.empty()) {
1079 result->rewriteAggregateBufferOffsets(serialized_varlen_buffer.front());
1080 for (
auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1082 auto& result_serialized_varlen_buffer = (*result_it)->serialized_varlen_buffer_;
1083 CHECK_EQ(result_serialized_varlen_buffer.size(), size_t(1));
1084 serialized_varlen_buffer.emplace_back(
1085 std::move(result_serialized_varlen_buffer.front()));
1090 result_rs->getTargetInfos(),
1091 result_rs->getTargetInitVals());
1092 auto reduction_code = reduction_jit.
codegen();
1094 for (
auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1096 if (!serialized_varlen_buffer.empty()) {
1098 *((*result_it)->storage_), serialized_varlen_buffer[ctr++], reduction_code);
1100 result->reduce(*((*result_it)->storage_), {}, reduction_code);
1111 auto& result_storage = result_rs->storage_;
1112 result_storage->rewriteAggregateBufferOffsets(
1113 result_rs->serialized_varlen_buffer_.front());
1119 CHECK_EQ(slot_count + key_count, entry.size());
1120 auto this_buff =
reinterpret_cast<int64_t*
>(
buff_);
1125 for (
size_t i = 0;
i < key_count; ++
i) {
1126 this_buff[key_off +
i] = entry[
i];
1130 this_buff[first_slot_off +
i] = entry[key_count +
i];
1138 const auto key_bytes_with_padding =
1144 auto row_ptr =
buff_ +
i * row_size;
1146 auto slot_ptr =
reinterpret_cast<int64_t*
>(row_ptr + key_bytes_with_padding);
1155 auto row_ptr =
buff_ +
i * row_size;
1157 auto slot_ptr =
reinterpret_cast<int64_t*
>(row_ptr + key_bytes_with_padding);
1174 CHECK_EQ(slot_count + key_count, entry.size());
1175 auto this_buff =
reinterpret_cast<int64_t*
>(
buff_);
1177 for (
size_t i = 0;
i < key_count;
i++) {
1179 this_buff[key_offset] = entry[
i];
1184 this_buff[slot_offset] = entry[key_count +
i];
1190 auto this_buff =
reinterpret_cast<int64_t*
>(
buff_);
1192 for (
size_t key_idx = 0; key_idx < key_count; ++key_idx) {
1193 const auto first_key_off =
1199 for (
size_t target_idx = 0; target_idx <
target_init_vals_.size(); ++target_idx) {
1200 const auto first_val_off =
1211 size_t slot_off = 0;
1223 #define AGGREGATE_ONE_VALUE( \
1224 agg_kind__, val_ptr__, other_ptr__, chosen_bytes__, agg_info__) \
1226 const auto sql_type = get_compact_type(agg_info__); \
1227 if (sql_type.is_fp()) { \
1228 if (chosen_bytes__ == sizeof(float)) { \
1229 agg_##agg_kind__##_float(reinterpret_cast<int32_t*>(val_ptr__), \
1230 *reinterpret_cast<const float*>(other_ptr__)); \
1232 agg_##agg_kind__##_double(reinterpret_cast<int64_t*>(val_ptr__), \
1233 *reinterpret_cast<const double*>(other_ptr__)); \
1236 if (chosen_bytes__ == sizeof(int32_t)) { \
1237 auto val_ptr = reinterpret_cast<int32_t*>(val_ptr__); \
1238 auto other_ptr = reinterpret_cast<const int32_t*>(other_ptr__); \
1239 agg_##agg_kind__##_int32(val_ptr, *other_ptr); \
1241 auto val_ptr = reinterpret_cast<int64_t*>(val_ptr__); \
1242 auto other_ptr = reinterpret_cast<const int64_t*>(other_ptr__); \
1243 agg_##agg_kind__(val_ptr, *other_ptr); \
1248 #define AGGREGATE_ONE_NULLABLE_VALUE( \
1249 agg_kind__, val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__) \
1251 if (agg_info__.skip_null_val) { \
1252 const auto sql_type = get_compact_type(agg_info__); \
1253 if (sql_type.is_fp()) { \
1254 if (chosen_bytes__ == sizeof(float)) { \
1255 agg_##agg_kind__##_float_skip_val( \
1256 reinterpret_cast<int32_t*>(val_ptr__), \
1257 *reinterpret_cast<const float*>(other_ptr__), \
1258 *reinterpret_cast<const float*>(may_alias_ptr(&init_val__))); \
1260 agg_##agg_kind__##_double_skip_val( \
1261 reinterpret_cast<int64_t*>(val_ptr__), \
1262 *reinterpret_cast<const double*>(other_ptr__), \
1263 *reinterpret_cast<const double*>(may_alias_ptr(&init_val__))); \
1266 if (chosen_bytes__ == sizeof(int32_t)) { \
1267 int32_t* val_ptr = reinterpret_cast<int32_t*>(val_ptr__); \
1268 const int32_t* other_ptr = reinterpret_cast<const int32_t*>(other_ptr__); \
1269 const auto null_val = static_cast<int32_t>(init_val__); \
1270 agg_##agg_kind__##_int32_skip_val(val_ptr, *other_ptr, null_val); \
1272 int64_t* val_ptr = reinterpret_cast<int64_t*>(val_ptr__); \
1273 const int64_t* other_ptr = reinterpret_cast<const int64_t*>(other_ptr__); \
1274 const auto null_val = static_cast<int64_t>(init_val__); \
1275 agg_##agg_kind__##_skip_val(val_ptr, *other_ptr, null_val); \
1279 AGGREGATE_ONE_VALUE( \
1280 agg_kind__, val_ptr__, other_ptr__, chosen_bytes__, agg_info__); \
1284 #define AGGREGATE_ONE_COUNT(val_ptr__, other_ptr__, chosen_bytes__) \
1286 if (chosen_bytes__ == sizeof(int32_t)) { \
1287 auto val_ptr = reinterpret_cast<int32_t*>(val_ptr__); \
1288 auto other_ptr = reinterpret_cast<const int32_t*>(other_ptr__); \
1289 agg_sum_int32(val_ptr, *other_ptr); \
1291 auto val_ptr = reinterpret_cast<int64_t*>(val_ptr__); \
1292 auto other_ptr = reinterpret_cast<const int64_t*>(other_ptr__); \
1293 agg_sum(val_ptr, *other_ptr); \
1297 #define AGGREGATE_ONE_NULLABLE_COUNT( \
1298 val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__) \
1300 if (agg_info__.skip_null_val) { \
1301 const auto sql_type = get_compact_type(agg_info__); \
1302 if (sql_type.is_fp()) { \
1303 if (chosen_bytes__ == sizeof(float)) { \
1304 agg_sum_float_skip_val( \
1305 reinterpret_cast<int32_t*>(val_ptr__), \
1306 *reinterpret_cast<const float*>(other_ptr__), \
1307 *reinterpret_cast<const float*>(may_alias_ptr(&init_val__))); \
1309 agg_sum_double_skip_val( \
1310 reinterpret_cast<int64_t*>(val_ptr__), \
1311 *reinterpret_cast<const double*>(other_ptr__), \
1312 *reinterpret_cast<const double*>(may_alias_ptr(&init_val__))); \
1315 if (chosen_bytes__ == sizeof(int32_t)) { \
1316 auto val_ptr = reinterpret_cast<int32_t*>(val_ptr__); \
1317 auto other_ptr = reinterpret_cast<const int32_t*>(other_ptr__); \
1318 const auto null_val = static_cast<int32_t>(init_val__); \
1319 agg_sum_int32_skip_val(val_ptr, *other_ptr, null_val); \
1321 auto val_ptr = reinterpret_cast<int64_t*>(val_ptr__); \
1322 auto other_ptr = reinterpret_cast<const int64_t*>(other_ptr__); \
1323 const auto null_val = static_cast<int64_t>(init_val__); \
1324 agg_sum_skip_val(val_ptr, *other_ptr, null_val); \
1328 AGGREGATE_ONE_COUNT(val_ptr__, other_ptr__, chosen_bytes__); \
1333 #define AGGREGATE_ONE_VALUE_SMALL( \
1334 agg_kind__, val_ptr__, other_ptr__, chosen_bytes__, agg_info__) \
1336 if (chosen_bytes__ == sizeof(int16_t)) { \
1337 auto val_ptr = reinterpret_cast<int16_t*>(val_ptr__); \
1338 auto other_ptr = reinterpret_cast<const int16_t*>(other_ptr__); \
1339 agg_##agg_kind__##_int16(val_ptr, *other_ptr); \
1340 } else if (chosen_bytes__ == sizeof(int8_t)) { \
1341 auto val_ptr = reinterpret_cast<int8_t*>(val_ptr__); \
1342 auto other_ptr = reinterpret_cast<const int8_t*>(other_ptr__); \
1343 agg_##agg_kind__##_int8(val_ptr, *other_ptr); \
1350 #define AGGREGATE_ONE_NULLABLE_VALUE_SMALL( \
1351 agg_kind__, val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__) \
1353 if (agg_info__.skip_null_val) { \
1354 if (chosen_bytes__ == sizeof(int16_t)) { \
1355 int16_t* val_ptr = reinterpret_cast<int16_t*>(val_ptr__); \
1356 const int16_t* other_ptr = reinterpret_cast<const int16_t*>(other_ptr__); \
1357 const auto null_val = static_cast<int16_t>(init_val__); \
1358 agg_##agg_kind__##_int16_skip_val(val_ptr, *other_ptr, null_val); \
1359 } else if (chosen_bytes == sizeof(int8_t)) { \
1360 int8_t* val_ptr = reinterpret_cast<int8_t*>(val_ptr__); \
1361 const int8_t* other_ptr = reinterpret_cast<const int8_t*>(other_ptr__); \
1362 const auto null_val = static_cast<int8_t>(init_val__); \
1363 agg_##agg_kind__##_int8_skip_val(val_ptr, *other_ptr, null_val); \
1366 AGGREGATE_ONE_VALUE_SMALL( \
1367 agg_kind__, val_ptr__, other_ptr__, chosen_bytes__, agg_info__); \
1372 const bool float_argument_input,
1374 if (float_argument_input) {
1375 return sizeof(float);
1382 const size_t target_slot_idx,
1383 const size_t init_agg_val_idx,
1384 const int8_t* that_ptr1)
const {
1390 auto reduce = [&](
auto const& size_tag) {
1391 using CastTarget = std::decay_t<decltype(size_tag)>;
1392 const auto lhs_proj_col = *
reinterpret_cast<const CastTarget*
>(this_ptr1);
1393 const auto rhs_proj_col = *
reinterpret_cast<const CastTarget*
>(that_ptr1);
1394 if (rhs_proj_col == init_val) {
1396 }
else if (lhs_proj_col == init_val) {
1397 *
reinterpret_cast<CastTarget*
>(this_ptr1) = rhs_proj_col;
1398 }
else if (lhs_proj_col != rhs_proj_col) {
1399 throw std::runtime_error(
"Multiple distinct values encountered");
1403 switch (chosen_bytes) {
1424 LOG(
FATAL) <<
"Invalid slot width: " << chosen_bytes;
1431 const int8_t* that_ptr1,
1432 const int8_t* that_ptr2,
1434 const size_t target_logical_idx,
1435 const size_t target_slot_idx,
1436 const size_t init_agg_val_idx,
1438 const size_t first_slot_idx_for_target,
1439 const std::vector<std::string>& serialized_varlen_buffer)
const {
1453 this_ptr1, target_info, target_logical_idx, init_agg_val_idx, that_ptr1);
1459 CHECK_EQ(static_cast<size_t>(chosen_bytes),
sizeof(int64_t));
1476 sum, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1480 if (static_cast<size_t>(chosen_bytes) <=
sizeof(int16_t)) {
1482 min, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1485 min, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1490 if (static_cast<size_t>(chosen_bytes) <=
sizeof(int16_t)) {
1492 max, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1495 max, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1500 CHECK_EQ(static_cast<int8_t>(
sizeof(int64_t)), chosen_bytes);
1507 switch (chosen_bytes) {
1510 const auto rhs_proj_col = *
reinterpret_cast<const int8_t*
>(that_ptr1);
1511 if (rhs_proj_col != init_val) {
1512 *
reinterpret_cast<int8_t*
>(this_ptr1) = rhs_proj_col;
1518 const auto rhs_proj_col = *
reinterpret_cast<const int16_t*
>(that_ptr1);
1519 if (rhs_proj_col != init_val) {
1520 *
reinterpret_cast<int16_t*
>(this_ptr1) = rhs_proj_col;
1527 const auto rhs_proj_col = *
reinterpret_cast<const int32_t*
>(that_ptr1);
1528 if (rhs_proj_col != init_val) {
1529 *
reinterpret_cast<int32_t*
>(this_ptr1) = rhs_proj_col;
1534 auto rhs_proj_col = *
reinterpret_cast<const int64_t*
>(that_ptr1);
1536 !serialized_varlen_buffer.empty()) {
1537 size_t length_to_elems{0};
1540 length_to_elems = target_slot_idx == first_slot_idx_for_target ? 1 : 4;
1546 CHECK_LT(static_cast<size_t>(rhs_proj_col), serialized_varlen_buffer.size());
1547 const auto& varlen_bytes_str = serialized_varlen_buffer[rhs_proj_col];
1548 const auto str_ptr =
reinterpret_cast<const int8_t*
>(varlen_bytes_str.c_str());
1549 *
reinterpret_cast<int64_t*
>(this_ptr1) =
1550 reinterpret_cast<const int64_t>(str_ptr);
1551 *
reinterpret_cast<int64_t*
>(this_ptr2) =
1552 static_cast<int64_t>(varlen_bytes_str.size() / length_to_elems);
1554 if (rhs_proj_col != init_val) {
1555 *
reinterpret_cast<int64_t*
>(this_ptr1) = rhs_proj_col;
1558 CHECK(this_ptr2 && that_ptr2);
1559 *
reinterpret_cast<int64_t*
>(this_ptr2) =
1560 *reinterpret_cast<const int64_t*>(that_ptr2);
1567 LOG(
FATAL) <<
"Invalid slot width: " << chosen_bytes;
1573 const int8_t* that_ptr1,
1574 const size_t target_logical_idx,
1579 CHECK(incoming) <<
"this_ptr1=" << (
void*)this_ptr1
1580 <<
", that_ptr1=" << (
void const*)that_ptr1
1581 <<
", target_logical_idx=" << target_logical_idx;
1582 if (incoming->centroids().capacity()) {
1584 CHECK(accumulator) <<
"this_ptr1=" << (
void*)this_ptr1
1585 <<
", that_ptr1=" << (
void const*)that_ptr1
1586 <<
", target_logical_idx=" << target_logical_idx;
1587 accumulator->allocate();
1588 accumulator->mergeTDigest(*incoming);
1593 const int8_t* that_ptr1,
1594 const size_t target_logical_idx,
1597 const auto& old_count_distinct_desc =
1600 const auto& new_count_distinct_desc =
1602 CHECK(old_count_distinct_desc.impl_type_ == new_count_distinct_desc.impl_type_);
1603 CHECK(this_ptr1 && that_ptr1);
1604 auto old_set_ptr =
reinterpret_cast<const int64_t*
>(this_ptr1);
1605 auto new_set_ptr =
reinterpret_cast<const int64_t*
>(that_ptr1);
1607 *new_set_ptr, *old_set_ptr, new_count_distinct_desc, old_count_distinct_desc);
1611 const int8_t warp_count,
1612 const bool is_columnar,
1613 const bool replace_bitmap_ptr_with_bitmap_sz,
1614 std::vector<int64_t>& agg_vals,
1616 const std::vector<TargetInfo>& targets,
1617 const std::vector<int64_t>& agg_init_vals) {
1618 const size_t agg_col_count{agg_vals.size()};
1619 const auto row_size = query_mem_desc.
getRowSize();
1621 CHECK_GE(agg_col_count, targets.size());
1624 std::vector<int64_t> partial_agg_vals(agg_col_count, 0);
1625 bool discard_row =
true;
1626 for (int8_t warp_idx = 0; warp_idx < warp_count; ++warp_idx) {
1627 bool discard_partial_result =
true;
1628 for (
size_t target_idx = 0, agg_col_idx = 0;
1629 target_idx < targets.size() && agg_col_idx < agg_col_count;
1630 ++target_idx, ++agg_col_idx) {
1631 const auto& agg_info = targets[target_idx];
1633 const auto chosen_bytes = float_argument_input
1638 partial_agg_vals[agg_col_idx] = partial_bin_val;
1641 CHECK(agg_info.is_agg && (agg_info.agg_kind ==
kCOUNT ||
1645 if (replace_bitmap_ptr_with_bitmap_sz) {
1646 partial_agg_vals[agg_col_idx] = partial_bin_val;
1649 if (
kAVG == agg_info.agg_kind) {
1650 CHECK(agg_info.is_agg && !agg_info.is_distinct);
1652 partial_bin_val = partial_agg_vals[agg_col_idx] =
1658 CHECK(agg_info.is_agg);
1659 discard_partial_result =
false;
1662 row_ptr += row_size;
1663 if (discard_partial_result) {
1666 discard_row =
false;
1667 for (
size_t target_idx = 0, agg_col_idx = 0;
1668 target_idx < targets.size() && agg_col_idx < agg_col_count;
1669 ++target_idx, ++agg_col_idx) {
1670 auto partial_bin_val = partial_agg_vals[agg_col_idx];
1671 const auto& agg_info = targets[target_idx];
1673 const auto chosen_bytes = float_argument_input
1677 if (agg_info.is_agg && agg_info.agg_kind !=
kSAMPLE) {
1679 switch (agg_info.agg_kind) {
1683 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1684 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1685 agg_init_vals[agg_col_idx],
1693 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx + 1]),
1694 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx + 1]),
1700 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1701 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1702 agg_init_vals[agg_col_idx],
1707 if (static_cast<size_t>(chosen_bytes) <=
sizeof(int16_t)) {
1710 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1711 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1712 agg_init_vals[agg_col_idx],
1718 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1719 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1720 agg_init_vals[agg_col_idx],
1726 if (static_cast<size_t>(chosen_bytes) <=
sizeof(int16_t)) {
1729 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1730 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1731 agg_init_vals[agg_col_idx],
1737 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1738 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1739 agg_init_vals[agg_col_idx],
1748 }
catch (std::runtime_error& e) {
1752 if (chosen_type.is_integer() || chosen_type.is_decimal()) {
1753 switch (chosen_bytes) {
1757 int32_t ret = *
reinterpret_cast<const int32_t*
>(&agg_vals[agg_col_idx]);
1758 if (!(agg_info.agg_kind ==
kCOUNT && ret != agg_init_vals[agg_col_idx])) {
1759 agg_vals[agg_col_idx] =
static_cast<int64_t
>(ret);
1767 if (
kAVG == agg_info.agg_kind) {
1771 if (agg_info.agg_kind ==
kSAMPLE) {
1772 CHECK(!agg_info.sql_type.is_varlen())
1773 <<
"Interleaved bins reduction not supported for variable length "
1777 if (agg_vals[agg_col_idx]) {
1778 if (agg_info.agg_kind ==
kSAMPLE) {
1781 CHECK_EQ(agg_vals[agg_col_idx], partial_bin_val);
1783 agg_vals[agg_col_idx] = partial_bin_val;
GroupValueInfo get_group_value_reduction(int64_t *groups_buffer, const uint32_t groups_buffer_entry_count, const int64_t *key, const uint32_t key_count, const size_t key_width, const QueryMemoryDescriptor &query_mem_desc, const int64_t *that_buff_i64, const size_t that_entry_idx, const size_t that_entry_count, const uint32_t row_size_quad)
size_t slot_offset_rowwise(const size_t entry_idx, const size_t slot_idx, const size_t key_count, const size_t slot_count)
size_t getSlotCount() const
NEVER_INLINE DEVICE int64_t * get_group_value_columnar(int64_t *groups_buffer, const uint32_t groups_buffer_entry_count, const int64_t *key, const uint32_t key_qw_count)
void count_distinct_set_union(const int64_t new_set_handle, const int64_t old_set_handle, const CountDistinctDescriptor &new_count_distinct_desc, const CountDistinctDescriptor &old_count_distinct_desc)
size_t getEntryCount() const
__device__ bool dynamic_watchdog()
void moveOneEntryToBuffer(const size_t entry_index, int64_t *new_buff_i64, const size_t new_entry_count, const size_t key_count, const size_t row_qw_count, const int64_t *src_buff, const size_t key_byte_width) const
bool isEmptyEntry(const size_t entry_idx, const int8_t *buff) const
void run_reduction_code(const ReductionCode &reduction_code, int8_t *this_buff, const int8_t *that_buff, const int32_t start_entry_index, const int32_t end_entry_index, const int32_t that_entry_count, const void *this_qmd, const void *that_qmd, const void *serialized_varlen_buffer)
std::string toString(const ExtArgumentType &sig_type)
const std::vector< TargetInfo > targets_
ALWAYS_INLINE void reduceOneSlot(int8_t *this_ptr1, int8_t *this_ptr2, const int8_t *that_ptr1, const int8_t *that_ptr2, const TargetInfo &target_info, const size_t target_logical_idx, const size_t target_slot_idx, const size_t init_agg_val_idx, const ResultSetStorage &that, const size_t first_slot_idx_for_target, const std::vector< std::string > &serialized_varlen_buffer) const
void reduceEntriesNoCollisionsColWise(int8_t *this_buff, const int8_t *that_buff, const ResultSetStorage &that, const size_t start_index, const size_t end_index, const std::vector< std::string > &serialized_varlen_buffer) const
std::vector< int64_t > target_init_vals_
void initializeColWise() const
size_t slot_offset_colwise(const size_t entry_idx, const size_t slot_idx, const size_t key_count, const size_t entry_count)
void reduceOneEntryBaseline(int8_t *this_buff, const int8_t *that_buff, const size_t i, const size_t that_entry_count, const ResultSetStorage &that) const
int64_t getTargetGroupbyIndex(const size_t target_idx) const
bool isEmptyEntryColumnar(const size_t entry_idx, const int8_t *buff) const
int64_t get_component(const int8_t *group_by_buffer, const size_t comp_sz, const size_t index=0)
std::unique_ptr< Function > ir_reduce_loop
ALWAYS_INLINE DEVICE uint32_t key_hash(const int64_t *key, const uint32_t key_count, const uint32_t key_byte_width)
bool isLogicalSizedColumnsAllowed() const
T advance_to_next_columnar_target_buff(T target_ptr, const QueryMemoryDescriptor &query_mem_desc, const size_t target_slot_idx)
std::shared_ptr< ResultSet > rs_
GroupValueInfo get_matching_group_value_reduction(int64_t *groups_buffer, const uint32_t h, const T *key, const uint32_t key_count, const QueryMemoryDescriptor &query_mem_desc, const int64_t *that_buff_i64, const size_t that_entry_idx, const size_t that_entry_count, const uint32_t row_size_quad)
void initializeStorage() const
bool hasKeylessHash() const
void fill_slots(int64_t *dst_entry, const size_t dst_entry_count, const int64_t *src_buff, const size_t src_entry_idx, const size_t src_entry_count, const QueryMemoryDescriptor &query_mem_desc)
void initializeRowWise() const
void initializeBaselineValueSlots(int64_t *this_entry_slots) const
GroupValueInfo get_group_value_columnar_reduction(int64_t *groups_buffer, const uint32_t groups_buffer_entry_count, const int64_t *key, const uint32_t key_qw_count)
size_t get_slot_off_quad(const QueryMemoryDescriptor &query_mem_desc)
size_t getEffectiveKeyWidth() const
ALWAYS_INLINE void fill_empty_key_32(int32_t *key_ptr_i32, const size_t key_count)
void reduceOneSlotBaseline(int64_t *this_buff, const size_t this_slot, const int64_t *that_buff, const size_t that_entry_count, const size_t that_slot, const TargetInfo &target_info, const size_t target_logical_idx, const size_t target_slot_idx, const size_t init_agg_val_idx, const ResultSetStorage &that) const
bool g_enable_dynamic_watchdog
bool takes_float_argument(const TargetInfo &target_info)
std::vector< int64_t > make_key(const int64_t *buff, const size_t entry_count, const size_t key_count)
T advance_target_ptr_row_wise(T target_ptr, const TargetInfo &target_info, const size_t slot_idx, const QueryMemoryDescriptor &query_mem_desc, const bool separate_varlen_storage)
void rewriteVarlenAggregates(ResultSet *)
size_t getRowSize() const
void reduce(const ResultSetStorage &that, const std::vector< std::string > &serialized_varlen_buffer, const ReductionCode &reduction_code) const
size_t getColOnlyOffInBytes(const size_t col_idx) const
const SQLTypeInfo get_compact_type(const TargetInfo &target)
int8_t get_width_for_slot(const size_t target_slot_idx, const bool float_argument_input, const QueryMemoryDescriptor &query_mem_desc)
int8_t groupColWidth(const size_t key_idx) const
void reduceOneEntrySlotsBaseline(int64_t *this_entry_slots, const int64_t *that_buff, const size_t that_entry_idx, const size_t that_entry_count, const ResultSetStorage &that) const
static EvalValue run(const Function *function, const std::vector< EvalValue > &inputs)
size_t advance_slot(const size_t j, const TargetInfo &target_info, const bool separate_varlen_storage)
void copyKeyColWise(const size_t entry_idx, int8_t *this_buff, const int8_t *that_buff) const
int64_t count_distinct_set_size(const int64_t set_handle, const CountDistinctDescriptor &count_distinct_desc)
void init(LogOptions const &log_opts)
void reduceOneCountDistinctSlot(int8_t *this_ptr1, const int8_t *that_ptr1, const size_t target_logical_idx, const ResultSetStorage &that) const
size_t getGroupbyColCount() const
void moveEntriesToBuffer(int8_t *new_buff, const size_t new_entry_count) const
void fill_empty_key(void *key_ptr, const size_t key_count, const size_t key_width)
#define store_cst(ptr, val)
size_t targetGroupbyIndicesSize() const
std::pair< int64_t *, bool > GroupValueInfo
ResultSet * reduce(std::vector< ResultSet * > &)
DEVICE auto accumulate(ARGS &&...args)
ALWAYS_INLINE void check_watchdog(const size_t sample_seed)
std::shared_ptr< ResultSet > getOwnResultSet()
void fillOneEntryColWise(const std::vector< int64_t > &entry)
bool is_distinct_target(const TargetInfo &target_info)
GroupValueInfo get_matching_group_value_columnar_reduction(int64_t *groups_buffer, const uint32_t h, const int64_t *key, const uint32_t key_qw_count, const size_t entry_count)
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
static const int32_t ERR_SINGLE_VALUE_FOUND_MULTIPLE_VALUES
T row_ptr_rowwise(T buff, const QueryMemoryDescriptor &query_mem_desc, const size_t entry_idx)
#define mapd_cas(address, compare, val)
size_t getCountDistinctDescriptorsSize() const
QueryDescriptionType getQueryDescriptionType() const
#define cas_cst(ptr, expected, desired)
NEVER_INLINE DEVICE int64_t * get_group_value(int64_t *groups_buffer, const uint32_t groups_buffer_entry_count, const int64_t *key, const uint32_t key_count, const uint32_t key_width, const uint32_t row_size_quad)
size_t key_offset_colwise(const size_t entry_idx, const size_t key_idx, const size_t entry_count)
virtual ReductionCode codegen() const
const CountDistinctDescriptor & getCountDistinctDescriptor(const size_t idx) const
#define AGGREGATE_ONE_NULLABLE_VALUE(agg_kind__, val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__)
void reduceOneApproxMedianSlot(int8_t *this_ptr1, const int8_t *that_ptr1, const size_t target_logical_idx, const ResultSetStorage &that) const
size_t get_row_bytes(const QueryMemoryDescriptor &query_mem_desc)
ALWAYS_INLINE void reduceOneSlotSingleValue(int8_t *this_ptr1, const TargetInfo &target_info, const size_t target_slot_idx, const size_t init_agg_val_idx, const int8_t *that_ptr1) const
#define AGGREGATE_ONE_COUNT(val_ptr__, other_ptr__, chosen_bytes__)
#define AGGREGATE_ONE_NULLABLE_COUNT(val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__)
size_t key_offset_rowwise(const size_t entry_idx, const size_t key_count, const size_t slot_count)
bool use_multithreaded_reduction(const size_t entry_count)
bool didOutputColumnar() const
const ColSlotContext & getColSlotContext() const
static std::mutex compilation_mutex_
void fillOneEntryRowWise(const std::vector< int64_t > &entry)
Basic constructors and methods of the row set interface.
size_t get_row_qw_count(const QueryMemoryDescriptor &query_mem_desc)
#define AGGREGATE_ONE_NULLABLE_VALUE_SMALL(agg_kind__, val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__)
void rewriteAggregateBufferOffsets(const std::vector< std::string > &serialized_varlen_buffer) const
ALWAYS_INLINE void fill_empty_key_64(int64_t *key_ptr_i64, const size_t key_count)
SQLTypeInfo get_elem_type() const
size_t getBufferColSlotCount() const
T get_cols_ptr(T buff, const QueryMemoryDescriptor &query_mem_desc)
static bool reduceSingleRow(const int8_t *row_ptr, const int8_t warp_count, const bool is_columnar, const bool replace_bitmap_ptr_with_bitmap_sz, std::vector< int64_t > &agg_vals, const QueryMemoryDescriptor &query_mem_desc, const std::vector< TargetInfo > &targets, const std::vector< int64_t > &agg_init_vals)
size_t get_key_bytes_rowwise(const QueryMemoryDescriptor &query_mem_desc)
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)
QueryMemoryDescriptor query_mem_desc_
int32_t getTargetIdxForKey() const
size_t getPrependedGroupColOffInBytes(const size_t group_idx) const