25 #include "../BufferCompaction.h"
36 const std::vector<int64_t>& col_exprs_to_not_project) {
39 if (!col_exprs_to_not_project.empty()) {
40 CHECK_EQ(col_expr_list.size(), col_exprs_to_not_project.size());
42 size_t col_expr_idx = 0;
44 for (
const auto col_expr : col_expr_list) {
45 if (!col_exprs_to_not_project.empty() &&
46 col_exprs_to_not_project[col_expr_idx] != -1) {
58 if ((chosen_type.is_string() && chosen_type.get_compression() ==
kENCODING_NONE) ||
59 chosen_type.is_array()) {
65 if (chosen_type.is_geometry()) {
66 if (dynamic_cast<const Analyzer::GeoExpr*>(col_expr)) {
70 const int64_t arr_size =
73 .insert(std::make_pair(
slot_sizes_.size() - 1, arr_size))
76 for (
auto i = 0; i < chosen_type.get_physical_coord_cols(); ++i) {
87 CHECK_EQ(
size_t(0), col_expr_bitwidth % 8);
90 if (agg_info.agg_kind ==
kAVG) {
91 CHECK(agg_info.is_agg);
100 const SlotSize ss{slot_width_size, slot_width_size};
106 slot_size.padded_size = padded_size;
112 if (slot_size.padded_size < 0) {
113 slot_size.padded_size = padded_size;
120 slot_size.padded_size = slot_size.logical_size;
126 CHECK_GE(slot_size.logical_size, 0);
127 CHECK_LE(slot_size.logical_size, slot_size.padded_size);
142 [](
size_t sum,
const auto& slot_size) {
144 return sum +
static_cast<size_t>(slot_size.padded_size);
156 [](
size_t sum,
const auto& slot_size) {
158 const auto chosen_bytes =
159 static_cast<size_t>(slot_size.padded_size);
160 if (chosen_bytes ==
sizeof(int64_t)) {
163 return sum + chosen_bytes;
173 [entry_count](
size_t sum,
const auto& slot_size) {
176 align_to_int64(static_cast<size_t>(slot_size.padded_size) * entry_count);
183 return actual_min_byte_width;
185 const auto min_padded_size = std::min_element(
187 return lhs.padded_size < rhs.padded_size;
189 return std::min(min_padded_size->padded_size, actual_min_byte_width);
196 size_t compact_width{0};
198 if (slot_size.padded_size != 0) {
199 compact_width = slot_size.padded_size;
203 if (!compact_width) {
207 for (
const auto& slot_size : slot_sizes_) {
208 if (slot_size.padded_size == 0) {
211 CHECK_EQ(static_cast<size_t>(slot_size.padded_size), compact_width);
213 return compact_width;
219 if (
slot_sizes_[slot_idx].padded_size ==
sizeof(int64_t)) {
235 size_t total_bytes{0};
236 for (
size_t slot_idx = 0; slot_idx <
slot_sizes_.size(); slot_idx++) {
237 auto chosen_bytes =
slot_sizes_[slot_idx].padded_size;
238 if (chosen_bytes ==
sizeof(int64_t)) {
240 CHECK_GE(aligned_total_bytes, total_bytes);
242 const auto padding = aligned_total_bytes - total_bytes;
243 CHECK(padding == 0 || padding == 4);
246 total_bytes = aligned_total_bytes;
248 total_bytes += chosen_bytes;
252 CHECK_GE(aligned_total_bytes, total_bytes);
253 const auto padding = aligned_total_bytes - total_bytes;
254 CHECK(padding == 0 || padding == 4);
260 const std::vector<std::tuple<int8_t, int8_t>>& slots_for_col) {
263 for (
const auto& slot_info : slots_for_col) {
279 throw std::runtime_error(
"Failed to find FlatBuffer map entry for slot " +
282 return varlen_map_it->second;
290 return slot_size.padded_size == 0 &&
291 slot_size.logical_size == 0;
297 const size_t column_idx) {
302 const int8_t logical_size,
303 const size_t column_idx) {
312 throw std::runtime_error(
"Failed to find varlen map entry for slot " +
315 return varlen_map_it->second;
Defines data structures for the semantic analysis phase of query processing.
int8_t getMinPaddedByteSize(const int8_t actual_min_byte_width) const
void alignPaddedSlots(const bool sort_on_gpu)
void sort_on_gpu(int64_t *val_buff, int32_t *idx_buff, const uint64_t entry_count, const bool desc, const uint32_t chosen_bytes, ThrustAllocator &alloc, const int device_id)
std::unordered_map< SlotIndex, ArraySize > varlen_output_slot_map_
size_t getAllSlotsPaddedSize() const
size_t getAllSlotsAlignedPaddedSize() const
std::vector< std::vector< size_t > > col_to_slot_map_
std::vector< SlotSize > slot_sizes_
void setAllSlotsSize(const int8_t slot_width_size)
TargetInfo get_target_info(const Analyzer::Expr *target_expr, const bool bigint_count)
size_t getColOnlyOffInBytes(const size_t slot_idx) const
const SQLTypeInfo get_compact_type(const TargetInfo &target)
size_t get_bit_width(const SQLTypeInfo &ti)
DEVICE void fill(ARGS &&...args)
void addColumnFlatBuffer(const int64_t flatbuffer_size)
size_t getCompactByteWidth() const
Provides column info and slot info for the output buffer and some metadata helpers.
size_t getAlignedPaddedSizeForRange(const size_t end) const
DEVICE auto accumulate(ARGS &&...args)
int64_t varlenOutputElementSize(const size_t slot_idx) const
void addColumn(const std::vector< std::tuple< int8_t, int8_t >> &slots_for_col)
void setAllSlotsPaddedSize(const int8_t padded_size)
bool checkSlotUsesFlatBufferFormat(const size_t slot_idx) const
size_t getTotalBytesOfColumnarBuffers(const size_t entry_count) const
void addSlotForColumn(const int8_t logical_size, const size_t column_idx)
size_t getSlotCount() const
void setAllSlotsPaddedSizeToLogicalSize()
size_t getColCount() const
void setAllUnsetSlotsPaddedSize(const int8_t padded_size)
int64_t getFlatBufferSize(const size_t slot_idx) const
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)