28 #include <tbb/parallel_reduce.h>
49 const ResultSet&
rows,
50 const std::vector<SQLTypeInfo>& target_types) {
51 std::vector<size_t> padded_target_sizes;
56 if (!rows.hasValidBuffer() ||
57 rows.getQueryMemDesc().getColCount() < target_types.size()) {
58 for (
const auto& target_type : target_types) {
59 padded_target_sizes.emplace_back(target_type.get_size());
61 return padded_target_sizes;
65 const auto col_context = rows.getQueryMemDesc().getColSlotContext();
66 for (
size_t col_idx = 0; col_idx < target_types.size(); col_idx++) {
69 const auto idx = col_context.getSlotsForCol(col_idx).front();
70 const size_t padded_slot_width =
71 static_cast<size_t>(rows.getPaddedSlotWidthBytes(idx));
72 padded_target_sizes.emplace_back(
73 padded_slot_width == 0UL ? target_types[col_idx].get_size() : padded_slot_width);
75 return padded_target_sizes;
81 const auto array_col_val = boost::get<ArrayTargetValue>(&col_val);
83 const auto& vec = array_col_val->get();
86 for (
const auto& item : vec) {
87 offset +=
toBuffer(item, elem_type_info, buf + offset);
90 }
else if (type_info.
is_fp()) {
91 const auto scalar_col_val = boost::get<ScalarTargetValue>(&col_val);
94 auto float_p = boost::get<float>(scalar_col_val);
95 *((
float*)buf) =
static_cast<float>(*float_p);
99 auto double_p = boost::get<double>(scalar_col_val);
100 *((
double*)buf) =
static_cast<double>(*double_p);
107 const auto scalar_col_val = boost::get<ScalarTargetValue>(&col_val);
108 CHECK(scalar_col_val);
109 auto i64_p = boost::get<int64_t>(scalar_col_val);
113 *buf =
static_cast<int8_t
>(val);
116 *((int16_t*)buf) =
static_cast<int16_t
>(val);
119 *((int32_t*)buf) =
static_cast<int32_t
>(val);
122 *((int64_t*)buf) =
static_cast<int64_t
>(val);
149 const size_t column_idx) {
151 tbb::blocked_range<int64_t>(0, rows.entryCount()),
152 static_cast<int64_t>(0),
153 [&](tbb::blocked_range<int64_t> r, int64_t running_count) {
154 for (
int i = r.begin(); i < r.end(); ++i) {
155 const auto crt_row = rows.getRowAtNoTranslations(i);
156 if (crt_row.empty()) {
159 const auto arr_tv = boost::get<ArrayTargetValue>(&crt_row[column_idx]);
161 if (arr_tv->is_initialized()) {
162 const auto& vec = arr_tv->get();
163 running_count += vec.size();
166 return running_count;
168 std::plus<int64_t>());
171 template <
typename TargetValue,
typename TargetValuePtr>
174 const size_t column_idx) {
176 tbb::blocked_range<int64_t>(0, rows.entryCount()),
177 static_cast<int64_t>(0),
178 [&](tbb::blocked_range<int64_t> r, int64_t running_count) {
179 for (
int i = r.begin(); i < r.end(); ++i) {
180 const auto crt_row = rows.getRowAtNoTranslations(i);
181 if (crt_row.empty()) {
184 if (
const auto tv = boost::get<ScalarTargetValue>(&crt_row[column_idx])) {
185 const auto ns = boost::get<NullableString>(tv);
187 const auto s_ptr = boost::get<std::string>(ns);
193 running_count += std::count(s_ptr->begin(), s_ptr->end(),
',') + 1;
195 }
else if (
const auto tv =
196 boost::get<GeoTargetValuePtr>(&crt_row[column_idx])) {
197 const auto s = boost::get<TargetValuePtr>(tv);
207 }
else if (
const auto tv = boost::get<GeoTargetValue>(&crt_row[column_idx])) {
208 if (tv->get_ptr() !=
nullptr) {
209 const auto s = boost::get<TargetValue>(tv->get());
210 std::vector<double>* d = s.coords.get();
212 running_count += d->size();
218 return running_count;
220 std::plus<int64_t>());
224 const size_t column_idx) {
226 tbb::blocked_range<int64_t>(0, rows.entryCount()),
227 static_cast<int64_t>(0),
228 [&](tbb::blocked_range<int64_t> r, int64_t running_count) {
229 for (
int i = r.begin(); i < r.end(); ++i) {
233 const auto crt_row = rows.getRowAtNoTranslations(i);
234 if (crt_row.empty()) {
237 const auto col_val = crt_row[column_idx];
238 if (
const auto tv = boost::get<ScalarTargetValue>(&col_val)) {
239 const auto ns = boost::get<NullableString>(tv);
241 const auto s_ptr = boost::get<std::string>(ns);
243 running_count += s_ptr->size();
249 return running_count;
251 std::plus<int64_t>());
257 const ResultSet&
rows,
258 const size_t num_columns,
259 const std::vector<SQLTypeInfo>& target_types,
260 const size_t executor_id,
261 const size_t thread_idx,
262 const bool is_parallel_execution_enforced)
263 : column_buffers_(num_columns)
265 rows.isDirectColumnarConversionPossible()
268 , target_types_(target_types)
269 , parallel_conversion_(is_parallel_execution_enforced
272 , direct_columnar_conversion_(rows.isDirectColumnarConversionPossible())
281 for (
size_t i = 0; i < num_columns; ++i) {
282 const auto& src_ti = rows.getColType(i);
288 if (rows.isZeroCopyColumnarConversionPossible(i)) {
289 CHECK_EQ(ti.usesFlatBuffer(), src_ti.usesFlatBuffer());
295 CHECK(!(src_ti.usesFlatBuffer() && ti.usesFlatBuffer()));
301 if (src_ti.usesFlatBuffer() && ti.usesFlatBuffer()) {
306 }
else if (ti.usesFlatBuffer()) {
307 int64_t values_count = -1;
308 switch (ti.get_type()) {
311 throw std::runtime_error(
312 "Column<Array<TextEncodedNone>> support not implemented yet "
313 "(ColumnarResults)");
360 UNREACHABLE() <<
"computing number of values not implemented for "
372 if (ti.is_varlen()) {
390 const int8_t* one_col_buffer,
391 const size_t num_rows,
393 const size_t executor_id,
394 const size_t thread_idx)
396 , num_rows_(num_rows)
397 , target_types_{target_type}
398 , parallel_conversion_(
false)
399 , direct_columnar_conversion_(
false)
402 const bool is_varlen =
403 target_type.is_array() ||
404 (target_type.is_string() && target_type.get_compression() ==
kENCODING_NONE) ||
405 target_type.is_geometry();
410 padded_target_sizes_.emplace_back(target_type.get_size());
412 const auto buf_size = num_rows * target_type.get_size();
414 reinterpret_cast<int8_t*
>(row_set_mem_owner->allocate(buf_size,
thread_idx_));
415 memcpy(((
void*)column_buffers_[0]), one_col_buffer, buf_size);
419 std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
420 const std::vector<std::unique_ptr<ColumnarResults>>& sub_results) {
423 if (sub_results.empty()) {
430 [](
const size_t init,
const std::unique_ptr<ColumnarResults>&
result) {
431 return init +
result->size();
433 std::unique_ptr<ColumnarResults> merged_results(
437 const auto col_count = sub_results[0]->column_buffers_.size();
438 const auto nonempty_it = std::find_if(
441 [](
const std::unique_ptr<ColumnarResults>& needle) {
return needle->size(); });
442 if (nonempty_it == sub_results.end()) {
445 for (
size_t col_idx = 0; col_idx < col_count; ++col_idx) {
446 const auto byte_width = merged_results->padded_target_sizes_[col_idx];
447 auto write_ptr = row_set_mem_owner->allocate(byte_width * total_row_count);
448 merged_results->column_buffers_.push_back(write_ptr);
449 for (
auto& rs : sub_results) {
450 CHECK_EQ(col_count, rs->column_buffers_.size());
454 CHECK_EQ(byte_width, rs->padded_target_sizes_[col_idx]);
455 memcpy(write_ptr, rs->column_buffers_[col_idx], rs->size() * byte_width);
456 write_ptr += rs->size() * byte_width;
459 return merged_results;
467 const size_t num_columns) {
469 std::atomic<size_t> row_idx{0};
471 std::vector<std::future<void>> conversion_threads;
472 std::mutex write_mutex;
474 [num_columns, &
rows, &row_idx, &write_mutex,
this](
const size_t i) {
475 const auto crt_row = rows.getRowAtNoTranslations(i);
476 if (!crt_row.empty()) {
477 auto cur_row_idx = row_idx.fetch_add(1);
478 for (
size_t col_idx = 0; col_idx < num_columns; ++col_idx) {
488 for (
auto interval :
makeIntervals(
size_t(0), rows.entryCount(), worker_count)) {
491 [&do_work,
this](
const size_t start,
const size_t end) {
493 size_t local_idx = 0;
494 for (
size_t i = start; i < end; ++i, ++local_idx) {
495 if (
UNLIKELY((local_idx & 0xFFFF) == 0 &&
496 executor_->checkNonKernelTimeInterrupted())) {
502 for (
size_t i = start; i < end; ++i) {
512 for (
auto& child : conversion_threads) {
530 const auto do_work = [num_columns, &row_idx, &
rows, &done,
this]() {
531 const auto crt_row = rows.getNextRow(
false,
false);
532 if (crt_row.empty()) {
536 for (
size_t i = 0; i < num_columns; ++i) {
544 if (
UNLIKELY((row_idx & 0xFFFF) == 0 &&
545 executor_->checkNonKernelTimeInterrupted())) {
559 template <
size_t NDIM,
560 typename GeospatialGeoType,
561 typename GeoTypeTargetValue,
562 typename GeoTypeTargetValuePtr,
568 std::mutex* write_mutex) {
578 if (
const auto tv = boost::get<ScalarTargetValue>(&col_val)) {
579 const auto ns = boost::get<NullableString>(tv);
581 const auto s_ptr = boost::get<std::string>(ns);
582 if (s_ptr ==
nullptr || *s_ptr ==
"NULL") {
584 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
585 : std::unique_lock<std::mutex>(*write_mutex));
588 std::vector<double> coords;
589 std::vector<double> bounds;
590 std::vector<int32_t> ring_sizes;
591 std::vector<int32_t> poly_rings;
592 int64_t approx_nof_coords = 2 * std::count(s_ptr->begin(), s_ptr->end(),
',');
593 coords.reserve(approx_nof_coords);
595 const auto gdal_wkt_ls = GeospatialGeoType(*s_ptr);
596 if constexpr (NDIM == 1) {
597 gdal_wkt_ls.getColumns(coords, bounds);
598 }
else if constexpr (NDIM == 2) {
599 int64_t approx_nof_rings = std::count(s_ptr->begin(), s_ptr->end(),
'(') - 1;
600 ring_sizes.reserve(approx_nof_rings);
601 gdal_wkt_ls.getColumns(coords, ring_sizes, bounds);
602 }
else if constexpr (NDIM == 3) {
603 int64_t approx_nof_rings = std::count(s_ptr->begin(), s_ptr->end(),
'(') - 1;
604 ring_sizes.reserve(approx_nof_rings);
605 poly_rings.reserve(approx_nof_rings);
606 gdal_wkt_ls.getColumns(coords, ring_sizes, poly_rings, bounds);
610 const std::vector<uint8_t> compressed_coords =
614 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
615 : std::unique_lock<std::mutex>(*write_mutex));
616 if constexpr (NDIM == 1) {
617 status = m.
setItem(index, compressed_coords);
618 }
else if constexpr (NDIM == 2) {
619 status = m.
setItem(index, compressed_coords, ring_sizes);
620 }
else if constexpr (NDIM == 3) {
621 status = m.
setItem(index, compressed_coords, ring_sizes, poly_rings);
627 }
else if (
const auto tv = boost::get<GeoTargetValuePtr>(&col_val)) {
628 const auto s = boost::get<GeoTypeTargetValuePtr>(tv);
630 if (s->coords_data ==
nullptr || s->coords_data->pointer ==
nullptr) {
638 d->
length / (ti_lite->
is_geoint() ? 2 *
sizeof(int32_t) : 2 *
sizeof(
double));
641 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
642 : std::unique_lock<std::mutex>(*write_mutex));
643 if constexpr (NDIM == 1) {
645 }
else if constexpr (NDIM == 2) {
647 if constexpr (is_multi) {
648 r = s->linestring_sizes_data.get();
650 r = s->ring_sizes_data.get();
656 reinterpret_cast<const int32_t*
>(r->
pointer),
657 r->
length /
sizeof(int32_t));
658 }
else if constexpr (NDIM == 3) {
665 reinterpret_cast<const int32_t*
>(r->
pointer),
666 r->
length /
sizeof(int32_t),
667 reinterpret_cast<const int32_t*
>(p->
pointer),
668 p->
length /
sizeof(int32_t));
674 }
else if (
const auto tv = boost::get<GeoTargetValue>(&col_val)) {
675 if (tv->get_ptr() ==
nullptr) {
677 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
678 : std::unique_lock<std::mutex>(*write_mutex));
681 const auto s = boost::get<GeoTypeTargetValue>(tv->get());
682 const std::vector<double>* d = s.coords.get();
683 const std::vector<int32_t>* r =
nullptr;
684 const std::vector<int32_t>* p =
nullptr;
685 if constexpr (NDIM == 1) {
688 }
else if constexpr (NDIM == 2) {
689 if constexpr (is_multi) {
690 r = s.linestring_sizes.get();
692 r = s.ring_sizes.get();
695 }
else if constexpr (NDIM == 3) {
696 r = s.ring_sizes.get();
697 p = s.poly_rings.get();
706 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
707 : std::unique_lock<std::mutex>(*write_mutex));
708 if constexpr (NDIM == 1) {
709 status = m.
setItem(index, compressed_coords);
710 }
else if constexpr (NDIM == 2) {
711 status = m.
setItem(index, compressed_coords, *r);
712 }
else if constexpr (NDIM == 3) {
713 status = m.
setItem(index, compressed_coords, *r, *p);
722 CHECK_EQ(status, FlatBufferManager::Status::Success);
725 template <
typename scalar_type,
typename value_type>
727 const size_t row_idx,
729 std::mutex* write_mutex) {
731 const auto arr_tv = boost::get<ArrayTargetValue>(&col_val);
732 if (arr_tv->is_initialized()) {
733 const auto& vec = arr_tv->get();
737 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
738 : std::unique_lock<std::mutex>(*write_mutex));
739 status = m.
setItem<1,
false>(row_idx,
nullptr, vec.size());
741 CHECK_EQ(status, FlatBufferManager::Status::Success);
744 status = m.
getItem(row_idx, item);
745 CHECK_EQ(status, FlatBufferManager::Status::Success);
749 scalar_type* values =
reinterpret_cast<scalar_type*
>(item.
values);
752 const auto& scalar_val = boost::get<ScalarTargetValue>(&val);
753 values[index++] =
static_cast<scalar_type
>(*boost::get<value_type>(scalar_val));
759 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
760 : std::unique_lock<std::mutex>(*write_mutex));
763 CHECK_EQ(status, FlatBufferManager::Status::Success);
768 const size_t row_idx,
770 std::mutex* write_mutex) {
772 if (
const auto tv = boost::get<ScalarTargetValue>(&col_val)) {
773 const auto ns = boost::get<NullableString>(tv);
775 const auto s_ptr = boost::get<std::string>(ns);
778 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
779 : std::unique_lock<std::mutex>(*write_mutex));
781 status = m.
setItem(row_idx, *s_ptr);
786 CHECK_EQ(status, FlatBufferManager::Status::Success);
793 const size_t row_idx,
796 std::mutex* write_mutex) {
799 if (
const auto tv = boost::get<ScalarTargetValue>(&col_val)) {
800 const auto ns = boost::get<NullableString>(tv);
802 const auto s_ptr = boost::get<std::string>(ns);
803 std::vector<double> coords;
805 if (s_ptr ==
nullptr) {
810 gdal_wkt_pt.getColumns(coords);
816 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
817 : std::unique_lock<std::mutex>(*write_mutex));
819 row_idx, reinterpret_cast<const int8_t*>(data.data()), data.size());
821 CHECK_EQ(status, FlatBufferManager::Status::Success);
822 }
else if (
const auto tv = boost::get<GeoTargetValuePtr>(&col_val)) {
823 const auto s = boost::get<GeoPointTargetValuePtr>(tv);
828 m.getGeoPointMetadata()->is_geoint);
831 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
832 : std::unique_lock<std::mutex>(*write_mutex));
836 CHECK_EQ(status, FlatBufferManager::Status::Success);
837 }
else if (
const auto tv = boost::get<GeoTargetValue>(&col_val)) {
842 const auto s = boost::get<GeoPointTargetValue>(tv->get());
843 const std::vector<double>* d = s.coords.get();
847 (write_mutex ==
nullptr ? std::unique_lock<std::mutex>()
848 : std::unique_lock<std::mutex>(*write_mutex));
850 row_idx, reinterpret_cast<const int8_t*>(d->data()), m.
dtypeSize());
853 CHECK_EQ(status, FlatBufferManager::Status::Success);
870 const size_t row_idx,
873 std::mutex* write_mutex) {
890 throw std::runtime_error(
891 "Column<Array<TextEncodedNone>> support not implemented yet (writeBackCell)");
895 writeBackCellArrayScalar<double, double>(m, row_idx, col_val, write_mutex);
898 writeBackCellArrayScalar<float, float>(m, row_idx, col_val, write_mutex);
902 writeBackCellArrayScalar<int8_t, int64_t>(m, row_idx, col_val, write_mutex);
905 writeBackCellArrayScalar<int16_t, int64_t>(m, row_idx, col_val, write_mutex);
909 writeBackCellArrayScalar<int32_t, int64_t>(m, row_idx, col_val, write_mutex);
912 writeBackCellArrayScalar<int64_t, int64_t>(m, row_idx, col_val, write_mutex);
927 m, row_idx, type_info, col_val, write_mutex);
936 m, row_idx, type_info, col_val, write_mutex);
945 m, row_idx, type_info, col_val, write_mutex);
954 m, row_idx, type_info, col_val, write_mutex);
963 m, row_idx, type_info, col_val, write_mutex);
979 template <
typename DATA_TYPE>
981 const size_t input_buffer_entry_idx,
982 const size_t output_buffer_entry_idx,
983 const size_t target_idx,
984 const size_t slot_idx,
987 read_from_function(rows, input_buffer_entry_idx, target_idx, slot_idx),
989 reinterpret_cast<DATA_TYPE*
>(
column_buffers_[target_idx])[output_buffer_entry_idx] =
994 void ColumnarResults::writeBackCellDirect<float>(
const ResultSet&
rows,
995 const size_t input_buffer_entry_idx,
996 const size_t output_buffer_entry_idx,
997 const size_t target_idx,
998 const size_t slot_idx,
1000 const int32_t ival =
1001 read_from_function(rows, input_buffer_entry_idx, target_idx, slot_idx);
1002 const float fval = *
reinterpret_cast<const float*
>(may_alias_ptr(&ival));
1003 reinterpret_cast<float*
>(column_buffers_[target_idx])[output_buffer_entry_idx] = fval;
1007 void ColumnarResults::writeBackCellDirect<double>(
1008 const ResultSet&
rows,
1009 const size_t input_buffer_entry_idx,
1010 const size_t output_buffer_entry_idx,
1011 const size_t target_idx,
1012 const size_t slot_idx,
1014 const int64_t ival =
1015 read_from_function(rows, input_buffer_entry_idx, target_idx, slot_idx);
1016 const double dval = *
reinterpret_cast<const double*
>(may_alias_ptr(&ival));
1017 reinterpret_cast<double*
>(column_buffers_[target_idx])[output_buffer_entry_idx] = dval;
1030 const size_t num_columns) {
1032 switch (rows.getQueryDescriptionType()) {
1048 <<
"Direct columnar conversion for this query type is not supported yet.";
1060 const size_t num_columns) {
1061 CHECK(rows.query_mem_desc_.didOutputColumnar());
1063 (rows.query_mem_desc_.getQueryDescriptionType() ==
1066 const auto& lazy_fetch_info = rows.getLazyFetchInfo();
1076 const size_t num_columns) {
1077 CHECK(rows.query_mem_desc_.didOutputColumnar());
1079 (rows.query_mem_desc_.getQueryDescriptionType() ==
1082 const auto& lazy_fetch_info = rows.getLazyFetchInfo();
1084 for (
const auto& col_lazy_fetch_info : lazy_fetch_info) {
1085 CHECK(!col_lazy_fetch_info.is_lazily_fetched);
1098 const std::vector<ColumnLazyFetchInfo>& lazy_fetch_info,
1099 const ResultSet& rows,
1100 const size_t num_columns) {
1102 const auto is_column_non_lazily_fetched = [&lazy_fetch_info](
const size_t col_idx) {
1104 if (lazy_fetch_info.empty()) {
1107 return !lazy_fetch_info[col_idx].is_lazily_fetched;
1112 std::vector<std::future<void>> direct_copy_threads;
1113 for (
size_t col_idx = 0; col_idx < num_columns; col_idx++) {
1114 if (rows.isZeroCopyColumnarConversionPossible(col_idx)) {
1117 column_buffers_[col_idx] =
const_cast<int8_t*
>(rows.getColumnarBuffer(col_idx));
1118 }
else if (is_column_non_lazily_fetched(col_idx)) {
1119 CHECK(!(rows.query_mem_desc_.getQueryDescriptionType() ==
1121 if (rows.getColType(col_idx).usesFlatBuffer() &&
1130 [&rows,
this](
const size_t column_index) {
1131 size_t column_size = rows.getColumnarBufferSize(column_index);
1132 rows.copyColumnIntoBuffer(
1139 for (
auto& child : direct_copy_threads) {
1154 const std::vector<ColumnLazyFetchInfo>& lazy_fetch_info,
1155 const ResultSet& rows,
1156 const size_t num_columns) {
1158 CHECK(!(rows.query_mem_desc_.getQueryDescriptionType() ==
1160 std::mutex write_mutex;
1161 const auto do_work_just_lazy_columns = [num_columns, &
rows, &write_mutex,
this](
1162 const size_t row_idx,
1163 const std::vector<bool>& targets_to_skip) {
1164 const auto crt_row = rows.getRowAtNoTranslations(row_idx, targets_to_skip);
1165 for (
size_t i = 0; i < num_columns; ++i) {
1166 if (!targets_to_skip.empty() && !targets_to_skip[i]) {
1173 const auto contains_lazy_fetched_column =
1174 [](
const std::vector<ColumnLazyFetchInfo>& lazy_fetch_info) {
1175 for (
auto& col_info : lazy_fetch_info) {
1176 if (col_info.is_lazily_fetched) {
1184 const bool skip_non_lazy_columns = rows.isPermutationBufferEmpty();
1185 if (contains_lazy_fetched_column(lazy_fetch_info)) {
1186 const size_t worker_count =
1188 std::vector<std::future<void>> conversion_threads;
1189 std::vector<bool> targets_to_skip;
1190 if (skip_non_lazy_columns) {
1191 CHECK_EQ(lazy_fetch_info.size(), size_t(num_columns));
1192 targets_to_skip.reserve(num_columns);
1193 for (
size_t i = 0; i < num_columns; i++) {
1195 targets_to_skip.push_back(!lazy_fetch_info[i].is_lazily_fetched);
1198 for (
auto interval :
makeIntervals(
size_t(0), rows.entryCount(), worker_count)) {
1201 [&do_work_just_lazy_columns, &targets_to_skip,
this](
const size_t start,
1204 size_t local_idx = 0;
1205 for (
size_t i = start; i < end; ++i, ++local_idx) {
1206 if (
UNLIKELY((local_idx & 0xFFFF) == 0 &&
1207 executor_->checkNonKernelTimeInterrupted())) {
1210 do_work_just_lazy_columns(i, targets_to_skip);
1213 for (
size_t i = start; i < end; ++i) {
1214 do_work_just_lazy_columns(i, targets_to_skip);
1223 for (
auto& child : conversion_threads) {
1244 const size_t num_columns) {
1250 const size_t entry_count = rows.entryCount();
1251 const size_t size_per_thread = (entry_count + num_threads - 1) / num_threads;
1254 std::vector<size_t> non_empty_per_thread(num_threads,
1260 rows, bitmap, non_empty_per_thread, entry_count, num_threads, size_per_thread);
1266 non_empty_per_thread,
1280 std::vector<size_t>& non_empty_per_thread,
1281 const size_t entry_count,
1282 const size_t num_threads,
1283 const size_t size_per_thread)
const {
1287 CHECK_EQ(num_threads, non_empty_per_thread.size());
1288 auto do_work = [&
rows, &bitmap](
size_t& total_non_empty,
1289 const size_t local_idx,
1290 const size_t entry_idx,
1291 const size_t thread_idx) {
1292 if (!rows.isRowAtEmpty(entry_idx)) {
1294 bitmap.
set(local_idx, thread_idx,
true);
1297 auto locate_and_count_func =
1298 [&do_work, &non_empty_per_thread,
this](
1299 size_t start_index,
size_t end_index,
size_t thread_idx) {
1300 size_t total_non_empty = 0;
1301 size_t local_idx = 0;
1303 for (
size_t entry_idx = start_index; entry_idx < end_index;
1304 entry_idx++, local_idx++) {
1305 if (
UNLIKELY((local_idx & 0xFFFF) == 0 &&
1306 executor_->checkNonKernelTimeInterrupted())) {
1309 do_work(total_non_empty, local_idx, entry_idx, thread_idx);
1312 for (
size_t entry_idx = start_index; entry_idx < end_index;
1313 entry_idx++, local_idx++) {
1314 do_work(total_non_empty, local_idx, entry_idx, thread_idx);
1317 non_empty_per_thread[thread_idx] = total_non_empty;
1320 std::vector<std::future<void>> conversion_threads;
1321 for (
size_t thread_idx = 0; thread_idx < num_threads; thread_idx++) {
1322 const size_t start_entry = thread_idx * size_per_thread;
1323 const size_t end_entry = std::min(start_entry + size_per_thread, entry_count);
1329 for (
auto& child : conversion_threads) {
1352 const ResultSet& rows,
1354 const std::vector<size_t>& non_empty_per_thread,
1355 const size_t num_columns,
1356 const size_t entry_count,
1357 const size_t num_threads,
1358 const size_t size_per_thread) {
1362 CHECK_EQ(num_threads, non_empty_per_thread.size());
1365 std::vector<size_t> global_offsets(num_threads + 1, 0);
1367 non_empty_per_thread.end(),
1368 std::next(global_offsets.begin()));
1370 const auto slot_idx_per_target_idx = rows.getSlotIndicesForTargetIndices();
1371 const auto [single_slot_targets_to_skip, num_single_slot_targets] =
1372 rows.getSupportedSingleSlotTargetBitmap();
1376 if (num_single_slot_targets < num_columns) {
1379 non_empty_per_thread,
1381 single_slot_targets_to_skip,
1382 slot_idx_per_target_idx,
1390 non_empty_per_thread,
1392 slot_idx_per_target_idx,
1407 const ResultSet& rows,
1409 const std::vector<size_t>& non_empty_per_thread,
1410 const std::vector<size_t>& global_offsets,
1411 const std::vector<bool>& targets_to_skip,
1412 const std::vector<size_t>& slot_idx_per_target_idx,
1413 const size_t num_columns,
1414 const size_t entry_count,
1415 const size_t num_threads,
1416 const size_t size_per_thread) {
1421 const auto [write_functions, read_functions] =
1423 CHECK_EQ(write_functions.size(), num_columns);
1424 CHECK_EQ(read_functions.size(), num_columns);
1425 std::mutex write_mutex;
1426 auto do_work = [
this,
1429 &slot_idx_per_target_idx,
1434 &write_functions = write_functions,
1435 &read_functions = read_functions](
size_t& non_empty_idx,
1436 const size_t total_non_empty,
1437 const size_t local_idx,
1439 const size_t thread_idx,
1440 const size_t end_idx) {
1441 if (non_empty_idx >= total_non_empty) {
1443 entry_idx = end_idx;
1445 const size_t output_buffer_row_idx = global_offsets[thread_idx] + non_empty_idx;
1446 if (bitmap.
get(local_idx, thread_idx)) {
1448 const auto crt_row = rows.getRowAtNoTranslations(entry_idx, targets_to_skip);
1449 for (
size_t column_idx = 0; column_idx < num_columns; ++column_idx) {
1450 if (!targets_to_skip.empty() && !targets_to_skip[column_idx]) {
1453 output_buffer_row_idx,
1461 for (
size_t column_idx = 0; column_idx < num_columns; column_idx++) {
1462 if (!targets_to_skip.empty() && !targets_to_skip[column_idx]) {
1465 write_functions[column_idx](
rows,
1467 output_buffer_row_idx,
1469 slot_idx_per_target_idx[column_idx],
1470 read_functions[column_idx]);
1476 auto compact_buffer_func = [&non_empty_per_thread, &do_work,
this](
1477 const size_t start_index,
1478 const size_t end_index,
1479 const size_t thread_idx) {
1480 const size_t total_non_empty = non_empty_per_thread[thread_idx];
1481 size_t non_empty_idx = 0;
1482 size_t local_idx = 0;
1484 for (
size_t entry_idx = start_index; entry_idx < end_index;
1485 entry_idx++, local_idx++) {
1486 if (
UNLIKELY((local_idx & 0xFFFF) == 0 &&
1487 executor_->checkNonKernelTimeInterrupted())) {
1491 non_empty_idx, total_non_empty, local_idx, entry_idx, thread_idx, end_index);
1494 for (
size_t entry_idx = start_index; entry_idx < end_index;
1495 entry_idx++, local_idx++) {
1497 non_empty_idx, total_non_empty, local_idx, entry_idx, thread_idx, end_index);
1502 std::vector<std::future<void>> compaction_threads;
1503 for (
size_t thread_idx = 0; thread_idx < num_threads; thread_idx++) {
1504 const size_t start_entry = thread_idx * size_per_thread;
1505 const size_t end_entry = std::min(start_entry + size_per_thread, entry_count);
1511 for (
auto& child : compaction_threads) {
1531 const ResultSet& rows,
1533 const std::vector<size_t>& non_empty_per_thread,
1534 const std::vector<size_t>& global_offsets,
1535 const std::vector<size_t>& slot_idx_per_target_idx,
1536 const size_t num_columns,
1537 const size_t entry_count,
1538 const size_t num_threads,
1539 const size_t size_per_thread) {
1544 const auto [write_functions, read_functions] =
1546 CHECK_EQ(write_functions.size(), num_columns);
1547 CHECK_EQ(read_functions.size(), num_columns);
1548 auto do_work = [&
rows,
1552 &slot_idx_per_target_idx,
1553 &write_functions = write_functions,
1554 &read_functions = read_functions](
size_t& entry_idx,
1555 size_t& non_empty_idx,
1556 const size_t total_non_empty,
1557 const size_t local_idx,
1558 const size_t thread_idx,
1559 const size_t end_idx) {
1560 if (non_empty_idx >= total_non_empty) {
1562 entry_idx = end_idx;
1565 const size_t output_buffer_row_idx = global_offsets[thread_idx] + non_empty_idx;
1566 if (bitmap.get(local_idx, thread_idx)) {
1567 for (
size_t column_idx = 0; column_idx < num_columns; column_idx++) {
1568 write_functions[column_idx](
rows,
1570 output_buffer_row_idx,
1572 slot_idx_per_target_idx[column_idx],
1573 read_functions[column_idx]);
1578 auto compact_buffer_func = [&non_empty_per_thread, &do_work,
this](
1579 const size_t start_index,
1580 const size_t end_index,
1581 const size_t thread_idx) {
1582 const size_t total_non_empty = non_empty_per_thread[thread_idx];
1583 size_t non_empty_idx = 0;
1584 size_t local_idx = 0;
1586 for (
size_t entry_idx = start_index; entry_idx < end_index;
1587 entry_idx++, local_idx++) {
1588 if (
UNLIKELY((local_idx & 0xFFFF) == 0 &&
1589 executor_->checkNonKernelTimeInterrupted())) {
1593 entry_idx, non_empty_idx, total_non_empty, local_idx, thread_idx, end_index);
1596 for (
size_t entry_idx = start_index; entry_idx < end_index;
1597 entry_idx++, local_idx++) {
1599 entry_idx, non_empty_idx, total_non_empty, local_idx, thread_idx, end_index);
1604 std::vector<std::future<void>> compaction_threads;
1605 for (
size_t thread_idx = 0; thread_idx < num_threads; thread_idx++) {
1606 const size_t start_entry = thread_idx * size_per_thread;
1607 const size_t end_entry = std::min(start_entry + size_per_thread, entry_count);
1613 for (
auto& child : compaction_threads) {
1632 const ResultSet& rows,
1633 const std::vector<bool>& targets_to_skip) {
1638 std::vector<WriteFunction>
result;
1641 for (
size_t target_idx = 0; target_idx <
target_types_.size(); target_idx++) {
1642 if (!targets_to_skip.empty() && !targets_to_skip[target_idx]) {
1643 result.emplace_back([](
const ResultSet& rows,
1644 const size_t input_buffer_entry_idx,
1645 const size_t output_buffer_entry_idx,
1646 const size_t target_idx,
1647 const size_t slot_idx,
1649 UNREACHABLE() <<
"Invalid write back function used.";
1657 result.emplace_back(std::bind(&ColumnarResults::writeBackCellDirect<double>,
1659 std::placeholders::_1,
1660 std::placeholders::_2,
1661 std::placeholders::_3,
1662 std::placeholders::_4,
1663 std::placeholders::_5,
1664 std::placeholders::_6));
1667 result.emplace_back(std::bind(&ColumnarResults::writeBackCellDirect<float>,
1669 std::placeholders::_1,
1670 std::placeholders::_2,
1671 std::placeholders::_3,
1672 std::placeholders::_4,
1673 std::placeholders::_5,
1674 std::placeholders::_6));
1677 UNREACHABLE() <<
"Invalid target type encountered.";
1683 result.emplace_back(std::bind(&ColumnarResults::writeBackCellDirect<int64_t>,
1685 std::placeholders::_1,
1686 std::placeholders::_2,
1687 std::placeholders::_3,
1688 std::placeholders::_4,
1689 std::placeholders::_5,
1690 std::placeholders::_6));
1693 result.emplace_back(std::bind(&ColumnarResults::writeBackCellDirect<int32_t>,
1695 std::placeholders::_1,
1696 std::placeholders::_2,
1697 std::placeholders::_3,
1698 std::placeholders::_4,
1699 std::placeholders::_5,
1700 std::placeholders::_6));
1703 result.emplace_back(std::bind(&ColumnarResults::writeBackCellDirect<int16_t>,
1705 std::placeholders::_1,
1706 std::placeholders::_2,
1707 std::placeholders::_3,
1708 std::placeholders::_4,
1709 std::placeholders::_5,
1710 std::placeholders::_6));
1713 result.emplace_back(std::bind(&ColumnarResults::writeBackCellDirect<int8_t>,
1715 std::placeholders::_1,
1716 std::placeholders::_2,
1717 std::placeholders::_3,
1718 std::placeholders::_4,
1719 std::placeholders::_5,
1720 std::placeholders::_6));
1723 UNREACHABLE() <<
"Invalid target type encountered.";
1734 const size_t input_buffer_entry_idx,
1735 const size_t target_idx,
1736 const size_t slot_idx) {
1737 UNREACHABLE() <<
"Invalid read function used, target should have been skipped.";
1738 return static_cast<int64_t
>(0);
1741 template <QueryDescriptionType QUERY_TYPE,
bool COLUMNAR_OUTPUT>
1743 const size_t input_buffer_entry_idx,
1744 const size_t target_idx,
1745 const size_t slot_idx) {
1749 auto fval =
static_cast<float>(rows.getEntryAt<double, QUERY_TYPE, COLUMNAR_OUTPUT>(
1750 input_buffer_entry_idx, target_idx, slot_idx));
1751 return *
reinterpret_cast<int32_t*
>(may_alias_ptr(&fval));
1754 template <QueryDescriptionType QUERY_TYPE,
bool COLUMNAR_OUTPUT>
1756 const size_t input_buffer_entry_idx,
1757 const size_t target_idx,
1758 const size_t slot_idx) {
1759 return rows.getEntryAt<int64_t, QUERY_TYPE, COLUMNAR_OUTPUT>(
1760 input_buffer_entry_idx, target_idx, slot_idx);
1763 template <QueryDescriptionType QUERY_TYPE,
bool COLUMNAR_OUTPUT>
1765 const size_t input_buffer_entry_idx,
1766 const size_t target_idx,
1767 const size_t slot_idx) {
1768 return rows.getEntryAt<int32_t, QUERY_TYPE, COLUMNAR_OUTPUT>(
1769 input_buffer_entry_idx, target_idx, slot_idx);
1772 template <QueryDescriptionType QUERY_TYPE,
bool COLUMNAR_OUTPUT>
1774 const size_t input_buffer_entry_idx,
1775 const size_t target_idx,
1776 const size_t slot_idx) {
1777 return rows.getEntryAt<int16_t, QUERY_TYPE, COLUMNAR_OUTPUT>(
1778 input_buffer_entry_idx, target_idx, slot_idx);
1781 template <QueryDescriptionType QUERY_TYPE,
bool COLUMNAR_OUTPUT>
1783 const size_t input_buffer_entry_idx,
1784 const size_t target_idx,
1785 const size_t slot_idx) {
1786 return rows.getEntryAt<int8_t, QUERY_TYPE, COLUMNAR_OUTPUT>(
1787 input_buffer_entry_idx, target_idx, slot_idx);
1790 template <QueryDescriptionType QUERY_TYPE,
bool COLUMNAR_OUTPUT>
1792 const size_t input_buffer_entry_idx,
1793 const size_t target_idx,
1794 const size_t slot_idx) {
1795 auto fval = rows.getEntryAt<float, QUERY_TYPE, COLUMNAR_OUTPUT>(
1796 input_buffer_entry_idx, target_idx, slot_idx);
1797 return *
reinterpret_cast<int32_t*
>(may_alias_ptr(&fval));
1800 template <QueryDescriptionType QUERY_TYPE,
bool COLUMNAR_OUTPUT>
1802 const size_t input_buffer_entry_idx,
1803 const size_t target_idx,
1804 const size_t slot_idx) {
1805 auto dval = rows.getEntryAt<double, QUERY_TYPE, COLUMNAR_OUTPUT>(
1806 input_buffer_entry_idx, target_idx, slot_idx);
1807 return *
reinterpret_cast<int64_t*
>(may_alias_ptr(&dval));
1818 template <QueryDescriptionType QUERY_TYPE,
bool COLUMNAR_OUTPUT>
1820 const ResultSet& rows,
1821 const std::vector<size_t>& slot_idx_per_target_idx,
1822 const std::vector<bool>& targets_to_skip) {
1824 CHECK(COLUMNAR_OUTPUT == rows.didOutputColumnar());
1825 CHECK(QUERY_TYPE == rows.getQueryDescriptionType());
1827 std::vector<ReadFunction> read_functions;
1830 for (
size_t target_idx = 0; target_idx <
target_types_.size(); target_idx++) {
1831 if (!targets_to_skip.empty() && !targets_to_skip[target_idx]) {
1839 if (rows.getPaddedSlotWidthBytes(slot_idx_per_target_idx[target_idx]) == 0) {
1841 CHECK(rows.query_mem_desc_.getTargetGroupbyIndex(target_idx) >= 0);
1843 CHECK_EQ(
size_t(8), rows.query_mem_desc_.getEffectiveKeyWidth());
1846 read_functions.emplace_back(
1847 read_float_key_baseline<QUERY_TYPE, COLUMNAR_OUTPUT>);
1850 read_functions.emplace_back(read_double_func<QUERY_TYPE, COLUMNAR_OUTPUT>);
1854 <<
"Invalid data type encountered (BaselineHash, floating point key).";
1858 switch (rows.query_mem_desc_.getEffectiveKeyWidth()) {
1860 read_functions.emplace_back(read_int64_func<QUERY_TYPE, COLUMNAR_OUTPUT>);
1863 read_functions.emplace_back(read_int32_func<QUERY_TYPE, COLUMNAR_OUTPUT>);
1867 <<
"Invalid data type encountered (BaselineHash, integer key).";
1874 switch (rows.getPaddedSlotWidthBytes(slot_idx_per_target_idx[target_idx])) {
1876 read_functions.emplace_back(read_double_func<QUERY_TYPE, COLUMNAR_OUTPUT>);
1879 read_functions.emplace_back(read_float_func<QUERY_TYPE, COLUMNAR_OUTPUT>);
1882 UNREACHABLE() <<
"Invalid data type encountered (floating point agg column).";
1886 switch (rows.getPaddedSlotWidthBytes(slot_idx_per_target_idx[target_idx])) {
1888 read_functions.emplace_back(read_int64_func<QUERY_TYPE, COLUMNAR_OUTPUT>);
1891 read_functions.emplace_back(read_int32_func<QUERY_TYPE, COLUMNAR_OUTPUT>);
1894 read_functions.emplace_back(read_int16_func<QUERY_TYPE, COLUMNAR_OUTPUT>);
1897 read_functions.emplace_back(read_int8_func<QUERY_TYPE, COLUMNAR_OUTPUT>);
1900 UNREACHABLE() <<
"Invalid data type encountered (integer agg column).";
1905 return read_functions;
1915 std::tuple<std::vector<ColumnarResults::WriteFunction>,
1916 std::vector<ColumnarResults::ReadFunction>>
1918 const ResultSet& rows,
1919 const std::vector<size_t>& slot_idx_per_target_idx,
1920 const std::vector<bool>& targets_to_skip) {
1927 if (rows.didOutputColumnar()) {
1928 return std::make_tuple(
1929 std::move(write_functions),
1930 initReadFunctions<QueryDescriptionType::GroupByPerfectHash, true>(
1931 rows, slot_idx_per_target_idx, targets_to_skip));
1933 return std::make_tuple(
1934 std::move(write_functions),
1935 initReadFunctions<QueryDescriptionType::GroupByPerfectHash, false>(
1936 rows, slot_idx_per_target_idx, targets_to_skip));
1939 if (rows.didOutputColumnar()) {
1940 return std::make_tuple(
1941 std::move(write_functions),
1942 initReadFunctions<QueryDescriptionType::GroupByBaselineHash, true>(
1943 rows, slot_idx_per_target_idx, targets_to_skip));
1945 return std::make_tuple(
1946 std::move(write_functions),
1947 initReadFunctions<QueryDescriptionType::GroupByBaselineHash, false>(
1948 rows, slot_idx_per_target_idx, targets_to_skip));
bool isParallelConversion() const
HOST DEVICE SQLTypes get_subtype() const
int64_t read_int16_func(const ResultSet &rows, const size_t input_buffer_entry_idx, const size_t target_idx, const size_t slot_idx)
std::vector< int8_t * > column_buffers_
HOST DEVICE int get_size() const
HOST DEVICE int64_t dtypeSize() const
void writeBackCellGeoPoint(FlatBufferManager &m, const size_t row_idx, const SQLTypeInfo &type_info, const TargetValue &col_val, std::mutex *write_mutex)
void materializeAllColumnsTableFunction(const ResultSet &rows, const size_t num_columns)
static std::unique_ptr< ColumnarResults > mergeResults(const std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const std::vector< std::unique_ptr< ColumnarResults >> &sub_results)
void writeBackCellTextEncodingNone(FlatBufferManager &m, const size_t row_idx, const TargetValue &col_val, std::mutex *write_mutex)
std::vector< ReadFunction > initReadFunctions(const ResultSet &rows, const std::vector< size_t > &slot_idx_per_target_idx, const std::vector< bool > &targets_to_skip={})
void writeBackCellGeoNestedArray(FlatBufferManager &m, const int64_t index, const SQLTypeInfo &ti, const TargetValue &col_val, std::mutex *write_mutex)
void locateAndCountEntries(const ResultSet &rows, ColumnBitmap &bitmap, std::vector< size_t > &non_empty_per_thread, const size_t entry_count, const size_t num_threads, const size_t size_per_thread) const
std::vector< size_t > get_padded_target_sizes(const ResultSet &rows, const std::vector< SQLTypeInfo > &target_types)
int64_t read_double_func(const ResultSet &rows, const size_t input_buffer_entry_idx, const size_t target_idx, const size_t slot_idx)
SQLTypeInfo get_logical_type_info(const SQLTypeInfo &type_info)
int64_t computeTotalNofValuesForColumnTextEncodingNone(const ResultSet &rows, const size_t column_idx)
void initializeFlatBuffer(FlatBufferManager &m, int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
Constants for Builtin SQL Types supported by HEAVY.AI.
void set(const size_t index, const size_t bank_index, const bool val)
Intervals< T > makeIntervals(T begin, T end, std::size_t n_workers)
bool g_enable_non_kernel_time_query_interrupt
HOST DEVICE SQLTypes get_type() const
void writeBackCellArrayScalar(FlatBufferManager &m, const size_t row_idx, const TargetValue &col_val, std::mutex *write_mutex)
void compactAndCopyEntries(const ResultSet &rows, const ColumnBitmap &bitmap, const std::vector< size_t > &non_empty_per_thread, const size_t num_columns, const size_t entry_count, const size_t num_threads, const size_t size_per_thread)
HOST DEVICE Status getItem(const int64_t index, NestedArrayItem< NDIM > &result)
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
bool use_parallel_algorithms(const ResultSet &rows)
std::vector< uint8_t > compress_coords(const std::vector< double > &coords, const SQLTypeInfo &ti)
future< Result > async(Fn &&fn, Args &&...args)
std::function< int64_t(const ResultSet &, const size_t, const size_t, const size_t)> ReadFunction
void materializeAllColumnsThroughIteration(const ResultSet &rows, const size_t num_columns)
void init(LogOptions const &log_opts)
int64_t fixed_encoding_nullable_val(const int64_t val, const SQLTypeInfo &type_info)
std::vector< WriteFunction > initWriteFunctions(const ResultSet &rows, const std::vector< bool > &targets_to_skip={})
DEVICE void partial_sum(ARGS &&...args)
bool hasErrorCode(ErrorCode const ec) const
void materializeAllColumnsGroupBy(const ResultSet &rows, const size_t num_columns)
int64_t getFlatBufferSize(int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
DEVICE auto accumulate(ARGS &&...args)
HOST DEVICE Status setItem(const int64_t index, const int8_t *values_buf, const int32_t nof_values)
bool usesFlatBuffer() const
std::string toString() const
Status setItemOld(const int64_t index, const int8_t *src, const int64_t size, int8_t **dest=nullptr)
int64_t read_int32_func(const ResultSet &rows, const size_t input_buffer_entry_idx, const size_t target_idx, const size_t slot_idx)
std::tuple< std::vector< WriteFunction >, std::vector< ReadFunction > > initAllConversionFunctions(const ResultSet &rows, const std::vector< size_t > &slot_idx_per_target_idx, const std::vector< bool > &targets_to_skip={})
bool g_enable_smem_group_by true
int64_t computeTotalNofValuesForColumnArray(const ResultSet &rows, const size_t column_idx)
Value parallel_reduce(const blocked_range< Int > &range, const Value &identity, const RealBody &real_body, const Reduction &reduction, const Partitioner &p=Partitioner())
Parallel iteration with reduction.
int64_t computeTotalNofValuesForColumnGeoType(const ResultSet &rows, const SQLTypeInfo &ti, const size_t column_idx)
bool isDirectColumnarConversionPossible() const
int64_t read_int8_func(const ResultSet &rows, const size_t input_buffer_entry_idx, const size_t target_idx, const size_t slot_idx)
void materializeAllColumnsDirectly(const ResultSet &rows, const size_t num_columns)
HOST DEVICE EncodingType get_compression() const
void writeBackCellDirect(const ResultSet &rows, const size_t input_buffer_entry_idx, const size_t output_buffer_entry_idx, const size_t target_idx, const size_t slot_idx, const ReadFunction &read_function)
bool get(const size_t index, const size_t bank_index) const
void writeBackCell(const TargetValue &col_val, const size_t row_idx, const SQLTypeInfo &type_info, int8_t *column_buf, std::mutex *write_mutex=nullptr)
int64_t toBuffer(const TargetValue &col_val, const SQLTypeInfo &type_info, int8_t *buf)
std::shared_ptr< Executor > executor_
#define NULL_ARRAY_DOUBLE
std::vector< size_t > padded_target_sizes_
void copyAllNonLazyColumns(const std::vector< ColumnLazyFetchInfo > &lazy_fetch_info, const ResultSet &rows, const size_t num_columns)
#define DEBUG_TIMER(name)
int64_t read_float_key_baseline(const ResultSet &rows, const size_t input_buffer_entry_idx, const size_t target_idx, const size_t slot_idx)
void materializeAllColumnsProjection(const ResultSet &rows, const size_t num_columns)
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
int64_t read_float_func(const ResultSet &rows, const size_t input_buffer_entry_idx, const size_t target_idx, const size_t slot_idx)
boost::variant< ScalarTargetValue, ArrayTargetValue, GeoTargetValue, GeoTargetValuePtr > TargetValue
int64_t invalid_read_func(const ResultSet &rows, const size_t input_buffer_entry_idx, const size_t target_idx, const size_t slot_idx)
int64_t read_int64_func(const ResultSet &rows, const size_t input_buffer_entry_idx, const size_t target_idx, const size_t slot_idx)
void compactAndCopyEntriesWithTargetSkipping(const ResultSet &rows, const ColumnBitmap &bitmap, const std::vector< size_t > &non_empty_per_thread, const std::vector< size_t > &global_offsets, const std::vector< bool > &targets_to_skip, const std::vector< size_t > &slot_idx_per_target_idx, const size_t num_columns, const size_t entry_count, const size_t num_threads, const size_t size_per_thread)
void compactAndCopyEntriesWithoutTargetSkipping(const ResultSet &rows, const ColumnBitmap &bitmap, const std::vector< size_t > &non_empty_per_thread, const std::vector< size_t > &global_offsets, const std::vector< size_t > &slot_idx_per_target_idx, const size_t num_columns, const size_t entry_count, const size_t num_threads, const size_t size_per_thread)
bool is_text_encoding_none() const
HOST static DEVICE bool isFlatBuffer(const void *buffer)
const std::vector< SQLTypeInfo > target_types_
SQLTypeInfo get_elem_type() const
Divide up indexes (A, A+1, A+2, ..., B-2, B-1) among N workers as evenly as possible in a range-based...
void materializeAllLazyColumns(const std::vector< ColumnLazyFetchInfo > &lazy_fetch_info, const ResultSet &rows, const size_t num_columns)
ColumnarResults(const std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const ResultSet &rows, const size_t num_columns, const std::vector< SQLTypeInfo > &target_types, const size_t executor_id, const size_t thread_idx, const bool is_parallel_execution_enforced=false)
HOST DEVICE Status setNull(int64_t index)