OmniSciDB  a987f07e93
 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 visitStringOper (const Analyzer::StringOper *string_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 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 260 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 262 of file RelAlgExecutor.cpp.

264  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 374 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.

376  {
377  auto result = aggregate;
378  result.text_decoding_casts += next_result.text_decoding_casts;
379  result.text_encoding_casts += next_result.text_encoding_casts;
380  return result;
381  }
TextEncodingCastCounts anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::defaultResult ( ) const
inlineoverrideprotectedvirtual

Reimplemented from ScalarExprVisitor< TextEncodingCastCounts >.

Definition at line 387 of file RelAlgExecutor.cpp.

387  {
388  return TextEncodingCastCounts();
389  }
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 314 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.

314  {
315  TextEncodingCastCounts result = defaultResult();
316  // Currently the join framework handles casts between string types, and
317  // casts to none-encoded strings should be considered spurious, except
318  // when the join predicate is not a =/<> operator, in which case
319  // for both join predicates and all other instances we have to decode
320  // to a none-encoded string to do the comparison. The logic below essentially
321  // overrides the logic such as to always count none-encoded casts on strings
322  // that are children of binary operators other than =/<>
323  if (bin_oper->get_optype() != kEQ && bin_oper->get_optype() != kNE) {
324  // Override the global override so that join opers don't skip
325  // the check when there is an actual cast to none-encoded string
326  const auto prev_disregard_casts_to_none_encoding_state =
328  const auto left_u_oper =
329  dynamic_cast<const Analyzer::UOper*>(bin_oper->get_left_operand());
330  if (left_u_oper && left_u_oper->get_optype() == kCAST) {
332  result = aggregateResult(result, visitUOper(left_u_oper));
333  } else {
334  disregard_casts_to_none_encoding_ = prev_disregard_casts_to_none_encoding_state;
335  result = aggregateResult(result, visit(bin_oper->get_left_operand()));
336  }
337 
338  const auto right_u_oper =
339  dynamic_cast<const Analyzer::UOper*>(bin_oper->get_left_operand());
340  if (right_u_oper && right_u_oper->get_optype() == kCAST) {
342  result = aggregateResult(result, visitUOper(right_u_oper));
343  } else {
344  disregard_casts_to_none_encoding_ = prev_disregard_casts_to_none_encoding_state;
345  result = aggregateResult(result, visit(bin_oper->get_right_operand()));
346  }
347  disregard_casts_to_none_encoding_ = prev_disregard_casts_to_none_encoding_state;
348  } else {
349  result = aggregateResult(result, visit(bin_oper->get_left_operand()));
350  result = aggregateResult(result, visit(bin_oper->get_right_operand()));
351  }
352  return result;
353  }
TextEncodingCastCounts visitUOper(const Analyzer::UOper *u_oper) const override
const Expr * get_right_operand() const
Definition: Analyzer.h:452
Definition: sqldefs.h:48
Definition: sqldefs.h:29
TextEncodingCastCounts visit(const Analyzer::Expr *expr) const
SQLOps get_optype() const
Definition: Analyzer.h:448
TextEncodingCastCounts aggregateResult(const TextEncodingCastCounts &aggregate, const TextEncodingCastCounts &next_result) const override
Definition: sqldefs.h:31
const Expr * get_left_operand() const
Definition: Analyzer.h:451

+ 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 355 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.

355  {
356  TextEncodingCastCounts result = defaultResult();
357  const auto u_oper = dynamic_cast<const Analyzer::UOper*>(like->get_arg());
358  const auto prev_disregard_casts_to_none_encoding_state =
360  if (u_oper && u_oper->get_optype() == kCAST) {
362  result = aggregateResult(result, visitUOper(u_oper));
363  disregard_casts_to_none_encoding_ = prev_disregard_casts_to_none_encoding_state;
364  } else {
365  result = aggregateResult(result, visit(like->get_arg()));
366  }
367  result = aggregateResult(result, visit(like->get_like_expr()));
368  if (like->get_escape_expr()) {
369  result = aggregateResult(result, visit(like->get_escape_expr()));
370  }
371  return result;
372  }
TextEncodingCastCounts visitUOper(const Analyzer::UOper *u_oper) const override
const Expr * get_escape_expr() const
Definition: Analyzer.h:908
Definition: sqldefs.h:48
TextEncodingCastCounts visit(const Analyzer::Expr *expr) const
const Expr * get_arg() const
Definition: Analyzer.h:905
TextEncodingCastCounts aggregateResult(const TextEncodingCastCounts &aggregate, const TextEncodingCastCounts &next_result) const override
const Expr * get_like_expr() const
Definition: Analyzer.h:907

+ Here is the call graph for this function:

TextEncodingCastCounts anonymous_namespace{RelAlgExecutor.cpp}::TextEncodingCastCountVisitor::visitStringOper ( const Analyzer::StringOper string_oper) const
inlineoverrideprotectedvirtual

Reimplemented from ScalarExprVisitor< TextEncodingCastCounts >.

Definition at line 301 of file RelAlgExecutor.cpp.

References Analyzer::StringOper::get_kind(), Analyzer::StringOper::getArg(), Analyzer::StringOper::getArity(), Analyzer::StringOper::hasNoneEncodedTextArg(), run_benchmark_import::result, and string_op_returns_string().

302  {
303  TextEncodingCastCounts result = defaultResult();
304  if (string_oper->getArity() > 0) {
305  result = aggregateResult(result, visit(string_oper->getArg(0)));
306  }
307  if (string_op_returns_string(string_oper->get_kind()) &&
308  string_oper->hasNoneEncodedTextArg()) {
309  result = aggregateResult(result, TextEncodingCastCounts(0UL, 1UL));
310  }
311  return result;
312  }
bool hasNoneEncodedTextArg() const
Definition: Analyzer.h:1613
size_t getArity() const
Definition: Analyzer.h:1544
TextEncodingCastCounts visit(const Analyzer::Expr *expr) const
TextEncodingCastCounts aggregateResult(const TextEncodingCastCounts &aggregate, const TextEncodingCastCounts &next_result) const override
bool string_op_returns_string(const SqlStringOpKind kind)
Definition: sqldefs.h:448
SqlStringOpKind get_kind() const
Definition: Analyzer.h:1542
const Expr * getArg(const size_t i) const
Definition: Analyzer.h:1558

+ 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 267 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.

267  {
268  TextEncodingCastCounts result = defaultResult();
269  // Save state of input disregard_casts_to_none_encoding_ as child node traversal
270  // will reset it
271  const bool disregard_casts_to_none_encoding = disregard_casts_to_none_encoding_;
272  result = aggregateResult(result, visit(u_oper->get_operand()));
273  if (u_oper->get_optype() != kCAST) {
274  return result;
275  }
276  const auto& operand_ti = u_oper->get_operand()->get_type_info();
277  const auto& casted_ti = u_oper->get_type_info();
278  if (!operand_ti.is_string() && casted_ti.is_dict_encoded_string()) {
279  return aggregateResult(result, TextEncodingCastCounts(0UL, 1UL));
280  }
281  if (!casted_ti.is_string()) {
282  return result;
283  }
284  const bool literals_only = u_oper->get_operand()->get_num_column_vars(true) == 0UL;
285  if (literals_only) {
286  return result;
287  }
288  if (operand_ti.is_none_encoded_string() && casted_ti.is_dict_encoded_string()) {
289  return aggregateResult(result, TextEncodingCastCounts(0UL, 1UL));
290  }
291  if (operand_ti.is_dict_encoded_string() && casted_ti.is_none_encoded_string()) {
292  if (!disregard_casts_to_none_encoding) {
293  return aggregateResult(result, TextEncodingCastCounts(1UL, 0UL));
294  } else {
295  return result;
296  }
297  }
298  return result;
299  }
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:83
const Expr * get_operand() const
Definition: Analyzer.h:380
virtual size_t get_num_column_vars(const bool include_agg) const
Definition: Analyzer.cpp:58
SQLOps get_optype() const
Definition: Analyzer.h:379

+ 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 393 of file RelAlgExecutor.cpp.

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

Definition at line 392 of file RelAlgExecutor.cpp.


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