OmniSciDB  04ee39c94c
anonymous_namespace{GroupByAndAggregate.cpp} Namespace Reference

Functions

int32_t get_agg_count (const std::vector< Analyzer::Expr *> &target_exprs)
 
bool expr_is_rowid (const Analyzer::Expr *expr, const Catalog_Namespace::Catalog &cat)
 
bool has_count_distinct (const RelAlgExecutionUnit &ra_exe_unit)
 
bool is_column_range_too_big_for_perfect_hash (const ColRangeInfo &col_range_info, const int64_t max_entry_count)
 
void add_transient_string_literals_for_expression (const Analyzer::Expr *expr, Executor *executor, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner)
 

Function Documentation

◆ add_transient_string_literals_for_expression()

void anonymous_namespace{GroupByAndAggregate.cpp}::add_transient_string_literals_for_expression ( const Analyzer::Expr expr,
Executor executor,
std::shared_ptr< RowSetMemoryOwner row_set_mem_owner 
)

Definition at line 415 of file GroupByAndAggregate.cpp.

References CHECK, CHECK_EQ, Analyzer::CaseExpr::get_domain(), Analyzer::UOper::get_optype(), Analyzer::Expr::get_type_info(), kCAST, and kENCODING_DICT.

Referenced by GroupByAndAggregate::addTransientStringLiterals().

418  {
419  if (!expr) {
420  return;
421  }
422 
423  const auto array_expr = dynamic_cast<const Analyzer::ArrayExpr*>(expr);
424  if (array_expr) {
425  for (size_t i = 0; i < array_expr->getElementCount(); i++) {
427  array_expr->getElement(i), executor, row_set_mem_owner);
428  }
429  return;
430  }
431 
432  const auto cast_expr = dynamic_cast<const Analyzer::UOper*>(expr);
433  const auto& expr_ti = expr->get_type_info();
434  if (cast_expr && cast_expr->get_optype() == kCAST && expr_ti.is_string()) {
435  CHECK_EQ(kENCODING_DICT, expr_ti.get_compression());
436  auto sdp = executor->getStringDictionaryProxy(
437  expr_ti.get_comp_param(), row_set_mem_owner, true);
438  CHECK(sdp);
439  const auto str_lit_expr =
440  dynamic_cast<const Analyzer::Constant*>(cast_expr->get_operand());
441  if (str_lit_expr && str_lit_expr->get_constval().stringval) {
442  sdp->getOrAddTransient(*str_lit_expr->get_constval().stringval);
443  }
444  return;
445  }
446  const auto case_expr = dynamic_cast<const Analyzer::CaseExpr*>(expr);
447  if (!case_expr) {
448  return;
449  }
450  Analyzer::DomainSet domain_set;
451  case_expr->get_domain(domain_set);
452  if (domain_set.empty()) {
453  return;
454  }
455  if (expr_ti.is_string()) {
456  CHECK_EQ(kENCODING_DICT, expr_ti.get_compression());
457  auto sdp = executor->getStringDictionaryProxy(
458  expr_ti.get_comp_param(), row_set_mem_owner, true);
459  CHECK(sdp);
460  for (const auto domain_expr : domain_set) {
461  const auto cast_expr = dynamic_cast<const Analyzer::UOper*>(domain_expr);
462  const auto str_lit_expr =
463  cast_expr && cast_expr->get_optype() == kCAST
464  ? dynamic_cast<const Analyzer::Constant*>(cast_expr->get_operand())
465  : dynamic_cast<const Analyzer::Constant*>(domain_expr);
466  if (str_lit_expr && str_lit_expr->get_constval().stringval) {
467  sdp->getOrAddTransient(*str_lit_expr->get_constval().stringval);
468  }
469  }
470  }
471 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
void get_domain(DomainSet &domain_set) const override
Definition: Analyzer.cpp:2848
Definition: sqldefs.h:49
std::list< const Expr * > DomainSet
Definition: Analyzer.h:61
void add_transient_string_literals_for_expression(const Analyzer::Expr *expr, Executor *executor, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner)
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
#define CHECK(condition)
Definition: Logger.h:187
SQLOps get_optype() const
Definition: Analyzer.h:363
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expr_is_rowid()

