OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TargetExprBuilder.cpp
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 #include "TargetExprBuilder.h"
24 
25 #include "CodeGenerator.h"
26 #include "Execute.h"
27 #include "GroupByAndAggregate.h"
28 #include "Logger/Logger.h"
29 #include "MaxwellCodegenPatch.h"
31 
32 #define LL_CONTEXT executor->cgen_state_->context_
33 #define LL_BUILDER executor->cgen_state_->ir_builder_
34 #define LL_BOOL(v) executor->ll_bool(v)
35 #define LL_INT(v) executor->cgen_state_->llInt(v)
36 #define LL_FP(v) executor->cgen_state_->llFp(v)
37 #define ROW_FUNC executor->cgen_state_->row_func_
38 
39 namespace {
40 
41 inline bool is_varlen_projection(const Analyzer::Expr* target_expr,
42  const SQLTypeInfo& ti) {
43  return dynamic_cast<const Analyzer::GeoExpr*>(target_expr) && ti.get_type() == kPOINT;
44 }
45 
46 std::vector<std::string> agg_fn_base_names(const TargetInfo& target_info,
47  const bool is_varlen_projection) {
48  const auto& chosen_type = get_compact_type(target_info);
49  if (is_varlen_projection) {
50  // TODO: support other types here
51  CHECK(chosen_type.is_geometry());
52  return {"agg_id_varlen"};
53  }
54  if (!target_info.is_agg || target_info.agg_kind == kSAMPLE) {
55  if (chosen_type.is_geometry()) {
56  return std::vector<std::string>(2 * chosen_type.get_physical_coord_cols(),
57  "agg_id");
58  }
59  if (chosen_type.is_varlen()) {
60  // not a varlen projection (not creating new varlen outputs). Just store the pointer
61  // and offset into the input buffer in the output slots.
62  return {"agg_id", "agg_id"};
63  }
64  return {"agg_id"};
65  }
66  switch (target_info.agg_kind) {
67  case kAVG:
68  return {"agg_sum", "agg_count"};
69  case kCOUNT:
70  return {target_info.is_distinct ? "agg_count_distinct" : "agg_count"};
71  case kMAX:
72  return {"agg_max"};
73  case kMIN:
74  return {"agg_min"};
75  case kSUM:
76  return {"agg_sum"};
78  return {"agg_approximate_count_distinct"};
79  case kAPPROX_QUANTILE:
80  return {"agg_approx_quantile"};
81  case kSINGLE_VALUE:
82  return {"checked_single_agg_id"};
83  case kSAMPLE:
84  return {"agg_id"};
85  default:
86  UNREACHABLE() << "Unrecognized agg kind: " << std::to_string(target_info.agg_kind);
87  }
88  return {};
89 }
90 
92  return query_mem_desc.getQueryDescriptionType() == QueryDescriptionType::Projection &&
93  query_mem_desc.didOutputColumnar();
94 }
95 
96 bool is_simple_count(const TargetInfo& target_info) {
97  return target_info.is_agg && target_info.agg_kind == kCOUNT && !target_info.is_distinct;
98 }
99 
100 bool target_has_geo(const TargetInfo& target_info) {
101  return target_info.is_agg ? target_info.agg_arg_type.is_geometry()
102  : target_info.sql_type.is_geometry();
103 }
104 
105 } // namespace
106 
108  GroupByAndAggregate* group_by_and_agg,
109  Executor* executor,
111  const CompilationOptions& co,
112  const GpuSharedMemoryContext& gpu_smem_context,
113  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx_in,
114  const std::vector<llvm::Value*>& agg_out_vec,
115  llvm::Value* output_buffer_byte_stream,
116  llvm::Value* out_row_idx,
117  llvm::Value* varlen_output_buffer,
118  DiamondCodegen& diamond_codegen,
119  DiamondCodegen* sample_cfg) const {
120  CHECK(group_by_and_agg);
121  CHECK(executor);
122  AUTOMATIC_IR_METADATA(executor->cgen_state_.get());
123 
124  auto agg_out_ptr_w_idx = agg_out_ptr_w_idx_in;
125  const auto arg_expr = agg_arg(target_expr);
126 
127  const bool varlen_projection = is_varlen_projection(target_expr, target_info.sql_type);
128  const auto agg_fn_names = agg_fn_base_names(target_info, varlen_projection);
129  const auto window_func = dynamic_cast<const Analyzer::WindowFunction*>(target_expr);
131  auto target_lvs =
132  window_func
133  ? std::vector<llvm::Value*>{executor->codegenWindowFunction(target_idx, co)}
134  : group_by_and_agg->codegenAggArg(target_expr, co);
135  const auto window_row_ptr = window_func
136  ? group_by_and_agg->codegenWindowRowPointer(
137  window_func, query_mem_desc, co, diamond_codegen)
138  : nullptr;
139  if (window_row_ptr) {
140  agg_out_ptr_w_idx =
141  std::make_tuple(window_row_ptr, std::get<1>(agg_out_ptr_w_idx_in));
142  if (window_function_is_aggregate(window_func->getKind())) {
143  out_row_idx = window_row_ptr;
144  }
145  }
146 
147  llvm::Value* str_target_lv{nullptr};
148  if (target_lvs.size() == 3 && !target_has_geo(target_info)) {
149  // none encoding string, pop the packed pointer + length since
150  // it's only useful for IS NULL checks and assumed to be only
151  // two components (pointer and length) for the purpose of projection
152  str_target_lv = target_lvs.front();
153  target_lvs.erase(target_lvs.begin());
154  }
155  if (target_info.sql_type.is_geometry() && !varlen_projection) {
156  // Geo cols are expanded to the physical coord cols. Each physical coord col is an
157  // array. Ensure that the target values generated match the number of agg
158  // functions before continuing
159  if (target_lvs.size() < agg_fn_names.size()) {
160  CHECK_EQ(target_lvs.size(), agg_fn_names.size() / 2);
161  std::vector<llvm::Value*> new_target_lvs;
162  new_target_lvs.reserve(agg_fn_names.size());
163  for (const auto& target_lv : target_lvs) {
164  new_target_lvs.push_back(target_lv);
165  new_target_lvs.push_back(target_lv);
166  }
167  target_lvs = new_target_lvs;
168  }
169  }
170  if (target_lvs.size() < agg_fn_names.size()) {
171  CHECK_EQ(size_t(1), target_lvs.size());
172  CHECK_EQ(size_t(2), agg_fn_names.size());
173  for (size_t i = 1; i < agg_fn_names.size(); ++i) {
174  target_lvs.push_back(target_lvs.front());
175  }
176  } else {
178  if (!target_info.is_agg && !varlen_projection) {
179  CHECK_EQ(static_cast<size_t>(2 * target_info.sql_type.get_physical_coord_cols()),
180  target_lvs.size());
181  CHECK_EQ(agg_fn_names.size(), target_lvs.size());
182  }
183  } else {
184  CHECK(str_target_lv || (agg_fn_names.size() == target_lvs.size()));
185  CHECK(target_lvs.size() == 1 || target_lvs.size() == 2);
186  }
187  }
188 
189  int32_t slot_index = base_slot_index;
190  CHECK_GE(slot_index, 0);
191  CHECK(is_group_by || static_cast<size_t>(slot_index) < agg_out_vec.size());
192 
193  uint32_t col_off{0};
194  if (co.device_type == ExecutorDeviceType::GPU && query_mem_desc.threadsShareMemory() &&
196  (!arg_expr || arg_expr->get_type_info().get_notnull())) {
197  CHECK_EQ(size_t(1), agg_fn_names.size());
198  const auto chosen_bytes = query_mem_desc.getPaddedSlotWidthBytes(slot_index);
199  llvm::Value* agg_col_ptr{nullptr};
200  if (is_group_by) {
201  if (query_mem_desc.didOutputColumnar()) {
202  col_off = query_mem_desc.getColOffInBytes(slot_index);
203  CHECK_EQ(size_t(0), col_off % chosen_bytes);
204  col_off /= chosen_bytes;
205  CHECK(std::get<1>(agg_out_ptr_w_idx));
206  auto offset =
207  LL_BUILDER.CreateAdd(std::get<1>(agg_out_ptr_w_idx), LL_INT(col_off));
208  agg_col_ptr = LL_BUILDER.CreateGEP(
209  LL_BUILDER.CreateBitCast(
210  std::get<0>(agg_out_ptr_w_idx),
211  llvm::PointerType::get(get_int_type((chosen_bytes << 3), LL_CONTEXT), 0)),
212  offset);
213  } else {
214  col_off = query_mem_desc.getColOnlyOffInBytes(slot_index);
215  CHECK_EQ(size_t(0), col_off % chosen_bytes);
216  col_off /= chosen_bytes;
217  agg_col_ptr = LL_BUILDER.CreateGEP(
218  LL_BUILDER.CreateBitCast(
219  std::get<0>(agg_out_ptr_w_idx),
220  llvm::PointerType::get(get_int_type((chosen_bytes << 3), LL_CONTEXT), 0)),
221  LL_INT(col_off));
222  }
223  }
224 
225  if (chosen_bytes != sizeof(int32_t)) {
226  CHECK_EQ(8, chosen_bytes);
227  if (g_bigint_count) {
228  const auto acc_i64 = LL_BUILDER.CreateBitCast(
229  is_group_by ? agg_col_ptr : agg_out_vec[slot_index],
230  llvm::PointerType::get(get_int_type(64, LL_CONTEXT), 0));
231  if (gpu_smem_context.isSharedMemoryUsed()) {
232  group_by_and_agg->emitCall(
233  "agg_count_shared", std::vector<llvm::Value*>{acc_i64, LL_INT(int64_t(1))});
234  } else {
235  LL_BUILDER.CreateAtomicRMW(llvm::AtomicRMWInst::Add,
236  acc_i64,
237  LL_INT(int64_t(1)),
238 #if LLVM_VERSION_MAJOR > 12
239  LLVM_ALIGN(8),
240 #endif
241  llvm::AtomicOrdering::Monotonic);
242  }
243  } else {
244  auto acc_i32 = LL_BUILDER.CreateBitCast(
245  is_group_by ? agg_col_ptr : agg_out_vec[slot_index],
246  llvm::PointerType::get(get_int_type(32, LL_CONTEXT), 0));
247  if (gpu_smem_context.isSharedMemoryUsed()) {
248  acc_i32 = LL_BUILDER.CreatePointerCast(
249  acc_i32, llvm::Type::getInt32PtrTy(LL_CONTEXT, 3));
250  }
251  LL_BUILDER.CreateAtomicRMW(llvm::AtomicRMWInst::Add,
252  acc_i32,
253  LL_INT(1),
254 #if LLVM_VERSION_MAJOR > 12
255  LLVM_ALIGN(4),
256 #endif
257  llvm::AtomicOrdering::Monotonic);
258  }
259  } else {
260  const auto acc_i32 = (is_group_by ? agg_col_ptr : agg_out_vec[slot_index]);
261  if (gpu_smem_context.isSharedMemoryUsed()) {
262  // Atomic operation on address space level 3 (Shared):
263  const auto shared_acc_i32 = LL_BUILDER.CreatePointerCast(
264  acc_i32, llvm::Type::getInt32PtrTy(LL_CONTEXT, 3));
265  LL_BUILDER.CreateAtomicRMW(llvm::AtomicRMWInst::Add,
266  shared_acc_i32,
267  LL_INT(1),
268 #if LLVM_VERSION_MAJOR > 12
269  LLVM_ALIGN(4),
270 #endif
271  llvm::AtomicOrdering::Monotonic);
272  } else {
273  LL_BUILDER.CreateAtomicRMW(llvm::AtomicRMWInst::Add,
274  acc_i32,
275  LL_INT(1),
276 #if LLVM_VERSION_MAJOR > 12
277  LLVM_ALIGN(4),
278 #endif
279  llvm::AtomicOrdering::Monotonic);
280  }
281  }
282  return;
283  }
284 
285  codegenAggregate(group_by_and_agg,
286  executor,
287  query_mem_desc,
288  co,
289  target_lvs,
290  agg_out_ptr_w_idx,
291  agg_out_vec,
292  output_buffer_byte_stream,
293  out_row_idx,
294  varlen_output_buffer,
295  slot_index);
296 }
297 
299  GroupByAndAggregate* group_by_and_agg,
300  Executor* executor,
302  const CompilationOptions& co,
303  const std::vector<llvm::Value*>& target_lvs,
304  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
305  const std::vector<llvm::Value*>& agg_out_vec,
306  llvm::Value* output_buffer_byte_stream,
307  llvm::Value* out_row_idx,
308  llvm::Value* varlen_output_buffer,
309  int32_t slot_index) const {
310  AUTOMATIC_IR_METADATA(executor->cgen_state_.get());
311  size_t target_lv_idx = 0;
312  const bool lazy_fetched{executor->plan_state_->isLazyFetchColumn(target_expr)};
313 
314  CodeGenerator code_generator(executor);
315 
316  const auto agg_fn_names = agg_fn_base_names(
318  auto arg_expr = agg_arg(target_expr);
319 
320  for (const auto& agg_base_name : agg_fn_names) {
321  if (target_info.is_distinct && arg_expr->get_type_info().is_array()) {
322  CHECK_EQ(static_cast<size_t>(query_mem_desc.getLogicalSlotWidthBytes(slot_index)),
323  sizeof(int64_t));
324  // TODO(miyu): check if buffer may be columnar here
325  CHECK(!query_mem_desc.didOutputColumnar());
326  const auto& elem_ti = arg_expr->get_type_info().get_elem_type();
327  uint32_t col_off{0};
328  if (is_group_by) {
329  const auto col_off_in_bytes = query_mem_desc.getColOnlyOffInBytes(slot_index);
330  CHECK_EQ(size_t(0), col_off_in_bytes % sizeof(int64_t));
331  col_off /= sizeof(int64_t);
332  }
333  executor->cgen_state_->emitExternalCall(
334  "agg_count_distinct_array_" + numeric_type_name(elem_ti),
335  llvm::Type::getVoidTy(LL_CONTEXT),
336  {is_group_by
337  ? LL_BUILDER.CreateGEP(std::get<0>(agg_out_ptr_w_idx), LL_INT(col_off))
338  : agg_out_vec[slot_index],
339  target_lvs[target_lv_idx],
340  code_generator.posArg(arg_expr),
341  elem_ti.is_fp()
342  ? static_cast<llvm::Value*>(executor->cgen_state_->inlineFpNull(elem_ti))
343  : static_cast<llvm::Value*>(
344  executor->cgen_state_->inlineIntNull(elem_ti))});
345  ++slot_index;
346  ++target_lv_idx;
347  continue;
348  }
349 
350  llvm::Value* agg_col_ptr{nullptr};
351  const auto chosen_bytes =
352  static_cast<size_t>(query_mem_desc.getPaddedSlotWidthBytes(slot_index));
353  const auto& chosen_type = get_compact_type(target_info);
354  const auto& arg_type =
355  ((arg_expr && arg_expr->get_type_info().get_type() != kNULLT) &&
359  const bool is_fp_arg =
360  !lazy_fetched && arg_type.get_type() != kNULLT && arg_type.is_fp();
361  if (is_group_by) {
362  agg_col_ptr = group_by_and_agg->codegenAggColumnPtr(output_buffer_byte_stream,
363  out_row_idx,
364  agg_out_ptr_w_idx,
365  query_mem_desc,
366  chosen_bytes,
367  slot_index,
368  target_idx);
369  CHECK(agg_col_ptr);
370  agg_col_ptr->setName("agg_col_ptr");
371  }
372 
374  CHECK(!query_mem_desc.didOutputColumnar());
375 
377  CHECK_LT(target_lv_idx, target_lvs.size());
378  CHECK(varlen_output_buffer);
379  auto target_lv = target_lvs[target_lv_idx];
380 
381  std::string agg_fname_suffix = "";
383  query_mem_desc.threadsShareMemory()) {
384  agg_fname_suffix += "_shared";
385  }
386 
387  // first write the varlen data into the varlen buffer and get the pointer location
388  // into the varlen buffer
389  auto& builder = executor->cgen_state_->ir_builder_;
390  auto orig_bb = builder.GetInsertBlock();
391  auto target_ptr_type = llvm::dyn_cast<llvm::PointerType>(target_lv->getType());
392  CHECK(target_ptr_type) << "Varlen projections expect a pointer input.";
393  auto is_nullptr =
394  builder.CreateICmp(llvm::CmpInst::ICMP_EQ,
395  target_lv,
396  llvm::ConstantPointerNull::get(llvm::PointerType::get(
397  target_ptr_type->getPointerElementType(), 0)));
398  llvm::BasicBlock* true_bb{nullptr};
399  {
400  DiamondCodegen nullcheck_diamond(
401  is_nullptr, executor, false, "varlen_null_check", nullptr, false);
402  // maintain a reference to the true bb, overriding the diamond codegen destructor
403  true_bb = nullcheck_diamond.cond_true_;
404  // if not null, process the pointer and insert it into the varlen buffer
405  builder.SetInsertPoint(nullcheck_diamond.cond_false_);
406  auto arr_ptr_lv = executor->cgen_state_->ir_builder_.CreateBitCast(
407  target_lv,
408  llvm::PointerType::get(get_int_type(8, executor->cgen_state_->context_), 0));
409  const int64_t chosen_bytes =
411  const auto output_buffer_slot = LL_BUILDER.CreateZExt(
412  LL_BUILDER.CreateLoad(get_arg_by_name(ROW_FUNC, "old_total_matched")),
413  llvm::Type::getInt64Ty(LL_CONTEXT));
414  const auto varlen_buffer_row_sz = query_mem_desc.varlenOutputBufferElemSize();
415  CHECK(varlen_buffer_row_sz);
416  const auto output_buffer_slot_bytes = LL_BUILDER.CreateAdd(
417  LL_BUILDER.CreateMul(output_buffer_slot,
418  executor->cgen_state_->llInt(
419  static_cast<int64_t>(*varlen_buffer_row_sz))),
420  executor->cgen_state_->llInt(static_cast<int64_t>(
421  query_mem_desc.varlenOutputRowSizeToSlot(slot_index))));
422 
423  std::vector<llvm::Value*> varlen_agg_args{
424  executor->castToIntPtrTyIn(varlen_output_buffer, 8),
425  output_buffer_slot_bytes,
426  arr_ptr_lv,
427  executor->cgen_state_->llInt(chosen_bytes)};
428  auto varlen_offset_ptr =
429  group_by_and_agg->emitCall(agg_base_name + agg_fname_suffix, varlen_agg_args);
430 
431  // then write that pointer location into the 64 bit slot in the output buffer
432  auto varlen_offset_int = LL_BUILDER.CreatePtrToInt(
433  varlen_offset_ptr, llvm::Type::getInt64Ty(LL_CONTEXT));
434  builder.CreateBr(nullcheck_diamond.cond_true_);
435 
436  // use the true block to do the output buffer insertion regardless of nullness
437  builder.SetInsertPoint(nullcheck_diamond.cond_true_);
438  auto output_phi =
439  builder.CreatePHI(llvm::Type::getInt64Ty(executor->cgen_state_->context_), 2);
440  output_phi->addIncoming(varlen_offset_int, nullcheck_diamond.cond_false_);
441  output_phi->addIncoming(executor->cgen_state_->llInt(static_cast<int64_t>(0)),
442  orig_bb);
443 
444  std::vector<llvm::Value*> agg_args{agg_col_ptr, output_phi};
445  group_by_and_agg->emitCall("agg_id" + agg_fname_suffix, agg_args);
446  }
447  CHECK(true_bb);
448  builder.SetInsertPoint(true_bb);
449 
450  ++slot_index;
451  ++target_lv_idx;
452  continue;
453  }
454 
455  const bool float_argument_input = takes_float_argument(target_info);
456  const bool is_count_in_avg = target_info.agg_kind == kAVG && target_lv_idx == 1;
457  // The count component of an average should never be compacted.
458  const auto agg_chosen_bytes =
459  float_argument_input && !is_count_in_avg ? sizeof(float) : chosen_bytes;
460  if (float_argument_input) {
461  CHECK_GE(chosen_bytes, sizeof(float));
462  }
463 
464  auto target_lv = target_lvs[target_lv_idx];
465  const auto needs_unnest_double_patch = group_by_and_agg->needsUnnestDoublePatch(
466  target_lv, agg_base_name, query_mem_desc.threadsShareMemory(), co);
467  const auto need_skip_null = !needs_unnest_double_patch && target_info.skip_null_val;
468  if (!needs_unnest_double_patch) {
469  if (need_skip_null && !is_agg_domain_range_equivalent(target_info.agg_kind)) {
470  target_lv = group_by_and_agg->convertNullIfAny(arg_type, target_info, target_lv);
471  } else if (is_fp_arg) {
472  target_lv = executor->castToFP(target_lv, arg_type, target_info.sql_type);
473  }
474  if (!dynamic_cast<const Analyzer::AggExpr*>(target_expr) || arg_expr) {
475  target_lv =
476  executor->cgen_state_->castToTypeIn(target_lv, (agg_chosen_bytes << 3));
477  }
478  }
479 
480  const bool is_simple_count_target = is_simple_count(target_info);
481  llvm::Value* str_target_lv{nullptr};
482  if (target_lvs.size() == 3 && !target_has_geo(target_info)) {
483  // none encoding string
484  str_target_lv = target_lvs.front();
485  }
486  std::vector<llvm::Value*> agg_args{
487  executor->castToIntPtrTyIn((is_group_by ? agg_col_ptr : agg_out_vec[slot_index]),
488  (agg_chosen_bytes << 3)),
489  (is_simple_count_target && !arg_expr)
490  ? (agg_chosen_bytes == sizeof(int32_t) ? LL_INT(int32_t(0))
491  : LL_INT(int64_t(0)))
492  : (is_simple_count_target && arg_expr && str_target_lv ? str_target_lv
493  : target_lv)};
494  if (query_mem_desc.isLogicalSizedColumnsAllowed()) {
495  if (is_simple_count_target && arg_expr && str_target_lv) {
496  agg_args[1] =
497  agg_chosen_bytes == sizeof(int32_t) ? LL_INT(int32_t(0)) : LL_INT(int64_t(0));
498  }
499  }
500  std::string agg_fname{agg_base_name};
501  if (is_fp_arg) {
502  if (!lazy_fetched) {
503  if (agg_chosen_bytes == sizeof(float)) {
504  CHECK_EQ(arg_type.get_type(), kFLOAT);
505  agg_fname += "_float";
506  } else {
507  CHECK_EQ(agg_chosen_bytes, sizeof(double));
508  agg_fname += "_double";
509  }
510  }
511  } else if (agg_chosen_bytes == sizeof(int32_t)) {
512  agg_fname += "_int32";
513  } else if (agg_chosen_bytes == sizeof(int16_t) &&
514  query_mem_desc.didOutputColumnar()) {
515  agg_fname += "_int16";
516  } else if (agg_chosen_bytes == sizeof(int8_t) && query_mem_desc.didOutputColumnar()) {
517  agg_fname += "_int8";
518  }
519 
521  CHECK_EQ(agg_chosen_bytes, sizeof(int64_t));
522  CHECK(!chosen_type.is_fp());
523  group_by_and_agg->codegenCountDistinct(
524  target_idx, target_expr, agg_args, query_mem_desc, co.device_type);
525  } else if (target_info.agg_kind == kAPPROX_QUANTILE) {
526  CHECK_EQ(agg_chosen_bytes, sizeof(int64_t));
527  group_by_and_agg->codegenApproxQuantile(
528  target_idx, target_expr, agg_args, query_mem_desc, co.device_type);
529  } else {
530  const auto& arg_ti = target_info.agg_arg_type;
531  if (need_skip_null && !arg_ti.is_geometry()) {
532  agg_fname += "_skip_val";
533  }
534 
536  (need_skip_null && !arg_ti.is_geometry())) {
537  llvm::Value* null_in_lv{nullptr};
538  if (arg_ti.is_fp()) {
539  null_in_lv =
540  static_cast<llvm::Value*>(executor->cgen_state_->inlineFpNull(arg_ti));
541  } else {
542  null_in_lv = static_cast<llvm::Value*>(executor->cgen_state_->inlineIntNull(
544  ? arg_ti
545  : target_info.sql_type));
546  }
547  CHECK(null_in_lv);
548  auto null_lv =
549  executor->cgen_state_->castToTypeIn(null_in_lv, (agg_chosen_bytes << 3));
550  agg_args.push_back(null_lv);
551  }
552  if (!target_info.is_distinct) {
554  query_mem_desc.threadsShareMemory()) {
555  agg_fname += "_shared";
556  if (needs_unnest_double_patch) {
557  agg_fname = patch_agg_fname(agg_fname);
558  }
559  }
560  auto agg_fname_call_ret_lv = group_by_and_agg->emitCall(agg_fname, agg_args);
561 
562  if (agg_fname.find("checked") != std::string::npos) {
563  group_by_and_agg->checkErrorCode(agg_fname_call_ret_lv);
564  }
565  }
566  }
567  const auto window_func = dynamic_cast<const Analyzer::WindowFunction*>(target_expr);
568  if (window_func && window_function_requires_peer_handling(window_func)) {
569  const auto window_func_context =
571  const auto pending_outputs =
572  LL_INT(window_func_context->aggregateStatePendingOutputs());
573  executor->cgen_state_->emitExternalCall("add_window_pending_output",
574  llvm::Type::getVoidTy(LL_CONTEXT),
575  {agg_args.front(), pending_outputs});
576  const auto& window_func_ti = window_func->get_type_info();
577  std::string apply_window_pending_outputs_name = "apply_window_pending_outputs";
578  switch (window_func_ti.get_type()) {
579  case kFLOAT: {
580  apply_window_pending_outputs_name += "_float";
581  if (query_mem_desc.didOutputColumnar()) {
582  apply_window_pending_outputs_name += "_columnar";
583  }
584  break;
585  }
586  case kDOUBLE: {
587  apply_window_pending_outputs_name += "_double";
588  break;
589  }
590  default: {
591  apply_window_pending_outputs_name += "_int";
592  if (query_mem_desc.didOutputColumnar()) {
593  apply_window_pending_outputs_name +=
594  std::to_string(window_func_ti.get_size() * 8);
595  } else {
596  apply_window_pending_outputs_name += "64";
597  }
598  break;
599  }
600  }
601  const auto partition_end =
602  LL_INT(reinterpret_cast<int64_t>(window_func_context->partitionEnd()));
603  executor->cgen_state_->emitExternalCall(apply_window_pending_outputs_name,
604  llvm::Type::getVoidTy(LL_CONTEXT),
605  {pending_outputs,
606  target_lvs.front(),
607  partition_end,
608  code_generator.posArg(nullptr)});
609  }
610 
611  ++slot_index;
612  ++target_lv_idx;
613  }
614 }
615 
617  const Executor* executor,
618  QueryMemoryDescriptor& query_mem_desc,
619  const CompilationOptions& co) {
620  AUTOMATIC_IR_METADATA(executor->cgen_state_.get());
621  if (query_mem_desc.getPaddedSlotWidthBytes(slot_index_counter) == 0) {
622  CHECK(!dynamic_cast<const Analyzer::AggExpr*>(target_expr));
623  ++slot_index_counter;
624  ++target_index_counter;
625  return;
626  }
627  if (dynamic_cast<const Analyzer::UOper*>(target_expr) &&
628  static_cast<const Analyzer::UOper*>(target_expr)->get_optype() == kUNNEST) {
629  throw std::runtime_error("UNNEST not supported in the projection list yet.");
630  }
631  if ((executor->plan_state_->isLazyFetchColumn(target_expr) || !is_group_by) &&
632  (static_cast<size_t>(query_mem_desc.getPaddedSlotWidthBytes(slot_index_counter)) <
633  sizeof(int64_t)) &&
634  !is_columnar_projection(query_mem_desc)) {
635  // TODO(miyu): enable different byte width in the layout w/o padding
637  }
638 
639  if (is_columnar_projection(query_mem_desc) &&
640  executor->plan_state_->isLazyFetchColumn(target_expr)) {
641  // For columnar outputs, we need to pad lazy fetched columns to 8 bytes to allow the
642  // lazy fetch index to be placed in the column. The QueryMemoryDescriptor is created
643  // before Lazy Fetch information is known, therefore we need to update the QMD with
644  // the new slot size width bytes for these columns.
645  query_mem_desc.setPaddedSlotWidthBytes(slot_index_counter, int8_t(8));
646  CHECK_EQ(query_mem_desc.getPaddedSlotWidthBytes(slot_index_counter), int8_t(8));
647  }
648 
649  auto target_info = get_target_info(target_expr, g_bigint_count);
650  auto arg_expr = agg_arg(target_expr);
651  if (arg_expr) {
654  target_info.skip_null_val = false;
655  } else if (query_mem_desc.getQueryDescriptionType() ==
657  !arg_expr->get_type_info().is_varlen()) {
658  // TODO: COUNT is currently not null-aware for varlen types. Need to add proper code
659  // generation for handling varlen nulls.
660  target_info.skip_null_val = true;
661  } else if (constrained_not_null(arg_expr, ra_exe_unit.quals)) {
662  target_info.skip_null_val = false;
663  }
664  }
665 
666  if (!(query_mem_desc.getQueryDescriptionType() ==
670  sample_exprs_to_codegen.emplace_back(target_expr,
671  target_info,
672  slot_index_counter,
673  target_index_counter++,
674  is_group_by);
675  } else {
676  target_exprs_to_codegen.emplace_back(target_expr,
677  target_info,
678  slot_index_counter,
679  target_index_counter++,
680  is_group_by);
681  }
682 
683  const auto agg_fn_names = agg_fn_base_names(
685  slot_index_counter += agg_fn_names.size();
686 }
687 
688 namespace {
689 
691  const QueryMemoryDescriptor& query_mem_desc) {
692  const bool is_group_by{query_mem_desc.isGroupBy()};
693  if (target_info.agg_kind == kSAMPLE && target_info.sql_type.is_string() &&
694  target_info.sql_type.get_compression() != kENCODING_NONE) {
695  return get_agg_initial_val(target_info.agg_kind,
696  target_info.sql_type,
697  is_group_by,
698  query_mem_desc.getCompactByteWidth());
699  }
700  return 0;
701 }
702 
703 } // namespace
704 
706  GroupByAndAggregate* group_by_and_agg,
707  Executor* executor,
708  const QueryMemoryDescriptor& query_mem_desc,
709  const CompilationOptions& co,
710  const GpuSharedMemoryContext& gpu_smem_context,
711  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
712  const std::vector<llvm::Value*>& agg_out_vec,
713  llvm::Value* output_buffer_byte_stream,
714  llvm::Value* out_row_idx,
715  llvm::Value* varlen_output_buffer,
716  DiamondCodegen& diamond_codegen) const {
717  CHECK(group_by_and_agg);
718  CHECK(executor);
719  AUTOMATIC_IR_METADATA(executor->cgen_state_.get());
720 
721  for (const auto& target_expr_codegen : target_exprs_to_codegen) {
722  target_expr_codegen.codegen(group_by_and_agg,
723  executor,
724  query_mem_desc,
725  co,
726  gpu_smem_context,
727  agg_out_ptr_w_idx,
728  agg_out_vec,
729  output_buffer_byte_stream,
730  out_row_idx,
731  varlen_output_buffer,
732  diamond_codegen);
733  }
734  if (!sample_exprs_to_codegen.empty()) {
735  codegenSampleExpressions(group_by_and_agg,
736  executor,
737  query_mem_desc,
738  co,
739  agg_out_ptr_w_idx,
740  agg_out_vec,
741  output_buffer_byte_stream,
742  out_row_idx,
743  diamond_codegen);
744  }
745 }
746 
748  GroupByAndAggregate* group_by_and_agg,
749  Executor* executor,
750  const QueryMemoryDescriptor& query_mem_desc,
751  const CompilationOptions& co,
752  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
753  const std::vector<llvm::Value*>& agg_out_vec,
754  llvm::Value* output_buffer_byte_stream,
755  llvm::Value* out_row_idx,
756  DiamondCodegen& diamond_codegen) const {
757  AUTOMATIC_IR_METADATA(executor->cgen_state_.get());
758  CHECK(!sample_exprs_to_codegen.empty());
760  if (sample_exprs_to_codegen.size() == 1 &&
761  !sample_exprs_to_codegen.front().target_info.sql_type.is_varlen()) {
762  codegenSingleSlotSampleExpression(group_by_and_agg,
763  executor,
764  query_mem_desc,
765  co,
766  agg_out_ptr_w_idx,
767  agg_out_vec,
768  output_buffer_byte_stream,
769  out_row_idx,
770  diamond_codegen);
771  } else {
772  codegenMultiSlotSampleExpressions(group_by_and_agg,
773  executor,
774  query_mem_desc,
775  co,
776  agg_out_ptr_w_idx,
777  agg_out_vec,
778  output_buffer_byte_stream,
779  out_row_idx,
780  diamond_codegen);
781  }
782 }
783 
785  GroupByAndAggregate* group_by_and_agg,
786  Executor* executor,
787  const QueryMemoryDescriptor& query_mem_desc,
788  const CompilationOptions& co,
789  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
790  const std::vector<llvm::Value*>& agg_out_vec,
791  llvm::Value* output_buffer_byte_stream,
792  llvm::Value* out_row_idx,
793  DiamondCodegen& diamond_codegen) const {
794  AUTOMATIC_IR_METADATA(executor->cgen_state_.get());
795  CHECK_EQ(size_t(1), sample_exprs_to_codegen.size());
796  CHECK(!sample_exprs_to_codegen.front().target_info.sql_type.is_varlen());
798  // no need for the atomic if we only have one SAMPLE target
799  sample_exprs_to_codegen.front().codegen(group_by_and_agg,
800  executor,
801  query_mem_desc,
802  co,
803  {},
804  agg_out_ptr_w_idx,
805  agg_out_vec,
806  output_buffer_byte_stream,
807  out_row_idx,
808  /*varlen_output_buffer=*/nullptr,
809  diamond_codegen);
810 }
811 
813  GroupByAndAggregate* group_by_and_agg,
814  Executor* executor,
815  const QueryMemoryDescriptor& query_mem_desc,
816  const CompilationOptions& co,
817  const std::tuple<llvm::Value*, llvm::Value*>& agg_out_ptr_w_idx,
818  const std::vector<llvm::Value*>& agg_out_vec,
819  llvm::Value* output_buffer_byte_stream,
820  llvm::Value* out_row_idx,
821  DiamondCodegen& diamond_codegen) const {
822  AUTOMATIC_IR_METADATA(executor->cgen_state_.get());
823  CHECK(sample_exprs_to_codegen.size() > 1 ||
824  sample_exprs_to_codegen.front().target_info.sql_type.is_varlen());
826  const auto& first_sample_expr = sample_exprs_to_codegen.front();
827  auto target_lvs = group_by_and_agg->codegenAggArg(first_sample_expr.target_expr, co);
828  CHECK_GE(target_lvs.size(), size_t(1));
829 
830  const auto init_val =
831  get_initial_agg_val(first_sample_expr.target_info, query_mem_desc);
832 
833  llvm::Value* agg_col_ptr{nullptr};
834  if (is_group_by) {
835  const auto agg_column_size_bytes =
836  query_mem_desc.isLogicalSizedColumnsAllowed() &&
837  !first_sample_expr.target_info.sql_type.is_varlen()
838  ? first_sample_expr.target_info.sql_type.get_size()
839  : sizeof(int64_t);
840  agg_col_ptr = group_by_and_agg->codegenAggColumnPtr(output_buffer_byte_stream,
841  out_row_idx,
842  agg_out_ptr_w_idx,
843  query_mem_desc,
844  agg_column_size_bytes,
845  first_sample_expr.base_slot_index,
846  first_sample_expr.target_idx);
847  } else {
848  CHECK_LT(static_cast<size_t>(first_sample_expr.base_slot_index), agg_out_vec.size());
849  agg_col_ptr =
850  executor->castToIntPtrTyIn(agg_out_vec[first_sample_expr.base_slot_index], 64);
851  }
852 
853  auto sample_cas_lv =
854  codegenSlotEmptyKey(agg_col_ptr, target_lvs, executor, query_mem_desc, init_val);
855 
856  DiamondCodegen sample_cfg(
857  sample_cas_lv, executor, false, "sample_valcheck", &diamond_codegen, false);
858 
859  for (const auto& target_expr_codegen : sample_exprs_to_codegen) {
860  target_expr_codegen.codegen(group_by_and_agg,
861  executor,
862  query_mem_desc,
863  co,
864  {},
865  agg_out_ptr_w_idx,
866  agg_out_vec,
867  output_buffer_byte_stream,
868  out_row_idx,
869  /*varlen_output_buffer=*/nullptr,
870  diamond_codegen,
871  &sample_cfg);
872  }
873 }
874 
876  llvm::Value* agg_col_ptr,
877  std::vector<llvm::Value*>& target_lvs,
878  Executor* executor,
879  const QueryMemoryDescriptor& query_mem_desc,
880  const int64_t init_val) const {
881  AUTOMATIC_IR_METADATA(executor->cgen_state_.get());
882  const auto& first_sample_expr = sample_exprs_to_codegen.front();
883  const auto first_sample_slot_bytes =
884  first_sample_expr.target_info.sql_type.is_varlen()
885  ? sizeof(int64_t)
886  : first_sample_expr.target_info.sql_type.get_size();
887  llvm::Value* target_lv_casted{nullptr};
888  // deciding whether proper casting is required for the first sample's slot:
889  if (first_sample_expr.target_info.sql_type.is_varlen()) {
890  target_lv_casted =
891  LL_BUILDER.CreatePtrToInt(target_lvs.front(), llvm::Type::getInt64Ty(LL_CONTEXT));
892  } else if (first_sample_expr.target_info.sql_type.is_fp()) {
893  // Initialization value for SAMPLE on a float column should be 0
894  CHECK_EQ(init_val, 0);
895  if (query_mem_desc.isLogicalSizedColumnsAllowed()) {
896  target_lv_casted = executor->cgen_state_->ir_builder_.CreateFPToSI(
897  target_lvs.front(),
898  first_sample_slot_bytes == sizeof(float) ? llvm::Type::getInt32Ty(LL_CONTEXT)
899  : llvm::Type::getInt64Ty(LL_CONTEXT));
900  } else {
901  target_lv_casted = executor->cgen_state_->ir_builder_.CreateFPToSI(
902  target_lvs.front(), llvm::Type::getInt64Ty(LL_CONTEXT));
903  }
904  } else if (first_sample_slot_bytes != sizeof(int64_t) &&
905  !query_mem_desc.isLogicalSizedColumnsAllowed()) {
906  target_lv_casted =
907  executor->cgen_state_->ir_builder_.CreateCast(llvm::Instruction::CastOps::SExt,
908  target_lvs.front(),
909  llvm::Type::getInt64Ty(LL_CONTEXT));
910  } else {
911  target_lv_casted = target_lvs.front();
912  }
913 
914  std::string slot_empty_cas_func_name("slotEmptyKeyCAS");
915  llvm::Value* init_val_lv{LL_INT(init_val)};
916  if (query_mem_desc.isLogicalSizedColumnsAllowed() &&
917  !first_sample_expr.target_info.sql_type.is_varlen()) {
918  // add proper suffix to the function name:
919  switch (first_sample_slot_bytes) {
920  case 1:
921  slot_empty_cas_func_name += "_int8";
922  break;
923  case 2:
924  slot_empty_cas_func_name += "_int16";
925  break;
926  case 4:
927  slot_empty_cas_func_name += "_int32";
928  break;
929  case 8:
930  break;
931  default:
932  UNREACHABLE() << "Invalid slot size for slotEmptyKeyCAS function.";
933  break;
934  }
935  if (first_sample_slot_bytes != sizeof(int64_t)) {
936  init_val_lv = llvm::ConstantInt::get(
937  get_int_type(first_sample_slot_bytes * 8, LL_CONTEXT), init_val);
938  }
939  }
940 
941  auto sample_cas_lv = executor->cgen_state_->emitExternalCall(
942  slot_empty_cas_func_name,
943  llvm::Type::getInt1Ty(executor->cgen_state_->context_),
944  {agg_col_ptr, target_lv_casted, init_val_lv});
945  return sample_cas_lv;
946 }
size_t varlenOutputRowSizeToSlot(const size_t slot_idx) const
#define LL_BUILDER
const Analyzer::Expr * agg_arg(const Analyzer::Expr *expr)
#define CHECK_EQ(x, y)
Definition: Logger.h:219
bool target_has_geo(const TargetInfo &target_info)
bool constrained_not_null(const Analyzer::Expr *expr, const std::list< std::shared_ptr< Analyzer::Expr >> &quals)
llvm::BasicBlock * cond_false_
llvm::Value * codegenAggColumnPtr(llvm::Value *output_buffer_byte_stream, llvm::Value *out_row_idx, const std::tuple< llvm::Value *, llvm::Value * > &agg_out_ptr_w_idx, const QueryMemoryDescriptor &query_mem_desc, const size_t chosen_bytes, const size_t agg_out_off, const size_t target_idx)
: returns the pointer to where the aggregation should be stored.
std::vector< std::string > agg_fn_base_names(const TargetInfo &target_info, const bool is_varlen_projection)
bool isLogicalSizedColumnsAllowed() const
SQLTypeInfo sql_type
Definition: TargetInfo.h:51
TargetInfo get_target_info(const PointerType target_expr, const bool bigint_count)
Definition: TargetInfo.h:92
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
llvm::Value * posArg(const Analyzer::Expr *) const
Definition: ColumnIR.cpp:512
#define UNREACHABLE()
Definition: Logger.h:255
#define CHECK_GE(x, y)
Definition: Logger.h:224
llvm::Value * emitCall(const std::string &fname, const std::vector< llvm::Value * > &args)
int64_t get_agg_initial_val(const SQLAgg agg, const SQLTypeInfo &ti, const bool enable_compaction, const unsigned min_byte_width_to_compact)
void codegenApproxQuantile(const size_t target_idx, const Analyzer::Expr *target_expr, std::vector< llvm::Value * > &agg_args, const QueryMemoryDescriptor &query_mem_desc, const ExecutorDeviceType device_type)
void checkErrorCode(llvm::Value *retCode)
bool takes_float_argument(const TargetInfo &target_info)
Definition: TargetInfo.h:157
#define LLVM_ALIGN(alignment)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
bool needsUnnestDoublePatch(llvm::Value const *val_ptr, const std::string &agg_base_name, const bool threads_share_memory, const CompilationOptions &co) const
bool skip_null_val
Definition: TargetInfo.h:53
llvm::BasicBlock * cond_true_
llvm::Type * get_int_type(const int width, llvm::LLVMContext &context)
static WindowFunctionContext * getActiveWindowFunctionContext(Executor *executor)
std::string to_string(char const *&&v)
SQLTypeInfo agg_arg_type
Definition: TargetInfo.h:52
std::string patch_agg_fname(const std::string &agg_name)
Helpers for codegen of target expressions.
size_t getColOnlyOffInBytes(const size_t col_idx) const
Definition: sqldefs.h:73
const SQLTypeInfo get_compact_type(const TargetInfo &target)
bool is_varlen_projection(const Analyzer::Expr *target_expr, const SQLTypeInfo &ti)
bool is_agg
Definition: TargetInfo.h:49
llvm::Value * get_arg_by_name(llvm::Function *func, const std::string &name)
Definition: Execute.h:166
void operator()(const Analyzer::Expr *target_expr, const Executor *executor, QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co)
#define LL_INT(v)
llvm::Value * convertNullIfAny(const SQLTypeInfo &arg_type, const TargetInfo &agg_info, llvm::Value *target)
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
bool g_bigint_count
Definition: sqldefs.h:75
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
#define LL_CONTEXT
bool is_distinct_target(const TargetInfo &target_info)
Definition: TargetInfo.h:153
void codegenCountDistinct(const size_t target_idx, const Analyzer::Expr *target_expr, std::vector< llvm::Value * > &agg_args, const QueryMemoryDescriptor &, const ExecutorDeviceType)
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
#define AUTOMATIC_IR_METADATA(CGENSTATE)
SQLAgg agg_kind
Definition: TargetInfo.h:50
QueryDescriptionType getQueryDescriptionType() const
ExecutorDeviceType device_type
std::optional< size_t > varlenOutputBufferElemSize() const
bool window_function_is_aggregate(const SqlWindowFunctionKind kind)
Definition: WindowContext.h:42
#define CHECK_LT(x, y)
Definition: Logger.h:221
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
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
const Analyzer::Expr * target_expr
Definition: sqldefs.h:76
std::vector< llvm::Value * > codegenAggArg(const Analyzer::Expr *target_expr, const CompilationOptions &co)
llvm::Value * codegenWindowRowPointer(const Analyzer::WindowFunction *window_func, const QueryMemoryDescriptor &query_mem_desc, const CompilationOptions &co, DiamondCodegen &diamond_codegen)
bool window_function_requires_peer_handling(const Analyzer::WindowFunction *window_func)
bool is_simple_count(const TargetInfo &target_info)
#define CHECK(condition)
Definition: Logger.h:211
bool is_geometry() const
Definition: sqltypes.h:531
static void resetWindowFunctionContext(Executor *executor)
void setPaddedSlotWidthBytes(const size_t slot_idx, const int8_t bytes)
int64_t get_initial_agg_val(const TargetInfo &target_info, const QueryMemoryDescriptor &query_mem_desc)
std::string numeric_type_name(const SQLTypeInfo &ti)
Definition: Execute.h:209
bool is_string() const
Definition: sqltypes.h:519
bool is_distinct
Definition: TargetInfo.h:54
Definition: sqldefs.h:74
const int8_t getLogicalSlotWidthBytes(const size_t slot_idx) const
int get_physical_coord_cols() const
Definition: sqltypes.h:375
Definition: sqldefs.h:72
size_t getColOffInBytes(const size_t col_idx) const
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
bool is_columnar_projection(const QueryMemoryDescriptor &query_mem_desc)
#define ROW_FUNC
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
bool is_agg_domain_range_equivalent(const SQLAgg &agg_kind)
Definition: TargetInfo.h:78