OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  llvm::Value* varlen_output_buffer,
55  DiamondCodegen& diamond_codegen,
56  DiamondCodegen* sample_cfg = nullptr) const;
57 
58  void codegenAggregate(GroupByAndAggregate* group_by_and_agg,
59  Executor* executor,
61  const CompilationOptions& co,
62  const std::vector<llvm::Value*>& target_lvs,
63  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
64  const std::vector<llvm::Value*>& agg_out_vec,
65  llvm::Value* output_buffer_byte_stream,
66  llvm::Value* out_row_idx,
67  llvm::Value* varlen_output_buffer,
68  int32_t slot_index) const;
69 
72 
73  int32_t base_slot_index;
74  size_t target_idx;
76 };
77 
80  : ra_exe_unit(ra_exe_unit), is_group_by(is_group_by) {}
81 
82  void operator()(const Analyzer::Expr* target_expr,
83  const Executor* executor,
85  const CompilationOptions& co);
86 
87  void codegen(GroupByAndAggregate* group_by_and_agg,
88  Executor* executor,
90  const CompilationOptions& co,
91  const GpuSharedMemoryContext& gpu_smem_context,
92  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
93  const std::vector<llvm::Value*>& agg_out_vec,
94  llvm::Value* output_buffer_byte_stream,
95  llvm::Value* out_row_idx,
96  llvm::Value* varlen_output_buffer,
97  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  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  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  DiamondCodegen& diamond_codegen) const;
131 
132  llvm::Value* codegenSlotEmptyKey(llvm::Value* agg_col_ptr,
133  std::vector<llvm::Value*>& target_lvs,
134  Executor* executor,
136  const int64_t init_val) const;
137 
140 
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 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, llvm::Value *varlen_output_buffer, DiamondCodegen &diamond_codegen, DiamondCodegen *sample_cfg=nullptr) const
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, DiamondCodegen &diamond_codegen) const
std::vector< TargetExprCodegen > target_exprs_to_codegen
void operator()(const Analyzer::Expr *target_expr, const Executor *executor, QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co)
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, DiamondCodegen &diamond_codegen) const
std::vector< TargetExprCodegen > sample_exprs_to_codegen
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, llvm::Value *varlen_output_buffer, DiamondCodegen &diamond_codegen) const
TargetExprCodegenBuilder(const RelAlgExecutionUnit &ra_exe_unit, const bool is_group_by)
llvm::Value * codegenSlotEmptyKey(llvm::Value *agg_col_ptr, std::vector< llvm::Value * > &target_lvs, Executor *executor, const QueryMemoryDescriptor &query_mem_desc, const int64_t init_val) const
const Analyzer::Expr * target_expr
Descriptor for the result set buffer layout.
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 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, llvm::Value *varlen_output_buffer, int32_t slot_index) 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, DiamondCodegen &diamond_codegen) const