OmniSciDB  5ade3759e0
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

◆ decimal_to_int_frac()

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

Definition at line 702 of file Analyzer.cpp.

References SQLTypeInfoCore< TYPE_FACET_PACK >::get_scale(), and SQLTypeInfoCore< TYPE_FACET_PACK >::set_scale().

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

702  {
703  if (ti.get_scale() > 18) {
704  auto truncated_ti = ti;
705  truncated_ti.set_scale(18);
706  auto truncated_dec = dec;
707  for (int i = 0; i < ti.get_scale() - 18; ++i) {
708  truncated_dec /= 10;
709  }
710  return decimal_to_int_frac(truncated_dec, truncated_ti);
711  }
712  int64_t integral_part = dec;
713  int64_t scale = 1;
714  for (int i = 0; i < ti.get_scale(); i++) {
715  integral_part /= 10;
716  scale *= 10;
717  }
718  return {integral_part, dec - integral_part * scale, scale};
719 }
HOST DEVICE int get_scale() const
Definition: sqltypes.h:328
void set_scale(int s)
Definition: sqltypes.h:418
IntFracRepr decimal_to_int_frac(const int64_t dec, const SQLTypeInfo &ti)
Definition: Analyzer.cpp:702
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expr_is()

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

Definition at line 1307 of file Analyzer.cpp.

1307  {
1308  return std::dynamic_pointer_cast<T>(expr) != nullptr;
1309 }

◆ is_expr_nullable()

bool Analyzer::anonymous_namespace{Analyzer.cpp}::is_expr_nullable ( const Analyzer::Expr expr)

Definition at line 1424 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().

1424  {
1425  const auto const_expr = dynamic_cast<const Analyzer::Constant*>(expr);
1426  if (const_expr) {
1427  return const_expr->get_is_null();
1428  }
1429  const auto& expr_ti = expr->get_type_info();
1430  return !expr_ti.get_notnull();
1431 }
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:330
bool get_is_null() const
Definition: Analyzer.h:327
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_in_values_nullable()

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

References is_expr_nullable(), and v().

1434  {
1435  if (is_expr_nullable(a.get())) {
1436  return true;
1437  }
1438  for (const auto& v : l) {
1439  if (is_expr_nullable(v.get())) {
1440  return true;
1441  }
1442  }
1443  return false;
1444 }
bool is_expr_nullable(const Analyzer::Expr *expr)
Definition: Analyzer.cpp:1424
T v(const TargetValue &r)
+ Here is the call graph for this function:

◆ safe_narrow()

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

Definition at line 722 of file Analyzer.cpp.

References v().

722  {
723  if (v > std::numeric_limits<T>::max() || v < std::numeric_limits<T>::min()) {
724  throw std::runtime_error("Overflow or underflow");
725  }
726  return static_cast<T>(v);
727 }
T v(const TargetValue &r)
+ Here is the call graph for this function: