OmniSciDB  b24e664e58
 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 SQLTypeInfoCore< TYPE_FACET_PACK >::get_scale(), and SQLTypeInfoCore< TYPE_FACET_PACK >::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:331
void set_scale(int s)
Definition: sqltypes.h:421
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 1315 of file Analyzer.cpp.

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

Definition at line 1432 of file Analyzer.cpp.

References Analyzer::Constant::get_is_null(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_notnull(), and Analyzer::Expr::get_type_info().

Referenced by is_in_values_nullable().

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

+ 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 1441 of file Analyzer.cpp.

References is_expr_nullable().

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

+ 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 }