bool anonymous_namespace{GroupByAndAggregate.cpp}::expr_is_rowid ( const Analyzer::Expr expr,
const Catalog_Namespace::Catalog cat 
)

Definition at line 82 of file GroupByAndAggregate.cpp.

References CHECK_EQ, and get_column_descriptor_maybe().

Referenced by GroupByAndAggregate::getColRangeInfo().

82  {
83  const auto col = dynamic_cast<const Analyzer::ColumnVar*>(expr);
84  if (!col) {
85  return false;
86  }
87  const auto cd =
88  get_column_descriptor_maybe(col->get_column_id(), col->get_table_id(), cat);
89  if (!cd || !cd->isVirtualCol) {
90  return false;
91  }
92  CHECK_EQ("rowid", cd->columnName);
93  return true;
94 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:168
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_agg_count()

int32_t anonymous_namespace{GroupByAndAggregate.cpp}::get_agg_count ( const std::vector< Analyzer::Expr *> &  target_exprs)

Definition at line 56 of file GroupByAndAggregate.cpp.

References agg_count(), CHECK, Analyzer::Expr::get_type_info(), kAVG, kENCODING_NONE, and kSAMPLE.

Referenced by GroupByAndAggregate::codegen().

56  {
57  int32_t agg_count{0};
58  for (auto target_expr : target_exprs) {
59  CHECK(target_expr);
60  const auto agg_expr = dynamic_cast<Analyzer::AggExpr*>(target_expr);
61  if (!agg_expr || agg_expr->get_aggtype() == kSAMPLE) {
62  const auto& ti = target_expr->get_type_info();
63  // TODO(pavan): or if is_geometry()
64  if (ti.is_array() || (ti.is_string() && ti.get_compression() == kENCODING_NONE)) {
65  agg_count += 2;
66  } else if (ti.is_geometry()) {
67  agg_count += ti.get_physical_coord_cols() * 2;
68  } else {
69  ++agg_count;
70  }
71  continue;
72  }
73  if (agg_expr && agg_expr->get_aggtype() == kAVG) {
74  agg_count += 2;
75  } else {
76  ++agg_count;
77  }
78  }
79  return agg_count;
80 }
ALWAYS_INLINE uint64_t agg_count(uint64_t *agg, const int64_t)
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
#define CHECK(condition)
Definition: Logger.h:187
Definition: sqldefs.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has_count_distinct()

bool anonymous_namespace{GroupByAndAggregate.cpp}::has_count_distinct ( const RelAlgExecutionUnit ra_exe_unit)

Definition at line 96 of file GroupByAndAggregate.cpp.

References g_bigint_count, get_target_info(), is_distinct_target(), and RelAlgExecutionUnit::target_exprs.

Referenced by GroupByAndAggregate::getColRangeInfo().

96  {
97  for (const auto& target_expr : ra_exe_unit.target_exprs) {
98  const auto agg_info = get_target_info(target_expr, g_bigint_count);
99  if (agg_info.is_agg && is_distinct_target(agg_info)) {
100  return true;
101  }
102  }
103  return false;
104 }
std::vector< Analyzer::Expr * > target_exprs
TargetInfo get_target_info(const PointerType target_expr, const bool bigint_count)
Definition: TargetInfo.h:65
bool g_bigint_count
bool is_distinct_target(const TargetInfo &target_info)
Definition: TargetInfo.h:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_column_range_too_big_for_perfect_hash()

bool anonymous_namespace{GroupByAndAggregate.cpp}::is_column_range_too_big_for_perfect_hash ( const ColRangeInfo col_range_info,
const int64_t  max_entry_count 
)

Definition at line 106 of file GroupByAndAggregate.cpp.

References ColRangeInfo::max, and ColRangeInfo::min.

Referenced by GroupByAndAggregate::getColRangeInfo().

107  {
108  try {
109  return static_cast<int64_t>(checked_int64_t(col_range_info.max) -
110  checked_int64_t(col_range_info.min)) >= max_entry_count;
111  } catch (...) {
112  return true;
113  }
114 }
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void > > checked_int64_t
+ Here is the caller graph for this function: