33 #include <llvm/ExecutionEngine/GenericValue.h>
44 return entry_count > 100000;
53 std::vector<int64_t>
make_key(
const int64_t* buff,
54 const size_t entry_count,
55 const size_t key_count) {
56 std::vector<int64_t> key;
58 for (
size_t i = 0; i < key_count; ++i) {
59 key.push_back(buff[off]);
66 const size_t dst_entry_count,
67 const int64_t* src_buff,
68 const size_t src_entry_idx,
69 const size_t src_entry_count,
74 for (
size_t i = 0, dst_slot_off = 0; i < slot_count;
75 ++i, dst_slot_off += dst_entry_count) {
76 dst_entry[dst_slot_off] =
80 const auto row_ptr = src_buff +
get_row_qw_count(query_mem_desc) * src_entry_idx;
82 for (
size_t i = 0; i < slot_count; ++i) {
83 dst_entry[i] = row_ptr[slot_off_quad + i];
90 for (
size_t i = 0; i < key_count; ++i) {
97 for (
size_t i = 0; i < key_count; ++i) {
103 const size_t comp_sz,
104 const size_t index = 0) {
105 int64_t ret = std::numeric_limits<int64_t>::min();
108 ret = group_by_buffer[index];
112 const int16_t* buffer_ptr =
reinterpret_cast<const int16_t*
>(group_by_buffer);
113 ret = buffer_ptr[index];
117 const int32_t* buffer_ptr =
reinterpret_cast<const int32_t*
>(group_by_buffer);
118 ret = buffer_ptr[index];
122 const int64_t* buffer_ptr =
reinterpret_cast<const int64_t*
>(group_by_buffer);
123 ret = buffer_ptr[index];
135 const int8_t* that_buff,
136 const int32_t start_entry_index,
137 const int32_t end_entry_index,
138 const int32_t that_entry_count,
139 const void* this_qmd,
140 const void* that_qmd,
141 const void* serialized_varlen_buffer) {
144 err = reduction_code.
func_ptr(this_buff,
151 serialized_varlen_buffer);
167 if (err == int32_t(heavyai::ErrorCode::SINGLE_VALUE_FOUND_MULTIPLE_VALUES)) {
168 throw std::runtime_error(
"Multiple distinct values encountered");
169 }
else if (err == int32_t(heavyai::ErrorCode::INTERRUPTED)) {
170 throw std::runtime_error(
171 "Query execution has interrupted during result set reduction");
173 throw std::runtime_error(
174 "Query execution has exceeded the time limit or was interrupted during result "
182 const size_t key_count,
183 const size_t key_width) {
186 auto key_ptr_i32 =
reinterpret_cast<int32_t*
>(key_ptr);
191 auto key_ptr_i64 =
reinterpret_cast<int64_t*
>(key_ptr);
203 const std::vector<std::string>& serialized_varlen_buffer,
205 const size_t executor_id)
const {
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);
267 for (
size_t entry_idx = start_index; entry_idx < end_index; ++entry_idx) {
269 this_buff, that_buff, entry_idx, that_entry_count, that);
274 for (
auto& reduction_thread : reduction_threads) {
275 reduction_thread.wait();
277 for (
auto& reduction_thread : reduction_threads) {
278 reduction_thread.get();
293 for (
size_t i = 0; i < that_entry_count; ++i) {
302 std::vector<std::future<void>> reduction_threads;
303 for (
size_t thread_idx = 0; thread_idx < thread_count; ++thread_idx) {
304 const auto thread_entry_count = (entry_count + thread_count - 1) / thread_count;
305 const auto start_index = thread_idx * thread_entry_count;
306 const auto end_index = std::min(start_index + thread_entry_count, entry_count);
307 if (query_mem_desc_.didOutputColumnar()) {
315 &serialized_varlen_buffer,
317 reduceEntriesNoCollisionsColWise(
323 serialized_varlen_buffer,
337 &serialized_varlen_buffer] {
338 CHECK(reduction_code.ir_reduce_loop);
348 &that.query_mem_desc_,
349 &serialized_varlen_buffer);
353 for (
auto& reduction_thread : reduction_threads) {
354 reduction_thread.wait();
356 for (
auto& reduction_thread : reduction_threads) {
357 reduction_thread.get();
360 if (query_mem_desc_.didOutputColumnar()) {
361 reduceEntriesNoCollisionsColWise(this_buff,
365 query_mem_desc_.getEntryCount(),
366 serialized_varlen_buffer,
369 CHECK(reduction_code.ir_reduce_loop);
378 &that.query_mem_desc_,
379 &serialized_varlen_buffer);
389 throw std::runtime_error(
390 "Query execution has exceeded the time limit or was interrupted during result "
398 throw std::runtime_error(
399 "Query execution has exceeded the time limit or was interrupted during result "
408 const int8_t* that_buff,
410 const size_t start_index,
411 const size_t end_index,
412 const std::vector<std::string>& serialized_varlen_buffer,
413 const size_t executor_id)
const {
416 CHECK(serialized_varlen_buffer.empty());
424 for (
size_t target_idx = 0; target_idx <
targets_.size(); ++target_idx) {
425 const auto& agg_info =
targets_[target_idx];
426 const auto& slots_for_col = col_slot_context.getSlotsForCol(target_idx);
428 bool two_slot_target{
false};
429 if (agg_info.is_agg &&
430 (agg_info.agg_kind ==
kAVG ||
431 (agg_info.agg_kind ==
kSAMPLE && agg_info.sql_type.is_varlen()))) {
435 two_slot_target =
true;
438 executor->checkNonKernelTimeInterrupted())) {
439 throw std::runtime_error(
440 "Query execution was interrupted during result set reduction");
445 for (
size_t target_slot_idx = slots_for_col.front();
446 target_slot_idx < slots_for_col.back() + 1;
447 target_slot_idx += 2) {
452 for (
size_t entry_idx = start_index; entry_idx < end_index; ++entry_idx) {
466 int8_t* this_ptr2{
nullptr};
467 const int8_t* that_ptr2{
nullptr};
485 slots_for_col.front(),
486 serialized_varlen_buffer);
489 this_crt_col_ptr = this_next_col_ptr;
490 that_crt_col_ptr = that_next_col_ptr;
507 const int8_t* that_buff)
const {
512 const auto column_offset_bytes =
514 auto lhs_key_ptr = this_buff + column_offset_bytes;
515 auto rhs_key_ptr = that_buff + column_offset_bytes;
518 *(
reinterpret_cast<int64_t*
>(lhs_key_ptr) + entry_idx) =
519 *(
reinterpret_cast<const int64_t*
>(rhs_key_ptr) + entry_idx);
522 *(
reinterpret_cast<int32_t*
>(lhs_key_ptr) + entry_idx) =
523 *(
reinterpret_cast<const int32_t*
>(rhs_key_ptr) + entry_idx);
526 *(
reinterpret_cast<int16_t*
>(lhs_key_ptr) + entry_idx) =
527 *(
reinterpret_cast<const int16_t*
>(rhs_key_ptr) + entry_idx);
530 *(
reinterpret_cast<int8_t*
>(lhs_key_ptr) + entry_idx) =
531 *(
reinterpret_cast<const int8_t*
>(rhs_key_ptr) + entry_idx);
543 const std::vector<std::string>& serialized_varlen_buffer)
const {
544 if (serialized_varlen_buffer.empty()) {
554 for (
size_t i = 0; i < entry_count; ++i) {
560 auto rowwise_targets_ptr =
562 size_t target_slot_idx = 0;
563 for (
size_t target_logical_idx = 0; target_logical_idx <
targets_.size();
564 ++target_logical_idx) {
565 const auto& target_info =
targets_[target_logical_idx];
566 if (target_info.sql_type.is_varlen() && target_info.is_agg) {
568 auto ptr1 = rowwise_targets_ptr;
569 auto slot_idx = target_slot_idx;
571 auto offset = *
reinterpret_cast<const int64_t*
>(ptr1);
573 const auto& elem_ti = target_info.sql_type.get_elem_type();
574 size_t length_to_elems =
575 target_info.sql_type.is_string() || target_info.sql_type.is_geometry()
577 : elem_ti.get_size();
578 if (target_info.sql_type.is_geometry()) {
579 for (
int j = 0; j < target_info.sql_type.get_physical_coord_cols(); j++) {
586 CHECK_LT(static_cast<size_t>(offset), serialized_varlen_buffer.size());
587 const auto& varlen_bytes_str = serialized_varlen_buffer[offset++];
589 reinterpret_cast<const int8_t*
>(varlen_bytes_str.c_str());
591 *
reinterpret_cast<int64_t*
>(ptr1) = reinterpret_cast<const int64_t>(str_ptr);
593 *
reinterpret_cast<int64_t*
>(ptr2) =
594 static_cast<int64_t>(varlen_bytes_str.size() / length_to_elems);
597 CHECK_LT(static_cast<size_t>(offset), serialized_varlen_buffer.size());
598 const auto& varlen_bytes_str = serialized_varlen_buffer[offset];
599 const auto str_ptr =
reinterpret_cast<const int8_t*
>(varlen_bytes_str.c_str());
601 *
reinterpret_cast<int64_t*
>(ptr1) = reinterpret_cast<const int64_t>(str_ptr);
603 *
reinterpret_cast<int64_t*
>(ptr2) =
604 static_cast<int64_t>(varlen_bytes_str.size() / length_to_elems);
609 rowwise_targets_ptr, target_info, target_slot_idx,
query_mem_desc_,
false);
610 target_slot_idx =
advance_slot(target_slot_idx, target_info,
false);
620 #define mapd_cas(address, compare, val) \
621 InterlockedCompareExchange(reinterpret_cast<volatile long*>(address), \
622 static_cast<long>(val), \
623 static_cast<long>(compare))
625 #define mapd_cas(address, compare, val) __sync_val_compare_and_swap(address, compare, val)
631 const uint32_t key_qw_count,
632 const size_t entry_count) {
636 for (
size_t i = 0; i < key_qw_count; ++i) {
637 groups_buffer[off] = key[i];
640 return {&groups_buffer[off],
true};
643 for (
size_t i = 0; i < key_qw_count; ++i) {
644 if (groups_buffer[off] != key[i]) {
645 return {
nullptr,
true};
649 return {&groups_buffer[off],
false};
656 int64_t* groups_buffer,
657 const uint32_t groups_buffer_entry_count,
659 const uint32_t key_qw_count) {
660 uint32_t h =
key_hash(key, key_qw_count,
sizeof(int64_t)) % groups_buffer_entry_count;
662 groups_buffer, h, key, key_qw_count, groups_buffer_entry_count);
663 if (matching_gvi.first) {
666 uint32_t h_probe = (h + 1) % groups_buffer_entry_count;
667 while (h_probe != h) {
669 groups_buffer, h_probe, key, key_qw_count, groups_buffer_entry_count);
670 if (matching_gvi.first) {
673 h_probe = (h_probe + 1) % groups_buffer_entry_count;
675 return {
nullptr,
true};
679 #define cas_cst(ptr, expected, desired) \
680 (InterlockedCompareExchangePointer(reinterpret_cast<void* volatile*>(ptr), \
681 reinterpret_cast<void*>(&desired), \
682 expected) == expected)
683 #define store_cst(ptr, val) \
684 InterlockedExchangePointer(reinterpret_cast<void* volatile*>(ptr), \
685 reinterpret_cast<void*>(val))
686 #define load_cst(ptr) \
687 InterlockedCompareExchange(reinterpret_cast<volatile long*>(ptr), 0, 0)
689 #define cas_cst(ptr, expected, desired) \
690 __atomic_compare_exchange_n( \
691 ptr, expected, desired, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
692 #define store_cst(ptr, val) __atomic_store_n(ptr, val, __ATOMIC_SEQ_CST)
693 #define load_cst(ptr) __atomic_load_n(ptr, __ATOMIC_SEQ_CST)
696 template <
typename T =
int64_t>
698 int64_t* groups_buffer,
701 const uint32_t key_count,
703 const int64_t* that_buff_i64,
704 const size_t that_entry_idx,
705 const size_t that_entry_count,
706 const uint32_t row_size_quad) {
707 auto off = h * row_size_quad;
708 T empty_key = get_empty_key<T>();
709 T write_pending = get_empty_key<T>() - 1;
710 auto row_ptr =
reinterpret_cast<T*
>(groups_buffer + off);
712 const bool success =
cas_cst(row_ptr, &empty_key, write_pending);
714 fill_slots(groups_buffer + off + slot_off_quad,
721 memcpy(row_ptr + 1, key + 1, (key_count - 1) *
sizeof(
T));
724 return {groups_buffer + off + slot_off_quad,
true};
726 while (
load_cst(row_ptr) == write_pending) {
730 for (
size_t i = 0; i < key_count; ++i) {
731 if (
load_cst(row_ptr + i) != key[i]) {
732 return {
nullptr,
true};
735 return {groups_buffer + off + slot_off_quad,
false};
743 int64_t* groups_buffer,
746 const uint32_t key_count,
747 const size_t key_width,
749 const int64_t* that_buff_i64,
750 const size_t that_entry_idx,
751 const size_t that_entry_count,
752 const uint32_t row_size_quad) {
757 reinterpret_cast<const int32_t*>(key),
776 return {
nullptr,
true};
783 int64_t* groups_buffer,
784 const uint32_t groups_buffer_entry_count,
786 const uint32_t key_count,
787 const size_t key_width,
789 const int64_t* that_buff_i64,
790 const size_t that_entry_idx,
791 const size_t that_entry_count,
792 const uint32_t row_size_quad) {
793 uint32_t h =
key_hash(key, key_count, key_width) % groups_buffer_entry_count;
804 if (matching_gvi.first) {
807 uint32_t h_probe = (h + 1) % groups_buffer_entry_count;
808 while (h_probe != h) {
819 if (matching_gvi.first) {
822 h_probe = (h_probe + 1) % groups_buffer_entry_count;
824 return {
nullptr,
true};
830 const int8_t* that_buff,
831 const size_t that_entry_idx,
832 const size_t that_entry_count,
847 auto this_buff_i64 =
reinterpret_cast<int64_t*
>(this_buff);
848 auto that_buff_i64 =
reinterpret_cast<const int64_t*
>(that_buff);
849 const auto key =
make_key(&that_buff_i64[key_off], that_entry_count, key_count);
852 CHECK(this_entry_slots);
863 this_entry_slots, that_buff_i64, that_entry_idx, that_entry_count, that);
867 const int64_t* that_buff,
868 const size_t that_entry_idx,
869 const size_t that_entry_count,
874 size_t init_agg_val_idx = 0;
875 for (
size_t target_logical_idx = 0; target_logical_idx <
targets_.size();
876 ++target_logical_idx) {
877 const auto& target_info =
targets_[target_logical_idx];
879 that_entry_idx, init_agg_val_idx, key_count, that_entry_count);
892 init_agg_val_idx =
advance_slot(init_agg_val_idx, target_info,
false);
895 init_agg_val_idx =
advance_slot(init_agg_val_idx, target_info,
false);
903 const size_t this_slot,
904 const int64_t* that_buff,
905 const size_t that_entry_count,
906 const size_t that_slot,
908 const size_t target_logical_idx,
909 const size_t target_slot_idx,
910 const size_t init_agg_val_idx,
913 int8_t* this_ptr2{
nullptr};
914 const int8_t* that_ptr2{
nullptr};
919 const auto that_count_off = that_entry_count;
920 this_ptr2 =
reinterpret_cast<int8_t*
>(&this_buff[this_slot + this_count_off]);
921 that_ptr2 =
reinterpret_cast<const int8_t*
>(&that_buff[that_slot + that_count_off]);
923 reduceOneSlot(reinterpret_cast<int8_t*>(&this_buff[this_slot]),
925 reinterpret_cast<const int8_t*>(&that_buff[that_slot]),
939 template <
class KeyType>
941 const size_t new_entry_count)
const {
944 auto new_buff_i64 =
reinterpret_cast<int64_t*
>(new_buff);
948 const auto src_buff =
reinterpret_cast<const int64_t*
>(
buff_);
954 std::vector<std::future<void>> move_threads;
956 for (
size_t thread_idx = 0; thread_idx < thread_count; ++thread_idx) {
957 const auto thread_entry_count =
959 const auto start_index = thread_idx * thread_entry_count;
960 const auto end_index =
973 for (
size_t entry_idx = start_index; entry_idx < end_index; ++entry_idx) {
974 moveOneEntryToBuffer<KeyType>(entry_idx,
984 for (
auto& move_thread : move_threads) {
987 for (
auto& move_thread : move_threads) {
992 moveOneEntryToBuffer<KeyType>(entry_idx,
1003 template <
class KeyType>
1005 int64_t* new_buff_i64,
1006 const size_t new_entry_count,
1007 const size_t key_count,
1008 const size_t row_qw_count,
1009 const int64_t* src_buff,
1010 const size_t key_byte_width)
const {
1011 const auto key_off =
1014 : row_qw_count * entry_index;
1015 const auto key_ptr =
reinterpret_cast<const KeyType*
>(&src_buff[key_off]);
1016 if (*key_ptr == get_empty_key<KeyType>()) {
1019 int64_t* new_entries_ptr{
nullptr};
1033 CHECK(new_entries_ptr);
1043 if (query_mem_desc_.didOutputColumnar()) {
1044 storage_->initializeColWise();
1046 storage_->initializeRowWise();
1054 const size_t executor_id) {
1055 CHECK(!result_sets.empty());
1056 auto result_rs = result_sets.front();
1057 CHECK(result_rs->storage_);
1058 auto& first_result = *result_rs->storage_;
1059 auto result = &first_result;
1060 const auto row_set_mem_owner = result_rs->row_set_mem_owner_;
1061 for (
const auto result_set : result_sets) {
1062 CHECK_EQ(row_set_mem_owner, result_set->row_set_mem_owner_);
1064 if (first_result.query_mem_desc_.getQueryDescriptionType() ==
1066 const auto total_entry_count =
1070 [](
const size_t init,
const ResultSet* rs) {
1071 return init + rs->query_mem_desc_.getEntryCount();
1073 CHECK(total_entry_count);
1076 rs_.reset(
new ResultSet(first_result.targets_,
1082 auto result_storage =
rs_->allocateStorage(first_result.target_init_vals_);
1083 rs_->initializeStorage();
1086 first_result.moveEntriesToBuffer<int32_t>(result_storage->getUnderlyingBuffer(),
1090 first_result.moveEntriesToBuffer<int64_t>(result_storage->getUnderlyingBuffer(),
1097 result_rs =
rs_.get();
1100 auto& serialized_varlen_buffer = result_sets.front()->serialized_varlen_buffer_;
1101 if (!serialized_varlen_buffer.empty()) {
1102 result->rewriteAggregateBufferOffsets(serialized_varlen_buffer.front());
1103 for (
auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1105 auto& result_serialized_varlen_buffer = (*result_it)->serialized_varlen_buffer_;
1106 CHECK_EQ(result_serialized_varlen_buffer.size(), size_t(1));
1107 serialized_varlen_buffer.emplace_back(
1108 std::move(result_serialized_varlen_buffer.front()));
1113 result_rs->getTargetInfos(),
1114 result_rs->getTargetInitVals(),
1116 auto reduction_code = reduction_jit.
codegen();
1118 for (
auto result_it = result_sets.begin() + 1; result_it != result_sets.end();
1120 if (!serialized_varlen_buffer.empty()) {
1121 result->reduce(*((*result_it)->storage_),
1122 serialized_varlen_buffer[ctr++],
1126 result->reduce(*((*result_it)->storage_), {}, reduction_code, executor_id);
1137 auto& result_storage = result_rs->storage_;
1138 result_storage->rewriteAggregateBufferOffsets(
1139 result_rs->serialized_varlen_buffer_.front());
1145 CHECK_EQ(slot_count + key_count, entry.size());
1146 auto this_buff =
reinterpret_cast<int64_t*
>(
buff_);
1151 for (
size_t i = 0; i < key_count; ++i) {
1152 this_buff[key_off + i] = entry[i];
1156 this_buff[first_slot_off + i] = entry[key_count + i];
1164 const auto key_bytes_with_padding =
1170 auto row_ptr =
buff_ + i * row_size;
1172 auto slot_ptr =
reinterpret_cast<int64_t*
>(row_ptr + key_bytes_with_padding);
1181 auto row_ptr =
buff_ + i * row_size;
1183 auto slot_ptr =
reinterpret_cast<int64_t*
>(row_ptr + key_bytes_with_padding);
1200 CHECK_EQ(slot_count + key_count, entry.size());
1201 auto this_buff =
reinterpret_cast<int64_t*
>(
buff_);
1203 for (
size_t i = 0; i < key_count; i++) {
1205 this_buff[key_offset] = entry[i];
1210 this_buff[slot_offset] = entry[key_count + i];
1216 auto this_buff =
reinterpret_cast<int64_t*
>(
buff_);
1218 for (
size_t key_idx = 0; key_idx < key_count; ++key_idx) {
1219 const auto first_key_off =
1225 for (
size_t target_idx = 0; target_idx <
target_init_vals_.size(); ++target_idx) {
1226 const auto first_val_off =
1237 size_t slot_off = 0;
1249 #define AGGREGATE_ONE_VALUE( \
1250 agg_kind__, val_ptr__, other_ptr__, chosen_bytes__, agg_info__) \
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(reinterpret_cast<int32_t*>(val_ptr__), \
1256 *reinterpret_cast<const float*>(other_ptr__)); \
1258 agg_##agg_kind__##_double(reinterpret_cast<int64_t*>(val_ptr__), \
1259 *reinterpret_cast<const double*>(other_ptr__)); \
1262 if (chosen_bytes__ == sizeof(int32_t)) { \
1263 auto val_ptr = reinterpret_cast<int32_t*>(val_ptr__); \
1264 auto other_ptr = reinterpret_cast<const int32_t*>(other_ptr__); \
1265 agg_##agg_kind__##_int32(val_ptr, *other_ptr); \
1267 auto val_ptr = reinterpret_cast<int64_t*>(val_ptr__); \
1268 auto other_ptr = reinterpret_cast<const int64_t*>(other_ptr__); \
1269 agg_##agg_kind__(val_ptr, *other_ptr); \
1274 #define AGGREGATE_ONE_NULLABLE_VALUE( \
1275 agg_kind__, val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__) \
1277 if (agg_info__.skip_null_val) { \
1278 const auto sql_type = get_compact_type(agg_info__); \
1279 if (sql_type.is_fp()) { \
1280 if (chosen_bytes__ == sizeof(float)) { \
1281 agg_##agg_kind__##_float_skip_val( \
1282 reinterpret_cast<int32_t*>(val_ptr__), \
1283 *reinterpret_cast<const float*>(other_ptr__), \
1284 *reinterpret_cast<const float*>(may_alias_ptr(&init_val__))); \
1286 agg_##agg_kind__##_double_skip_val( \
1287 reinterpret_cast<int64_t*>(val_ptr__), \
1288 *reinterpret_cast<const double*>(other_ptr__), \
1289 *reinterpret_cast<const double*>(may_alias_ptr(&init_val__))); \
1292 if (chosen_bytes__ == sizeof(int32_t)) { \
1293 int32_t* val_ptr = reinterpret_cast<int32_t*>(val_ptr__); \
1294 const int32_t* other_ptr = reinterpret_cast<const int32_t*>(other_ptr__); \
1295 const auto null_val = static_cast<int32_t>(init_val__); \
1296 agg_##agg_kind__##_int32_skip_val(val_ptr, *other_ptr, null_val); \
1298 int64_t* val_ptr = reinterpret_cast<int64_t*>(val_ptr__); \
1299 const int64_t* other_ptr = reinterpret_cast<const int64_t*>(other_ptr__); \
1300 const auto null_val = static_cast<int64_t>(init_val__); \
1301 agg_##agg_kind__##_skip_val(val_ptr, *other_ptr, null_val); \
1305 AGGREGATE_ONE_VALUE( \
1306 agg_kind__, val_ptr__, other_ptr__, chosen_bytes__, agg_info__); \
1310 #define AGGREGATE_ONE_COUNT(val_ptr__, other_ptr__, chosen_bytes__) \
1312 if (chosen_bytes__ == sizeof(int32_t)) { \
1313 auto val_ptr = reinterpret_cast<int32_t*>(val_ptr__); \
1314 auto other_ptr = reinterpret_cast<const int32_t*>(other_ptr__); \
1315 agg_sum_int32(val_ptr, *other_ptr); \
1317 auto val_ptr = reinterpret_cast<int64_t*>(val_ptr__); \
1318 auto other_ptr = reinterpret_cast<const int64_t*>(other_ptr__); \
1319 agg_sum(val_ptr, *other_ptr); \
1323 #define AGGREGATE_ONE_NULLABLE_COUNT( \
1324 val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__) \
1326 if (agg_info__.skip_null_val) { \
1327 const auto sql_type = get_compact_type(agg_info__); \
1328 if (sql_type.is_fp()) { \
1329 if (chosen_bytes__ == sizeof(float)) { \
1330 agg_sum_float_skip_val( \
1331 reinterpret_cast<int32_t*>(val_ptr__), \
1332 *reinterpret_cast<const float*>(other_ptr__), \
1333 *reinterpret_cast<const float*>(may_alias_ptr(&init_val__))); \
1335 agg_sum_double_skip_val( \
1336 reinterpret_cast<int64_t*>(val_ptr__), \
1337 *reinterpret_cast<const double*>(other_ptr__), \
1338 *reinterpret_cast<const double*>(may_alias_ptr(&init_val__))); \
1341 if (chosen_bytes__ == sizeof(int32_t)) { \
1342 auto val_ptr = reinterpret_cast<int32_t*>(val_ptr__); \
1343 auto other_ptr = reinterpret_cast<const int32_t*>(other_ptr__); \
1344 const auto null_val = static_cast<int32_t>(init_val__); \
1345 agg_sum_int32_skip_val(val_ptr, *other_ptr, null_val); \
1347 auto val_ptr = reinterpret_cast<int64_t*>(val_ptr__); \
1348 auto other_ptr = reinterpret_cast<const int64_t*>(other_ptr__); \
1349 const auto null_val = static_cast<int64_t>(init_val__); \
1350 agg_sum_skip_val(val_ptr, *other_ptr, null_val); \
1354 AGGREGATE_ONE_COUNT(val_ptr__, other_ptr__, chosen_bytes__); \
1359 #define AGGREGATE_ONE_VALUE_SMALL( \
1360 agg_kind__, val_ptr__, other_ptr__, chosen_bytes__, agg_info__) \
1362 if (chosen_bytes__ == sizeof(int16_t)) { \
1363 auto val_ptr = reinterpret_cast<int16_t*>(val_ptr__); \
1364 auto other_ptr = reinterpret_cast<const int16_t*>(other_ptr__); \
1365 agg_##agg_kind__##_int16(val_ptr, *other_ptr); \
1366 } else if (chosen_bytes__ == sizeof(int8_t)) { \
1367 auto val_ptr = reinterpret_cast<int8_t*>(val_ptr__); \
1368 auto other_ptr = reinterpret_cast<const int8_t*>(other_ptr__); \
1369 agg_##agg_kind__##_int8(val_ptr, *other_ptr); \
1376 #define AGGREGATE_ONE_NULLABLE_VALUE_SMALL( \
1377 agg_kind__, val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__) \
1379 if (agg_info__.skip_null_val) { \
1380 if (chosen_bytes__ == sizeof(int16_t)) { \
1381 int16_t* val_ptr = reinterpret_cast<int16_t*>(val_ptr__); \
1382 const int16_t* other_ptr = reinterpret_cast<const int16_t*>(other_ptr__); \
1383 const auto null_val = static_cast<int16_t>(init_val__); \
1384 agg_##agg_kind__##_int16_skip_val(val_ptr, *other_ptr, null_val); \
1385 } else if (chosen_bytes == sizeof(int8_t)) { \
1386 int8_t* val_ptr = reinterpret_cast<int8_t*>(val_ptr__); \
1387 const int8_t* other_ptr = reinterpret_cast<const int8_t*>(other_ptr__); \
1388 const auto null_val = static_cast<int8_t>(init_val__); \
1389 agg_##agg_kind__##_int8_skip_val(val_ptr, *other_ptr, null_val); \
1392 AGGREGATE_ONE_VALUE_SMALL( \
1393 agg_kind__, val_ptr__, other_ptr__, chosen_bytes__, agg_info__); \
1398 const bool float_argument_input,
1400 if (float_argument_input) {
1401 return sizeof(float);
1408 const size_t target_slot_idx,
1409 const size_t init_agg_val_idx,
1410 const int8_t* that_ptr1)
const {
1416 auto reduce = [&](
auto const& size_tag) {
1417 using CastTarget = std::decay_t<decltype(size_tag)>;
1418 const auto lhs_proj_col = *
reinterpret_cast<const CastTarget*
>(this_ptr1);
1419 const auto rhs_proj_col = *
reinterpret_cast<const CastTarget*
>(that_ptr1);
1420 if (rhs_proj_col == init_val) {
1422 }
else if (lhs_proj_col == init_val) {
1423 *
reinterpret_cast<CastTarget*
>(this_ptr1) = rhs_proj_col;
1424 }
else if (lhs_proj_col != rhs_proj_col) {
1425 throw std::runtime_error(
"Multiple distinct values encountered");
1429 switch (chosen_bytes) {
1450 LOG(
FATAL) <<
"Invalid slot width: " << chosen_bytes;
1457 const int8_t* that_ptr1,
1458 const int8_t* that_ptr2,
1460 const size_t target_logical_idx,
1461 const size_t target_slot_idx,
1462 const size_t init_agg_val_idx,
1464 const size_t first_slot_idx_for_target,
1465 const std::vector<std::string>& serialized_varlen_buffer)
const {
1479 this_ptr1, target_info, target_logical_idx, init_agg_val_idx, that_ptr1);
1486 CHECK_EQ(static_cast<size_t>(chosen_bytes),
sizeof(int64_t));
1504 sum, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1508 if (static_cast<size_t>(chosen_bytes) <=
sizeof(int16_t)) {
1510 min, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1513 min, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1518 if (static_cast<size_t>(chosen_bytes) <=
sizeof(int16_t)) {
1520 max, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1523 max, this_ptr1, that_ptr1, init_val, chosen_bytes, target_info);
1528 CHECK_EQ(static_cast<int8_t>(
sizeof(int64_t)), chosen_bytes);
1535 switch (chosen_bytes) {
1538 const auto rhs_proj_col = *
reinterpret_cast<const int8_t*
>(that_ptr1);
1539 if (rhs_proj_col != init_val) {
1540 *
reinterpret_cast<int8_t*
>(this_ptr1) = rhs_proj_col;
1546 const auto rhs_proj_col = *
reinterpret_cast<const int16_t*
>(that_ptr1);
1547 if (rhs_proj_col != init_val) {
1548 *
reinterpret_cast<int16_t*
>(this_ptr1) = rhs_proj_col;
1555 const auto rhs_proj_col = *
reinterpret_cast<const int32_t*
>(that_ptr1);
1556 if (rhs_proj_col != init_val) {
1557 *
reinterpret_cast<int32_t*
>(this_ptr1) = rhs_proj_col;
1562 auto rhs_proj_col = *
reinterpret_cast<const int64_t*
>(that_ptr1);
1564 !serialized_varlen_buffer.empty()) {
1565 size_t length_to_elems{0};
1568 length_to_elems = target_slot_idx == first_slot_idx_for_target ? 1 : 4;
1574 CHECK_LT(static_cast<size_t>(rhs_proj_col), serialized_varlen_buffer.size());
1575 const auto& varlen_bytes_str = serialized_varlen_buffer[rhs_proj_col];
1576 const auto str_ptr =
reinterpret_cast<const int8_t*
>(varlen_bytes_str.c_str());
1577 *
reinterpret_cast<int64_t*
>(this_ptr1) =
1578 reinterpret_cast<const int64_t>(str_ptr);
1579 *
reinterpret_cast<int64_t*
>(this_ptr2) =
1580 static_cast<int64_t>(varlen_bytes_str.size() / length_to_elems);
1582 if (rhs_proj_col != init_val) {
1583 *
reinterpret_cast<int64_t*
>(this_ptr1) = rhs_proj_col;
1586 CHECK(this_ptr2 && that_ptr2);
1587 *
reinterpret_cast<int64_t*
>(this_ptr2) =
1588 *reinterpret_cast<const int64_t*>(that_ptr2);
1595 LOG(
FATAL) <<
"Invalid slot width: " << chosen_bytes;
1601 const int8_t* that_ptr1,
1602 const size_t target_logical_idx,
1607 CHECK(incoming) <<
"this_ptr1=" << (
void*)this_ptr1
1608 <<
", that_ptr1=" << (
void const*)that_ptr1
1609 <<
", target_logical_idx=" << target_logical_idx;
1610 if (incoming->centroids().capacity()) {
1612 CHECK(accumulator) <<
"this_ptr1=" << (
void*)this_ptr1
1613 <<
", that_ptr1=" << (
void const*)that_ptr1
1614 <<
", target_logical_idx=" << target_logical_idx;
1615 accumulator->allocate();
1616 accumulator->mergeTDigest(*incoming);
1621 const int8_t* that_ptr1,
1622 const size_t target_logical_idx,
1625 const auto& old_count_distinct_desc =
1628 const auto& new_count_distinct_desc =
1630 CHECK(old_count_distinct_desc.impl_type_ == new_count_distinct_desc.impl_type_);
1631 CHECK(this_ptr1 && that_ptr1);
1632 auto old_set_ptr =
reinterpret_cast<const int64_t*
>(this_ptr1);
1633 auto new_set_ptr =
reinterpret_cast<const int64_t*
>(that_ptr1);
1635 *new_set_ptr, *old_set_ptr, new_count_distinct_desc, old_count_distinct_desc);
1639 const int8_t warp_count,
1640 const bool is_columnar,
1641 const bool replace_bitmap_ptr_with_bitmap_sz,
1642 std::vector<int64_t>& agg_vals,
1644 const std::vector<TargetInfo>& targets,
1645 const std::vector<int64_t>& agg_init_vals) {
1646 const size_t agg_col_count{agg_vals.size()};
1647 const auto row_size = query_mem_desc.
getRowSize();
1649 CHECK_GE(agg_col_count, targets.size());
1652 std::vector<int64_t> partial_agg_vals(agg_col_count, 0);
1653 bool discard_row =
true;
1654 for (int8_t warp_idx = 0; warp_idx < warp_count; ++warp_idx) {
1655 bool discard_partial_result =
true;
1656 for (
size_t target_idx = 0, agg_col_idx = 0;
1657 target_idx < targets.size() && agg_col_idx < agg_col_count;
1658 ++target_idx, ++agg_col_idx) {
1659 const auto& agg_info = targets[target_idx];
1661 const auto chosen_bytes = float_argument_input
1666 partial_agg_vals[agg_col_idx] = partial_bin_val;
1669 CHECK(agg_info.is_agg &&
1674 if (replace_bitmap_ptr_with_bitmap_sz) {
1675 partial_agg_vals[agg_col_idx] = partial_bin_val;
1678 if (
kAVG == agg_info.agg_kind) {
1679 CHECK(agg_info.is_agg && !agg_info.is_distinct);
1681 partial_bin_val = partial_agg_vals[agg_col_idx] =
1687 CHECK(agg_info.is_agg);
1688 discard_partial_result =
false;
1691 row_ptr += row_size;
1692 if (discard_partial_result) {
1695 discard_row =
false;
1696 for (
size_t target_idx = 0, agg_col_idx = 0;
1697 target_idx < targets.size() && agg_col_idx < agg_col_count;
1698 ++target_idx, ++agg_col_idx) {
1699 auto partial_bin_val = partial_agg_vals[agg_col_idx];
1700 const auto& agg_info = targets[target_idx];
1702 const auto chosen_bytes = float_argument_input
1706 if (agg_info.is_agg && agg_info.agg_kind !=
kSAMPLE) {
1708 switch (agg_info.agg_kind) {
1713 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1714 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1715 agg_init_vals[agg_col_idx],
1723 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx + 1]),
1724 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx + 1]),
1731 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1732 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1733 agg_init_vals[agg_col_idx],
1738 if (static_cast<size_t>(chosen_bytes) <=
sizeof(int16_t)) {
1741 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1742 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1743 agg_init_vals[agg_col_idx],
1749 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1750 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1751 agg_init_vals[agg_col_idx],
1757 if (static_cast<size_t>(chosen_bytes) <=
sizeof(int16_t)) {
1760 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1761 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1762 agg_init_vals[agg_col_idx],
1768 reinterpret_cast<int8_t*>(&agg_vals[agg_col_idx]),
1769 reinterpret_cast<int8_t*>(&partial_agg_vals[agg_col_idx]),
1770 agg_init_vals[agg_col_idx],
1779 }
catch (std::runtime_error& e) {
1783 if (chosen_type.is_integer() || chosen_type.is_decimal()) {
1784 switch (chosen_bytes) {
1788 int32_t ret = *
reinterpret_cast<const int32_t*
>(&agg_vals[agg_col_idx]);
1789 if (!(shared::is_any<kCOUNT, kCOUNT_IF>(agg_info.agg_kind) &&
1790 ret != agg_init_vals[agg_col_idx])) {
1791 agg_vals[agg_col_idx] =
static_cast<int64_t
>(ret);
1799 if (
kAVG == agg_info.agg_kind) {
1803 if (agg_info.agg_kind ==
kSAMPLE) {
1804 CHECK(!agg_info.sql_type.is_varlen())
1805 <<
"Interleaved bins reduction not supported for variable length "
1809 if (agg_vals[agg_col_idx]) {
1810 if (agg_info.agg_kind ==
kSAMPLE) {
1813 CHECK_EQ(agg_vals[agg_col_idx], partial_bin_val);
1815 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
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
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
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
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)
ALWAYS_INLINE void check_watchdog_with_seed(const size_t sample_seed)
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 reduceOneApproxQuantileSlot(int8_t *this_ptr1, const int8_t *that_ptr1, const size_t target_logical_idx, const ResultSetStorage &that) 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)
bool g_enable_non_kernel_time_query_interrupt
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
size_t getColOnlyOffInBytes(const size_t col_idx) const
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
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
future< Result > async(Fn &&fn, Args &&...args)
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
ALWAYS_INLINE void check_watchdog()
std::pair< int64_t *, bool > GroupValueInfo
DEVICE auto accumulate(ARGS &&...args)
std::shared_ptr< ResultSet > getOwnResultSet()
void fillOneEntryColWise(const std::vector< int64_t > &entry)
bool is_distinct_target(const TargetInfo &target_info)
static EvalValue MakeEvalValue(const T &val)
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
RUNTIME_EXPORT 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)
std::string toString(const Executor::ExtModuleKinds &kind)
void reduce(const ResultSetStorage &that, const std::vector< std::string > &serialized_varlen_buffer, const ReductionCode &reduction_code, const size_t executor_id) const
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)
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
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 size_t executor_id) const
#define AGGREGATE_ONE_NULLABLE_VALUE(agg_kind__, val_ptr__, other_ptr__, init_val__, chosen_bytes__, agg_info__)
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
RUNTIME_EXPORT ALWAYS_INLINE DEVICE uint32_t key_hash(const int64_t *key, const uint32_t key_count, const uint32_t key_byte_width)
const ColSlotContext & getColSlotContext() const
static EvalValue run(const size_t execution_id, const Function *function, const std::vector< EvalValue > &inputs)
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)
void run_reduction_code(const size_t executor_id, 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)
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)
RUNTIME_EXPORT 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)
size_t get_key_bytes_rowwise(const QueryMemoryDescriptor &query_mem_desc)
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)
ResultSet * reduce(std::vector< ResultSet * > &, const size_t executor_id)
QueryMemoryDescriptor query_mem_desc_
int32_t getTargetIdxForKey() const
size_t getPrependedGroupColOffInBytes(const size_t group_idx) const