OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{TargetExprBuilder.cpp} Namespace Reference

Functions

bool is_varlen_projection (const Analyzer::Expr *target_expr, const SQLTypeInfo &ti)
 
std::vector< std::string > agg_fn_base_names (const TargetInfo &target_info, const bool is_varlen_projection)
 
bool is_columnar_projection (const QueryMemoryDescriptor &query_mem_desc)
 
bool is_simple_count (const TargetInfo &target_info)
 
bool target_has_geo (const TargetInfo &target_info)
 
int64_t get_initial_agg_val (const TargetInfo &target_info, const QueryMemoryDescriptor &query_mem_desc)
 

Function Documentation

std::vector<std::string> anonymous_namespace{TargetExprBuilder.cpp}::agg_fn_base_names ( const TargetInfo target_info,
const bool  is_varlen_projection 
)

Definition at line 46 of file TargetExprBuilder.cpp.

References TargetInfo::agg_kind, CHECK, get_compact_type(), TargetInfo::is_agg, TargetInfo::is_distinct, kAPPROX_COUNT_DISTINCT, kAPPROX_QUANTILE, kAVG, kCOUNT, kCOUNT_IF, kMAX, kMIN, kMODE, kSAMPLE, kSINGLE_VALUE, kSUM, kSUM_IF, and UNREACHABLE.

Referenced by TargetExprCodegen::codegen(), TargetExprCodegen::codegenAggregate(), and TargetExprCodegenBuilder::operator()().

47  {
48  const auto& chosen_type = get_compact_type(target_info);
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 kCOUNT_IF:
72  return {"agg_count_if"};
73  case kMAX:
74  return {"agg_max"};
75  case kMIN:
76  return {"agg_min"};
77  case kSUM:
78  return {"agg_sum"};
79  case kSUM_IF:
80  return {"agg_sum_if"};
82  return {"agg_approximate_count_distinct"};
83  case kAPPROX_QUANTILE:
84  return {"agg_approx_quantile"};
85  case kSINGLE_VALUE:
86  return {"checked_single_agg_id"};
87  case kSAMPLE:
88  return {"agg_id"};
89  case kMODE:
90  return {"agg_mode_func"};
91  default:
92  UNREACHABLE() << "Unrecognized agg kind: " << target_info.agg_kind;
93  }
94  return {};
95 }
#define UNREACHABLE()
Definition: Logger.h:333
Definition: sqldefs.h:75
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:50
Definition: sqldefs.h:77
SQLAgg agg_kind
Definition: TargetInfo.h:51
Definition: sqldefs.h:78
#define CHECK(condition)
Definition: Logger.h:289
bool is_distinct
Definition: TargetInfo.h:55
Definition: sqldefs.h:76
Definition: sqldefs.h:74
Definition: sqldefs.h:83

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t anonymous_namespace{TargetExprBuilder.cpp}::get_initial_agg_val ( const TargetInfo target_info,
const QueryMemoryDescriptor query_mem_desc 
)
inline

Definition at line 720 of file TargetExprBuilder.cpp.

References TargetInfo::agg_kind, get_agg_initial_val(), SQLTypeInfo::get_compression(), QueryMemoryDescriptor::getCompactByteWidth(), TargetExprCodegen::is_group_by, SQLTypeInfo::is_string(), QueryMemoryDescriptor::isGroupBy(), kENCODING_NONE, kSAMPLE, and TargetInfo::sql_type.

Referenced by TargetExprCodegenBuilder::codegenMultiSlotSampleExpressions().

721  {
722  const bool is_group_by{query_mem_desc.isGroupBy()};
723  if (target_info.agg_kind == kSAMPLE && target_info.sql_type.is_string() &&
724  target_info.sql_type.get_compression() != kENCODING_NONE) {
725  return get_agg_initial_val(target_info.agg_kind,
726  target_info.sql_type,
727  is_group_by,
728  query_mem_desc.getCompactByteWidth());
729  }
730  return 0;
731 }
SQLTypeInfo sql_type
Definition: TargetInfo.h:52
int64_t get_agg_initial_val(const SQLAgg agg, const SQLTypeInfo &ti, const bool enable_compaction, const unsigned min_byte_width_to_compact)
SQLAgg agg_kind
Definition: TargetInfo.h:51
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
bool is_string() const
Definition: sqltypes.h:576

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{TargetExprBuilder.cpp}::is_columnar_projection ( const QueryMemoryDescriptor query_mem_desc)
inline

Definition at line 97 of file TargetExprBuilder.cpp.

References QueryMemoryDescriptor::didOutputColumnar(), QueryMemoryDescriptor::getQueryDescriptionType(), Projection, and TableFunction.

Referenced by TargetExprCodegenBuilder::operator()().

97  {
98  return (query_mem_desc.getQueryDescriptionType() == QueryDescriptionType::Projection ||
99  query_mem_desc.getQueryDescriptionType() ==
101  query_mem_desc.didOutputColumnar();
102 }
QueryDescriptionType getQueryDescriptionType() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{TargetExprBuilder.cpp}::is_simple_count ( const TargetInfo target_info)

Definition at line 104 of file TargetExprBuilder.cpp.

References TargetInfo::agg_kind, TargetInfo::is_agg, and TargetInfo::is_distinct.

Referenced by TargetExprCodegen::codegen(), and TargetExprCodegen::codegenAggregate().

104  {
105  return target_info.is_agg && shared::is_any<kCOUNT>(target_info.agg_kind) &&
106  !target_info.is_distinct;
107 }
bool is_agg
Definition: TargetInfo.h:50
SQLAgg agg_kind
Definition: TargetInfo.h:51
bool is_distinct
Definition: TargetInfo.h:55

+ Here is the caller graph for this function:

bool anonymous_namespace{TargetExprBuilder.cpp}::is_varlen_projection ( const Analyzer::Expr target_expr,
const SQLTypeInfo ti 
)
inline

Definition at line 41 of file TargetExprBuilder.cpp.

References SQLTypeInfo::get_type(), and kPOINT.

Referenced by TargetExprCodegen::codegen(), TargetExprCodegen::codegenAggregate(), anonymous_namespace{QueryMemoryDescriptor.cpp}::get_col_byte_widths(), target_info::get_target_info_impl(), and TargetExprCodegenBuilder::operator()().

42  {
43  return dynamic_cast<const Analyzer::GeoExpr*>(target_expr) && ti.get_type() == kPOINT;
44 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{TargetExprBuilder.cpp}::target_has_geo ( const TargetInfo target_info)

Definition at line 109 of file TargetExprBuilder.cpp.

References TargetInfo::agg_arg_type, TargetInfo::is_agg, SQLTypeInfo::is_geometry(), and TargetInfo::sql_type.

Referenced by TargetExprCodegen::codegen(), and TargetExprCodegen::codegenAggregate().

109  {
110  return target_info.is_agg ? target_info.agg_arg_type.is_geometry()
111  : target_info.sql_type.is_geometry();
112 }
SQLTypeInfo sql_type
Definition: TargetInfo.h:52
SQLTypeInfo agg_arg_type
Definition: TargetInfo.h:53
bool is_agg
Definition: TargetInfo.h:50
bool is_geometry() const
Definition: sqltypes.h:588

+ Here is the call graph for this function:

+ Here is the caller graph for this function: