OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TargetExprBuilder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
23 #pragma once
24 
25 #include <Analyzer/Analyzer.h>
26 #include <Shared/TargetInfo.h>
27 
29 #include "GroupByAndAggregate.h"
30 
31 #include <vector>
32 
36  const int32_t base_slot_index,
37  const size_t target_idx,
38  const bool is_group_by)
39  : target_expr(target_expr)
40  , target_info(target_info)
41  , base_slot_index(base_slot_index)
42  , target_idx(target_idx)
43  , is_group_by(is_group_by) {}
44 
45  void codegen(GroupByAndAggregate* group_by_and_agg,
46  Executor* executor,
48  const CompilationOptions& co,
49  const GpuSharedMemoryContext& gpu_smem_context,
50  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
51  const std::vector<llvm::Value*>& agg_out_vec,
52  llvm::Value* output_buffer_byte_stream,
53  llvm::Value* out_row_idx,
54  GroupByAndAggregate::DiamondCodegen& diamond_codegen,
55  GroupByAndAggregate::DiamondCodegen* sample_cfg = nullptr) const;
56 
57  void codegenAggregate(GroupByAndAggregate* group_by_and_agg,
58  Executor* executor,
60  const CompilationOptions& co,
61  const std::vector<llvm::Value*>& target_lvs,
62  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
63  const std::vector<llvm::Value*>& agg_out_vec,
64  llvm::Value* output_buffer_byte_stream,
65  llvm::Value* out_row_idx,
66  int32_t slot_index) const;
67 
70 
71  int32_t base_slot_index;
72  size_t target_idx;
74 };
75 
79  const bool is_group_by)
80  : query_mem_desc(query_mem_desc)
81  , ra_exe_unit(ra_exe_unit)
82  , is_group_by(is_group_by) {}
83 
84  void operator()(const Analyzer::Expr* target_expr,
85  const Executor* executor,
86  const CompilationOptions& co);
87 
88  void codegen(GroupByAndAggregate* group_by_and_agg,
89  Executor* executor,
91  const CompilationOptions& co,
92  const GpuSharedMemoryContext& gpu_smem_context,
93  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
94  const std::vector<llvm::Value*>& agg_out_vec,
95  llvm::Value* output_buffer_byte_stream,
96  llvm::Value* out_row_idx,
97  GroupByAndAggregate::DiamondCodegen& diamond_codegen) const;
98 
100  GroupByAndAggregate* group_by_and_agg,
101  Executor* executor,
103  const CompilationOptions& co,
104  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
105  const std::vector<llvm::Value*>& agg_out_vec,
106  llvm::Value* output_buffer_byte_stream,
107  llvm::Value* out_row_idx,
108  GroupByAndAggregate::DiamondCodegen& diamond_codegen) const;
109 
111  GroupByAndAggregate* group_by_and_agg,
112  Executor* executor,
114  const CompilationOptions& co,
115  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
116  const std::vector<llvm::Value*>& agg_out_vec,
117  llvm::Value* output_buffer_byte_stream,
118  llvm::Value* out_row_idx,
119  GroupByAndAggregate::DiamondCodegen& diamond_codegen) const;
120 
122  GroupByAndAggregate* group_by_and_agg,
123  Executor* executor,
125  const CompilationOptions& co,
126  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
127  const std::vector<llvm::Value*>& agg_out_vec,
128  llvm::Value* output_buffer_byte_stream,
129  llvm::Value* out_row_idx,
130  GroupByAndAggregate::DiamondCodegen& diamond_codegen) const;
131 
132  llvm::Value* codegenSlotEmptyKey(llvm::Value* agg_col_ptr,
133  std::vector<llvm::Value*>& target_lvs,
134  Executor* executor,
135  const int64_t init_val) const;
136 
139 
142 
143  std::vector<TargetExprCodegen> target_exprs_to_codegen;
144  std::vector<TargetExprCodegen> sample_exprs_to_codegen;
145 
147 };
Defines data structures for the semantic analysis phase of query processing.
const RelAlgExecutionUnit & ra_exe_unit
void codegenAggregate(GroupByAndAggregate *group_by_and_agg, Executor *executor, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const std::vector< llvm::Value * > &target_lvs, const std::tuple< llvm::Value *, llvm::Value * > &agg_out_ptr_w_idx, const std::vector< llvm::Value * > &agg_out_vec, llvm::Value *output_buffer_byte_stream, llvm::Value *out_row_idx, int32_t slot_index) const
void codegenSampleExpressions(GroupByAndAggregate *group_by_and_agg, Executor *executor, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const std::tuple< llvm::Value *, llvm::Value * > &agg_out_ptr_w_idx, const std::vector< llvm::Value * > &agg_out_vec, llvm::Value *output_buffer_byte_stream, llvm::Value *out_row_idx, GroupByAndAggregate::DiamondCodegen &diamond_codegen) const
TargetExprCodegenBuilder(const QueryMemoryDescriptor &query_mem_desc, const RelAlgExecutionUnit &ra_exe_unit, const bool is_group_by)
void codegen(GroupByAndAggregate *group_by_and_agg, Executor *executor, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const GpuSharedMemoryContext &gpu_smem_context, const std::tuple< llvm::Value *, llvm::Value * > &agg_out_ptr_w_idx, const std::vector< llvm::Value * > &agg_out_vec, llvm::Value *output_buffer_byte_stream, llvm::Value *out_row_idx, GroupByAndAggregate::DiamondCodegen &diamond_codegen, GroupByAndAggregate::DiamondCodegen *sample_cfg=nullptr) const
void codegen(GroupByAndAggregate *group_by_and_agg, Executor *executor, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const GpuSharedMemoryContext &gpu_smem_context, const std::tuple< llvm::Value *, llvm::Value * > &agg_out_ptr_w_idx, const std::vector< llvm::Value * > &agg_out_vec, llvm::Value *output_buffer_byte_stream, llvm::Value *out_row_idx, GroupByAndAggregate::DiamondCodegen &diamond_codegen) const
std::vector< TargetExprCodegen > target_exprs_to_codegen
const QueryMemoryDescriptor & query_mem_desc
llvm::Value * codegenSlotEmptyKey(llvm::Value *agg_col_ptr, std::vector< llvm::Value * > &target_lvs, Executor *executor, const int64_t init_val) const
void codegenSingleSlotSampleExpression(GroupByAndAggregate *group_by_and_agg, Executor *executor, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const std::tuple< llvm::Value *, llvm::Value * > &agg_out_ptr_w_idx, const std::vector< llvm::Value * > &agg_out_vec, llvm::Value *output_buffer_byte_stream, llvm::Value *out_row_idx, GroupByAndAggregate::DiamondCodegen &diamond_codegen) const
std::vector< TargetExprCodegen > sample_exprs_to_codegen
const Analyzer::Expr * target_expr
Descriptor for the result set buffer layout.
void codegenMultiSlotSampleExpressions(GroupByAndAggregate *group_by_and_agg, Executor *executor, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, const std::tuple< llvm::Value *, llvm::Value * > &agg_out_ptr_w_idx, const std::vector< llvm::Value * > &agg_out_vec, llvm::Value *output_buffer_byte_stream, llvm::Value *out_row_idx, GroupByAndAggregate::DiamondCodegen &diamond_codegen) const
TargetExprCodegen(const Analyzer::Expr *target_expr, TargetInfo &target_info, const int32_t base_slot_index, const size_t target_idx, const bool is_group_by)
void operator()(const Analyzer::Expr *target_expr, const Executor *executor, const CompilationOptions &co)