OmniSciDB  4201147b46
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor Class Reference
+ Inheritance diagram for anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor:
+ Collaboration diagram for anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor:

Public Member Functions

 TextEncodingCastCountVisitor (const bool default_disregard_casts_to_none_encoding)
 
- Public Member Functions inherited from ScalarExprVisitor< TextEncodingCastCounts >
TextEncodingCastCounts visit (const Analyzer::Expr *expr) const
 

Protected Member Functions

TextEncodingCastCounts visitUOper (const Analyzer::UOper *u_oper) const override
 
TextEncodingCastCounts visitBinOper (const Analyzer::BinOper *bin_oper) const override
 
TextEncodingCastCounts visitLikeExpr (const Analyzer::LikeExpr *like) const override
 
TextEncodingCastCounts aggregateResult (const TextEncodingCastCounts &aggregate, const TextEncodingCastCounts &next_result) const override
 
void visitBegin () const override
 
TextEncodingCastCounts defaultResult () const override
 
- Protected Member Functions inherited from ScalarExprVisitor< TextEncodingCastCounts >
virtual TextEncodingCastCounts visitVar (const Analyzer::Var *) const
 
virtual TextEncodingCastCounts visitColumnVar (const Analyzer::ColumnVar *) const
 
virtual TextEncodingCastCounts visitColumnVarTuple (const Analyzer::ExpressionTuple *) const
 
virtual TextEncodingCastCounts visitConstant (const Analyzer::Constant *) const
 
virtual TextEncodingCastCounts visitGeoExpr (const Analyzer::GeoExpr *geo_expr) const
 
virtual TextEncodingCastCounts visitInValues (const Analyzer::InValues *in_values) const
 
virtual TextEncodingCastCounts visitInIntegerSet (const Analyzer::InIntegerSet *in_integer_set) const
 
virtual TextEncodingCastCounts visitCharLength (const Analyzer::CharLengthExpr *char_length) const
 
virtual TextEncodingCastCounts visitKeyForString (const Analyzer::KeyForStringExpr *key_for_string) const
 
virtual TextEncodingCastCounts visitSampleRatio (const Analyzer::SampleRatioExpr *sample_ratio) const
 
virtual TextEncodingCastCounts visitStringOper (const Analyzer::StringOper *string_oper) const
 
virtual TextEncodingCastCounts visitCardinality (const Analyzer::CardinalityExpr *cardinality) const
 
virtual TextEncodingCastCounts visitRegexpExpr (const Analyzer::RegexpExpr *regexp) const
 
virtual TextEncodingCastCounts visitWidthBucket (const Analyzer::WidthBucketExpr *width_bucket_expr) const
 
virtual TextEncodingCastCounts visitCaseExpr (const Analyzer::CaseExpr *case_) const
 
virtual TextEncodingCastCounts visitDatetruncExpr (const Analyzer::DatetruncExpr *datetrunc) const
 
virtual TextEncodingCastCounts visitExtractExpr (const Analyzer::ExtractExpr *extract) const
 
virtual TextEncodingCastCounts visitFunctionOperWithCustomTypeHandling (const Analyzer::FunctionOperWithCustomTypeHandling *func_oper) const
 
virtual TextEncodingCastCounts visitArrayOper (Analyzer::ArrayExpr const *array_expr) const
 
virtual TextEncodingCastCounts visitGeoUOper (const Analyzer::GeoUOper *geo_expr) const
 
virtual TextEncodingCastCounts visitGeoBinOper (const Analyzer::GeoBinOper *geo_expr) const
 
virtual TextEncodingCastCounts visitFunctionOper (const Analyzer::FunctionOper *func_oper) const
 
virtual TextEncodingCastCounts visitWindowFunction (const Analyzer::WindowFunction *window_func) const
 
virtual TextEncodingCastCounts visitDatediffExpr (const Analyzer::DatediffExpr *datediff) const
 
virtual TextEncodingCastCounts visitDateaddExpr (const Analyzer::DateaddExpr *dateadd) const
 
virtual TextEncodingCastCounts visitLikelihood (const Analyzer::LikelihoodExpr *likelihood) const
 
virtual TextEncodingCastCounts visitOffsetInFragment (const Analyzer::OffsetInFragment *) const
 
virtual TextEncodingCastCounts visitAggExpr (const Analyzer::AggExpr *agg) const
 
virtual TextEncodingCastCounts visitRangeJoinOper (const Analyzer::RangeOper *range_oper) const
 
virtual TextEncodingCastCounts aggregateResult (const TextEncodingCastCounts &aggregate, const TextEncodingCastCounts &next_result) const
 

Private Attributes

bool disregard_casts_to_none_encoding_ = false
 
const bool default_disregard_casts_to_none_encoding_
 

Detailed Description

Definition at line 254 of file RelAlgExecutor.cpp.

Constructor & Destructor Documentation

anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::TextEncodingCastCountVisitor ( const bool  default_disregard_casts_to_none_encoding)
inline

Definition at line 256 of file RelAlgExecutor.cpp.

258  default_disregard_casts_to_none_encoding) {}

Member Function Documentation

TextEncodingCastCounts anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::aggregateResult ( const TextEncodingCastCounts aggregate,
const TextEncodingCastCounts next_result 
) const
inlineoverrideprotected

Definition at line 352 of file RelAlgExecutor.cpp.

References run_benchmark_import::result, anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCounts::text_decoding_casts, and anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCounts::text_encoding_casts.

354  {
355  auto result = aggregate;
356  result.text_decoding_casts += next_result.text_decoding_casts;
357  result.text_encoding_casts += next_result.text_encoding_casts;
358  return result;
359  }
TextEncodingCastCounts anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::defaultResult ( ) const
inlineoverrideprotectedvirtual

Reimplemented from ScalarExprVisitor< TextEncodingCastCounts >.

Definition at line 365 of file RelAlgExecutor.cpp.

365  {
366  return TextEncodingCastCounts();
367  }
void anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::visitBegin ( ) const
inlineoverrideprotectedvirtual
TextEncodingCastCounts anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::visitBinOper ( const Analyzer::BinOper bin_oper) const
inlineoverrideprotectedvirtual

Reimplemented from ScalarExprVisitor< TextEncodingCastCounts >.

Definition at line 292 of file RelAlgExecutor.cpp.

References Analyzer::BinOper::get_left_operand(), Analyzer::BinOper::get_optype(), Analyzer::BinOper::get_right_operand(), kCAST, kEQ, kNE, and run_benchmark_import::result.

292  {
293  TextEncodingCastCounts result = defaultResult();
294  // Currently the join framework handles casts between string types, and
295  // casts to none-encoded strings should be considered spurious, except
296  // when the join predicate is not a =/<> operator, in which case
297  // for both join predicates and all other instances we have to decode
298  // to a none-encoded string to do the comparison. The logic below essentially
299  // overrides the logic such as to always count none-encoded casts on strings
300  // that are children of binary operators other than =/<>
301  if (bin_oper->get_optype() != kEQ && bin_oper->get_optype() != kNE) {
302  // Override the global override so that join opers don't skip
303  // the check when there is an actual cast to none-encoded string
304  const auto prev_disregard_casts_to_none_encoding_state =
306  const auto left_u_oper =
307  dynamic_cast<const Analyzer::UOper*>(bin_oper->get_left_operand());
308  if (left_u_oper && left_u_oper->get_optype() == kCAST) {
310  result = aggregateResult(result, visitUOper(left_u_oper));
311  } else {
312  disregard_casts_to_none_encoding_ = prev_disregard_casts_to_none_encoding_state;
313  result = aggregateResult(result, visit(bin_oper->get_left_operand()));
314  }
315 
316  const auto right_u_oper =
317  dynamic_cast<const Analyzer::UOper*>(bin_oper->get_left_operand());
318  if (right_u_oper && right_u_oper->get_optype() == kCAST) {
320  result = aggregateResult(result, visitUOper(right_u_oper));
321  } else {
322  disregard_casts_to_none_encoding_ = prev_disregard_casts_to_none_encoding_state;
323  result = aggregateResult(result, visit(bin_oper->get_right_operand()));
324  }
325  disregard_casts_to_none_encoding_ = prev_disregard_casts_to_none_encoding_state;
326  } else {
327  result = aggregateResult(result, visit(bin_oper->get_left_operand()));
328  result = aggregateResult(result, visit(bin_oper->get_right_operand()));
329  }
330  return result;
331  }
TextEncodingCastCounts visitUOper(const Analyzer::UOper *u_oper) const override
const Expr * get_right_operand() const
Definition: Analyzer.h:450
Definition: sqldefs.h:48
Definition: sqldefs.h:29
TextEncodingCastCounts visit(const Analyzer::Expr *expr) const
SQLOps get_optype() const
Definition: Analyzer.h:446
TextEncodingCastCounts aggregateResult(const TextEncodingCastCounts &aggregate, const TextEncodingCastCounts &next_result) const override
Definition: sqldefs.h:31
const Expr * get_left_operand() const
Definition: Analyzer.h:449

