17 #ifndef COLUMNAR_RESULTS_H
18 #define COLUMNAR_RESULTS_H
22 #include "../Shared/checked_alloc.h"
25 #include <unordered_map>
31 "Columnar conversion not supported for variable length types") {}
43 :
bitmaps_(num_banks, std::vector<bool>(num_elements_per_bank,
false)) {}
45 inline bool get(
const size_t index,
const size_t bank_index)
const {
51 inline void set(
const size_t index,
const size_t bank_index,
const bool val) {
63 ColumnarResults(
const std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
64 const ResultSet&
rows,
65 const size_t num_columns,
66 const std::vector<SQLTypeInfo>& target_types,
67 const size_t executor_id,
68 const size_t thread_idx,
69 const bool is_parallel_execution_enforced =
false);
71 ColumnarResults(
const std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
72 const int8_t* one_col_buffer,
73 const size_t num_rows,
75 const size_t executor_id,
76 const size_t thread_idx);
79 const std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
80 const std::vector<std::unique_ptr<ColumnarResults>>& sub_results);
98 std::function<int64_t(const ResultSet&, const size_t, const size_t, const size_t)>;
115 const std::vector<SQLTypeInfo>& target_types,
116 const std::vector<size_t>& padded_target_sizes)
121 const size_t row_idx,
124 std::mutex* write_mutex =
nullptr);
127 const size_t num_columns);
136 const size_t num_columns);
139 const ResultSet& rows,
140 const size_t num_columns);
142 const ResultSet& rows,
143 const size_t num_columns);
147 std::vector<size_t>& non_empty_per_thread,
148 const size_t entry_count,
149 const size_t num_threads,
150 const size_t size_per_thread)
const;
153 const std::vector<size_t>& non_empty_per_thread,
154 const size_t num_columns,
155 const size_t entry_count,
156 const size_t num_threads,
157 const size_t size_per_thread);
159 const ResultSet& rows,
161 const std::vector<size_t>& non_empty_per_thread,
162 const std::vector<size_t>& global_offsets,
163 const std::vector<bool>& targets_to_skip,
164 const std::vector<size_t>& slot_idx_per_target_idx,
165 const size_t num_columns,
166 const size_t entry_count,
167 const size_t num_threads,
168 const size_t size_per_thread);
170 const ResultSet& rows,
172 const std::vector<size_t>& non_empty_per_thread,
173 const std::vector<size_t>& global_offsets,
174 const std::vector<size_t>& slot_idx_per_target_idx,
175 const size_t num_columns,
176 const size_t entry_count,
177 const size_t num_threads,
178 const size_t size_per_thread);
180 template <
typename DATA_TYPE>
182 const size_t input_buffer_entry_idx,
183 const size_t output_buffer_entry_idx,
184 const size_t target_idx,
185 const size_t slot_idx,
189 const ResultSet& rows,
190 const std::vector<bool>& targets_to_skip = {});
192 template <QueryDescriptionType QUERY_TYPE,
bool COLUMNAR_OUTPUT>
194 const ResultSet& rows,
195 const std::vector<size_t>& slot_idx_per_target_idx,
196 const std::vector<bool>& targets_to_skip = {});
198 std::tuple<std::vector<WriteFunction>, std::vector<ReadFunction>>
200 const std::vector<size_t>& slot_idx_per_target_idx,
201 const std::vector<bool>& targets_to_skip = {});
214 std::unordered_map<int, std::shared_ptr<const ColumnarResults>>>;
216 #endif // COLUMNAR_RESULTS_H
bool isParallelConversion() const
std::vector< int8_t * > column_buffers_
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)
std::vector< ReadFunction > initReadFunctions(const ResultSet &rows, const std::vector< size_t > &slot_idx_per_target_idx, const std::vector< bool > &targets_to_skip={})
ColumnarResults(const size_t num_rows, const std::vector< SQLTypeInfo > &target_types, const std::vector< size_t > &padded_target_sizes)
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
void set(const size_t index, const size_t bank_index, const bool val)
bool direct_columnar_conversion_
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)
std::function< int64_t(const ResultSet &, const size_t, const size_t, const size_t)> ReadFunction
std::function< void(const ResultSet &, const size_t, const size_t, const size_t, const size_t, const ReadFunction &)> WriteFunction
void materializeAllColumnsThroughIteration(const ResultSet &rows, const size_t num_columns)
const size_t size() const
ColumnarConversionNotSupported()
std::vector< WriteFunction > initWriteFunctions(const ResultSet &rows, const std::vector< bool > &targets_to_skip={})
void materializeAllColumnsGroupBy(const ResultSet &rows, const size_t num_columns)
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 isDirectColumnarConversionPossible() const
void materializeAllColumnsDirectly(const ResultSet &rows, const size_t num_columns)
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)
void writeBackCell(const TargetValue &col_val, const size_t row_idx, const SQLTypeInfo &type_info, int8_t *column_buf, std::mutex *write_mutex=nullptr)
ColumnBitmap(const size_t num_elements_per_bank, size_t num_banks)
std::unordered_map< shared::TableKey, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
std::shared_ptr< Executor > executor_
std::vector< size_t > padded_target_sizes_
void copyAllNonLazyColumns(const std::vector< ColumnLazyFetchInfo > &lazy_fetch_info, const ResultSet &rows, const size_t num_columns)
std::vector< std::vector< bool > > bitmaps_
bool g_enable_watchdog false
void materializeAllColumnsProjection(const ResultSet &rows, const size_t num_columns)
bool parallel_conversion_
Basic constructors and methods of the row set interface.
boost::variant< ScalarTargetValue, ArrayTargetValue, GeoTargetValue, GeoTargetValuePtr > TargetValue
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)
const std::vector< int8_t * > & getColumnBuffers() const
const std::vector< SQLTypeInfo > target_types_
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)
const SQLTypeInfo & getColumnType(const int col_id) const