OmniSciDB  0fdbebe030
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Analyzer::anonymous_namespace{Analyzer.cpp} Namespace Reference

Classes

struct  IntFracRepr
 

Functions

IntFracRepr decimal_to_int_frac (const int64_t dec, const SQLTypeInfo &ti)
 
template<class T >
safe_narrow (const int64_t v)
 
template<class T >
bool expr_is (const std::shared_ptr< Analyzer::Expr > &expr)
 
bool is_expr_nullable (const Analyzer::Expr *expr)
 
bool is_in_values_nullable (const std::shared_ptr< Analyzer::Expr > &a, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
 

Function Documentation

IntFracRepr Analyzer::anonymous_namespace{Analyzer.cpp}::decimal_to_int_frac ( const int64_t  dec,
const SQLTypeInfo ti 
)

Definition at line 710 of file Analyzer.cpp.

References SQLTypeInfo::get_scale(), and SQLTypeInfo::set_scale().

Referenced by Analyzer::Constant::cast_number().

710  {
711  if (ti.get_scale() > 18) {
712  auto truncated_ti = ti;
713  truncated_ti.set_scale(18);
714  auto truncated_dec = dec;
715  for (int i = 0; i < ti.get_scale() - 18; ++i) {
716  truncated_dec /= 10;
717  }
718  return decimal_to_int_frac(truncated_dec, truncated_ti);
719  }
720  int64_t integral_part = dec;
721  int64_t scale = 1;
722  for (int i = 0; i < ti.get_scale(); i++) {
723  integral_part /= 10;
724  scale *= 10;
725  }
726  return {integral_part, dec - integral_part * scale, scale};
727 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:253
void set_scale(int s)
Definition: sqltypes.h:343
IntFracRepr decimal_to_int_frac(const int64_t dec, const SQLTypeInfo &ti)
Definition: Analyzer.cpp:710

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
bool Analyzer::anonymous_namespace{Analyzer.cpp}::expr_is ( const std::shared_ptr< Analyzer::Expr > &  expr)

Definition at line 1316 of file Analyzer.cpp.

1316  {
1317  return std::dynamic_pointer_cast<T>(expr) != nullptr;
1318 }
bool Analyzer::anonymous_namespace{Analyzer.cpp}::is_expr_nullable ( const Analyzer::Expr expr)

Definition at line 1433 of file Analyzer.cpp.

References Analyzer::Constant::get_is_null(), SQLTypeInfo::get_notnull(), and Analyzer::Expr::get_type_info().

Referenced by is_in_values_nullable().

1433  {
1434  const auto const_expr = dynamic_cast<const Analyzer::Constant*>(expr);
1435  if (const_expr) {
1436  return const_expr->get_is_null();
1437  }
1438  const auto& expr_ti = expr->get_type_info();
1439  return !expr_ti.get_notnull();
1440 }
bool get_is_null() const
Definition: Analyzer.h:328
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:255

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Analyzer::anonymous_namespace{Analyzer.cpp}::is_in_values_nullable ( const std::shared_ptr< Analyzer::Expr > &  a,
const std::list< std::shared_ptr< Analyzer::Expr >> &  l 
)

Definition at line 1442 of file Analyzer.cpp.

References is_expr_nullable().

1443  {
1444  if (is_expr_nullable(a.get())) {
1445  return true;
1446  }
1447  for (const auto& v : l) {
1448  if (is_expr_nullable(v.get())) {
1449  return true;
1450  }
1451  }
1452  return false;
1453 }
bool is_expr_nullable(const Analyzer::Expr *expr)
Definition: Analyzer.cpp:1433

+ Here is the call graph for this function:

template<class T >
T Analyzer::anonymous_namespace{Analyzer.cpp}::safe_narrow ( const int64_t  v)

Definition at line 730 of file Analyzer.cpp.

730  {
731  if (v > std::numeric_limits<T>::max() || v < std::numeric_limits<T>::min()) {
732  throw std::runtime_error("Overflow or underflow");
733  }
734  return static_cast<T>(v);
735 }