+ Here is the call graph for this function:

TextEncodingCastCounts anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::visitLikeExpr ( const Analyzer::LikeExpr like) const
inlineoverrideprotectedvirtual

Reimplemented from ScalarExprVisitor< TextEncodingCastCounts >.

Definition at line 333 of file RelAlgExecutor.cpp.

References Analyzer::LikeExpr::get_arg(), Analyzer::LikeExpr::get_escape_expr(), Analyzer::LikeExpr::get_like_expr(), kCAST, and run_benchmark_import::result.

333  {
334  TextEncodingCastCounts result = defaultResult();
335  const auto u_oper = dynamic_cast<const Analyzer::UOper*>(like->get_arg());
336  const auto prev_disregard_casts_to_none_encoding_state =
338  if (u_oper && u_oper->get_optype() == kCAST) {
340  result = aggregateResult(result, visitUOper(u_oper));
341  disregard_casts_to_none_encoding_ = prev_disregard_casts_to_none_encoding_state;
342  } else {
343  result = aggregateResult(result, visit(like->get_arg()));
344  }
345  result = aggregateResult(result, visit(like->get_like_expr()));
346  if (like->get_escape_expr()) {
347  result = aggregateResult(result, visit(like->get_escape_expr()));
348  }
349  return result;
350  }
TextEncodingCastCounts visitUOper(const Analyzer::UOper *u_oper) const override
const Expr * get_escape_expr() const
Definition: Analyzer.h:906
Definition: sqldefs.h:48
TextEncodingCastCounts visit(const Analyzer::Expr *expr) const
const Expr * get_arg() const
Definition: Analyzer.h:903
TextEncodingCastCounts aggregateResult(const TextEncodingCastCounts &aggregate, const TextEncodingCastCounts &next_result) const override
const Expr * get_like_expr() const
Definition: Analyzer.h:905

+ Here is the call graph for this function:

TextEncodingCastCounts anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::visitUOper ( const Analyzer::UOper u_oper) const
inlineoverrideprotectedvirtual

Reimplemented from ScalarExprVisitor< TextEncodingCastCounts >.

Definition at line 261 of file RelAlgExecutor.cpp.

References Analyzer::Expr::get_num_column_vars(), Analyzer::UOper::get_operand(), Analyzer::UOper::get_optype(), Analyzer::Expr::get_type_info(), kCAST, and run_benchmark_import::result.

261  {
262  TextEncodingCastCounts result = defaultResult();
263  // Save state of input disregard_casts_to_none_encoding_ as child node traversal
264  // will reset it
265  const bool disregard_casts_to_none_encoding = disregard_casts_to_none_encoding_;
266  result = aggregateResult(result, visit(u_oper->get_operand()));
267  if (u_oper->get_optype() != kCAST) {
268  return result;
269  }
270  const auto& operand_ti = u_oper->get_operand()->get_type_info();
271  const auto& casted_ti = u_oper->get_type_info();
272  if (!operand_ti.is_string() || !casted_ti.is_string()) {
273  return result;
274  }
275  const bool literals_only = u_oper->get_operand()->get_num_column_vars(true) == 0UL;
276  if (literals_only) {
277  return result;
278  }
279  if (operand_ti.is_none_encoded_string() && casted_ti.is_dict_encoded_string()) {
280  return aggregateResult(result, TextEncodingCastCounts(0UL, 1UL));
281  }
282  if (operand_ti.is_dict_encoded_string() && casted_ti.is_none_encoded_string()) {
283  if (!disregard_casts_to_none_encoding) {
284  return aggregateResult(result, TextEncodingCastCounts(1UL, 0UL));
285  } else {
286  return result;
287  }
288  }
289  return result;
290  }
Definition: sqldefs.h:48
TextEncodingCastCounts visit(const Analyzer::Expr *expr) const
TextEncodingCastCounts aggregateResult(const TextEncodingCastCounts &aggregate, const TextEncodingCastCounts &next_result) const override
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:81
const Expr * get_operand() const
Definition: Analyzer.h:378
virtual size_t get_num_column_vars(const bool include_agg) const
Definition: Analyzer.cpp:58
SQLOps get_optype() const
Definition: Analyzer.h:377

+ Here is the call graph for this function:

Member Data Documentation

const bool anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::default_disregard_casts_to_none_encoding_
private

Definition at line 371 of file RelAlgExecutor.cpp.

bool anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::disregard_casts_to_none_encoding_ = false
mutableprivate

Definition at line 370 of file RelAlgExecutor.cpp.


The documentation for this class was generated from the following file: