OmniSciDB  a47db9e897
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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 419 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().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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:198
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:171

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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)
CHECK(cgen_state)
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
Definition: sqldefs.h:71

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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:

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: