26 #include <unordered_map>
147 const size_t elem_count,
149 std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner);
155 const std::shared_ptr<HashJoin>& partitions,
156 const size_t elem_count,
158 std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner,
170 const std::vector<std::shared_ptr<Chunk_NS::Chunk>>& chunks_owner);
175 const int8_t* column,
176 const std::vector<std::shared_ptr<Chunk_NS::Chunk>>& chunks_owner);
187 std::unordered_map<QueryPlanHash, size_t>& sorted_partition_key_ref_count_map,
188 std::unordered_map<
QueryPlanHash, std::shared_ptr<std::vector<int64_t>>>&
189 sorted_partition_cache,
190 std::unordered_map<QueryPlanHash, AggregateTreeForWindowFraming>&
197 const int8_t*
output()
const;
246 const int32_t*
payload()
const;
248 const int32_t*
offsets()
const;
250 const int32_t*
counts()
const;
266 const int8_t* partition_values,
267 const int32_t* partition_indices,
268 const bool asc_ordering,
269 const bool nulls_first);
272 int64_t* output_for_partition_buff,
276 int64_t* output_for_partition_buff,
277 bool should_parallelize);
280 size_t partition_idx,
281 const int32_t* original_col_idx_buf,
282 const int64_t* ordered_col_idx_buf);
285 size_t partition_idx,
286 size_t partition_size,
287 const int32_t* original_rowid_buf,
288 const int64_t* ordered_rowid_buf,
315 std::vector<std::vector<std::shared_ptr<Chunk_NS::Chunk>>>
352 std::unique_ptr<WindowFunctionContext> window_function_context,
353 const size_t target_index);
361 const size_t target_index)
const;
377 static void reset(Executor* executor);
size_t getAggregateTreeFanout() const
Defines data structures for the semantic analysis phase of query processing.
std::vector< SumAndCountPair< double > * > derived_aggregate_tree_for_double_type_
void addOrderColumn(const int8_t *column, const SQLTypeInfo &ti, const std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner)
llvm::Value * num_elem_current_partition_lv
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
int64_t * ordered_partition_null_start_pos_
llvm::Value * current_col_value_lv
const int32_t dummy_count_
std::vector< double * > aggregate_tree_for_double_type_
int64_t * getNullValueEndPos() const
bool window_function_conditional_aggregate(const SqlWindowFunctionKind kind)
llvm::Value * current_partition_start_offset_lv
const int32_t dummy_offset_
static Comparator makeComparator(const Analyzer::ColumnVar *col_var, const int8_t *partition_values, const int32_t *partition_indices, const bool asc_ordering, const bool nulls_first)
llvm::Value * current_row_pos_lv
llvm::Value * target_partition_rowid_ptr_lv
const int8_t * partitionStart() const
llvm::Value * frame_end_bound_expr_lv
llvm::Value * num_elem_current_partition_lv
llvm::Value * nulls_first_lv
const std::vector< SQLTypeInfo > & getOrderKeyColumnBufferTypes() const
void setSortedPartitionCacheKey(QueryPlanHash cache_key)
void computeNullRangeOfSortedPartition(const SQLTypeInfo &order_col_ti, size_t partition_idx, const int32_t *original_col_idx_buf, const int64_t *ordered_col_idx_buf)
static WindowProjectNodeContext * create(Executor *executor)
size_t elementCount() const
const int8_t * output() const
const Analyzer::WindowFunction * window_func_
const int32_t * counts() const
Constants for Builtin SQL Types supported by HEAVY.AI.
const int32_t * offsets() const
llvm::Value * target_partition_sorted_rowid_ptr_lv
llvm::Value * target_partition_rowid_ptr_lv
static WindowFunctionContext * getActiveWindowFunctionContext(Executor *executor)
const bool needsToBuildAggregateTree() const
size_t * getAggregateTreeDepth() const
int64_t ** getAggregationTreesForIntegerTypeWindowExpr() const
const std::vector< const int8_t * > & getColumnBufferForWindowFunctionExpressions() const
int64_t * getNullValueStartPos() const
SumAndCountPair< double > ** getDerivedAggregationTreesForDoubleTypeWindowExpr() const
const int64_t * partitionStartOffset() const
std::vector< std::shared_ptr< void > > segment_trees_owned_
std::shared_ptr< std::vector< int64_t > > sorted_partition_buf_
size_t partitionCount() const
AggregateState aggregate_state_
llvm::Value * null_start_pos_lv
bool window_function_is_value(const SqlWindowFunctionKind kind)
size_t g_window_function_aggregation_tree_fanout
const int64_t * aggregateStateCount() const
std::vector< Comparator > createComparator(size_t partition_idx)
QueryPlanHash sorted_partition_cache_key_
const int8_t * partitionEnd() const
std::vector< std::vector< std::shared_ptr< Chunk_NS::Chunk > > > window_func_expr_columns_owner_
void addColumnBufferForWindowFunctionExpression(const int8_t *column, const std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner)
static void reset(Executor *executor)
const WindowFunctionContext * activateWindowFunctionContext(Executor *executor, const size_t target_index) const
size_t * aggregate_trees_depth_
QueryPlanHash partition_cache_key_
int64_t aggregateStatePendingOutputs() const
void buildAggregationTreeForPartition(SqlWindowFunctionKind agg_type, size_t partition_idx, size_t partition_size, const int32_t *original_rowid_buf, const int64_t *ordered_rowid_buf, const SQLTypeInfo &input_col_ti)
const int64_t * aggregateState() const
size_t aggregate_trees_fan_out_
std::function< bool(const PermutationIdx, const PermutationIdx)> Comparator
WindowFunctionContext & operator=(const WindowFunctionContext &)=delete
SumAndCountPair< int64_t > ** getDerivedAggregationTreesForIntegerTypeWindowExpr() const
void fillPartitionStart()
static const int NUM_EXECUTION_DEVICES
Executor(const ExecutorId id, Data_Namespace::DataMgr *data_mgr, const size_t block_size_x, const size_t grid_size_x, const size_t max_gpu_slab_size, const std::string &debug_dir, const std::string &debug_file)
llvm::Value * current_partition_start_offset_lv
bool window_function_is_aggregate(const SqlWindowFunctionKind kind)
void addWindowFunctionContext(std::unique_ptr< WindowFunctionContext > window_function_context, const size_t target_index)
llvm::Value * target_partition_sorted_rowid_ptr_lv
int8_t * partition_start_
std::vector< const int8_t * > window_func_expr_columns_
AggregateTreeForWindowFraming aggregate_trees_
void sortPartition(const size_t partition_idx, int64_t *output_for_partition_buff, bool should_parallelize)
WindowFunctionContext(const Analyzer::WindowFunction *window_func, const size_t elem_count, const ExecutorDeviceType device_type, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner)
const std::vector< const int8_t * > & getOrderKeyColumnBuffers() const
std::shared_ptr< HashJoin > partitions_
llvm::Value * null_end_pos_lv
void resizeStorageForWindowFraming(size_t partition_count)
const int64_t * partitionNumCountBuf() const
bool window_function_is_value_with_frame(const SqlWindowFunctionKind kind)
bool window_function_requires_peer_handling(const Analyzer::WindowFunction *window_func)
void resizeStorageForWindowFraming(bool const for_reuse=false)
std::unordered_map< size_t, std::unique_ptr< WindowFunctionContext > > window_contexts_
void computePartitionBuffer(const size_t partition_idx, int64_t *output_for_partition_buff, const Analyzer::WindowFunction *window_func)
llvm::Value * order_key_buf_ptr_lv
int64_t * partition_start_offset_
llvm::Value * int64_t_zero_val_lv
std::vector< const int8_t * > order_columns_
const int64_t * sortedPartition() const
const QueryPlanHash computeAggregateTreeCacheKey() const
static void resetWindowFunctionContext(Executor *executor)
std::vector< SQLTypeInfo > order_columns_ti_
std::vector< SumAndCountPair< int64_t > * > derived_aggregate_tree_for_integer_type_
const Analyzer::WindowFunction * getWindowFunction() const
const int32_t * payload() const
std::function< WindowFunctionContext::WindowComparatorResult(const int64_t lhs, const int64_t rhs)> Comparator
size_t * aggregate_trees_depth_
std::vector< std::vector< std::shared_ptr< Chunk_NS::Chunk > > > order_columns_owner_
llvm::Value * int64_t_one_val_lv
llvm::Value * frame_start_bound_expr_lv
std::vector< int64_t * > aggregate_tree_for_integer_type_
const ExecutorDeviceType device_type_
std::string order_type_col_name
void compute(std::unordered_map< QueryPlanHash, size_t > &sorted_partition_key_ref_count_map, std::unordered_map< QueryPlanHash, std::shared_ptr< std::vector< int64_t >>> &sorted_partition_cache, std::unordered_map< QueryPlanHash, AggregateTreeForWindowFraming > &aggregate_tree_map)
double ** getAggregationTreesForDoubleTypeWindowExpr() const
int64_t * ordered_partition_null_end_pos_
std::vector< void * > outputs