OmniSciDB  b24e664e58
 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 std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
50  const std::vector<llvm::Value*>& agg_out_vec,
51  llvm::Value* output_buffer_byte_stream,
52  llvm::Value* out_row_idx,
53  GroupByAndAggregate::DiamondCodegen& diamond_codegen,
54  GroupByAndAggregate::DiamondCodegen* sample_cfg = nullptr) const;
55 
58 
59  int32_t base_slot_index;
60  size_t target_idx;
62 };
63 
67  const bool is_group_by)
68  : query_mem_desc(query_mem_desc)
69  , ra_exe_unit(ra_exe_unit)
70  , is_group_by(is_group_by) {}
71 
72  void operator()(const Analyzer::Expr* target_expr,
73  const Executor* executor,
74  const CompilationOptions& co);
75 
76  void codegen(GroupByAndAggregate* group_by_and_agg,
77  Executor* executor,
79  const CompilationOptions& co,
80  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
81  const std::vector<llvm::Value*>& agg_out_vec,
82  llvm::Value* output_buffer_byte_stream,
83  llvm::Value* out_row_idx,
84  GroupByAndAggregate::DiamondCodegen& diamond_codegen) const;
85 
87  GroupByAndAggregate* group_by_and_agg,
88  Executor* executor,
90  const CompilationOptions& co,
91  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
92  const std::vector<llvm::Value*>& agg_out_vec,
93  llvm::Value* output_buffer_byte_stream,
94  llvm::Value* out_row_idx,
95  GroupByAndAggregate::DiamondCodegen& diamond_codegen) const;
96 
98  GroupByAndAggregate* group_by_and_agg,
99  Executor* executor,
101  const CompilationOptions& co,
102  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
103  const std::vector<llvm::Value*>& agg_out_vec,
104  llvm::Value* output_buffer_byte_stream,
105  llvm::Value* out_row_idx,
106  GroupByAndAggregate::DiamondCodegen& diamond_codegen) const;
107 
109  GroupByAndAggregate* group_by_and_agg,
110  Executor* executor,
112  const CompilationOptions& co,
113  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
114  const std::vector<llvm::Value*>& agg_out_vec,
115  llvm::Value* output_buffer_byte_stream,
116  llvm::Value* out_row_idx,
117  GroupByAndAggregate::DiamondCodegen& diamond_codegen) const;
118 
119  llvm::Value* codegenSlotEmptyKey(llvm::Value* agg_col_ptr,
120  std::vector<llvm::Value*>& target_lvs,
121  Executor* executor,
122  const int64_t init_val) const;
123 
126 
129 
130  std::vector<TargetExprCodegen> target_exprs_to_codegen;
131  std::vector<TargetExprCodegen> sample_exprs_to_codegen;
132 
134 };
Defines data structures for the semantic analysis phase of query processing.
const RelAlgExecutionUnit & ra_exe_unit
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)
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
void codegen(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, GroupByAndAggregate::DiamondCodegen *sample_cfg=nullptr) const
void codegen(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)