OmniSciDB  04ee39c94c
NumberColumnDescriptor< T > Class Template Reference
+ Inheritance diagram for NumberColumnDescriptor< T >:
+ Collaboration diagram for NumberColumnDescriptor< T >:

Public Member Functions

 NumberColumnDescriptor (std::string col_type, SQLTypes sql_type, T null)
 
bool skip_test (std::string name) override
 
std::string get_column_definition () override
 
std::string get_column_value (int row) override
 
bool check_column_value (int row, const TDatum *value) override
 
 NumberColumnDescriptor (std::string col_type, SQLTypes sql_type, T null)
 
bool skip_test (std::string name) override
 
std::string get_column_definition () override
 
std::string get_column_value (int row) override
 
bool check_column_value (int row, const SQLTypeInfo &type, const ScalarTargetValue *value) override
 
int64_t pow10 (int scale)
 
- Public Member Functions inherited from TestColumnDescriptor
virtual std::string get_update_column_value (int row)
 
virtual ~TestColumnDescriptor ()=default
 
virtual std::string get_update_column_value (int row)
 
virtual bool check_column_value (const int row, const SQLTypeInfo &type, const TargetValue *value)
 
virtual ~TestColumnDescriptor ()=default
 

Private Attributes

std::string column_definition
 
SQLTypes rs_type
 
null_value
 

Detailed Description

template<typename T>
class NumberColumnDescriptor< T >

Definition at line 139 of file CtasIntegrationTest.cpp.

Constructor & Destructor Documentation

◆ NumberColumnDescriptor() [1/2]

template<typename T >
NumberColumnDescriptor< T >::NumberColumnDescriptor ( std::string  col_type,
SQLTypes  sql_type,
null 
)
inline

Definition at line 145 of file CtasIntegrationTest.cpp.

◆ NumberColumnDescriptor() [2/2]

template<typename T >
NumberColumnDescriptor< T >::NumberColumnDescriptor ( std::string  col_type,
SQLTypes  sql_type,
null 
)
inline

Definition at line 71 of file CtasUpdateTest.cpp.

Member Function Documentation

◆ check_column_value() [1/2]

template<typename T >
bool NumberColumnDescriptor< T >::check_column_value ( int  row,
const SQLTypeInfo type,
const ScalarTargetValue value 
)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 92 of file CtasUpdateTest.cpp.

References logger::ERROR, SQLTypeInfoCore< TYPE_FACET_PACK >::get_scale(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kDECIMAL, LOG, and to_string().

94  {
95  if (type.get_type() != rs_type) {
96  return false;
97  }
98 
99  const auto mapd_as_int_p = boost::get<T>(value);
100  if (nullptr == mapd_as_int_p) {
101  LOG(ERROR) << "row: null";
102  return false;
103  }
104 
105  const auto mapd_val = *mapd_as_int_p;
106 
107  T value_to_check = (T)row;
108  if (row == 0) {
109  value_to_check = null_value;
110  } else if (kDECIMAL == rs_type) {
111  // TODO: create own descriptor for decimals
112  value_to_check *= pow10(type.get_scale());
113  }
114 
115  if (mapd_val == value_to_check) {
116  return true;
117  }
118 
119  LOG(ERROR) << "row: " << std::to_string(row) << " " << std::to_string(value_to_check)
120  << " vs. " << std::to_string(mapd_val);
121  return false;
122  }
#define LOG(tag)
Definition: Logger.h:182
HOST DEVICE int get_scale() const
Definition: sqltypes.h:328
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
std::string to_string(char const *&&v)
int64_t pow10(int scale)
+ Here is the call graph for this function:

◆ check_column_value() [2/2]

template<typename T >
bool NumberColumnDescriptor< T >::check_column_value ( int  row,
const TDatum *  value 
)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 167 of file CtasIntegrationTest.cpp.

References checked_get(), logger::ERROR, LOG, and to_string().

167  {
168  T mapd_val;
169 
170  if (!checked_get(row, value, mapd_val, null_value)) {
171  return false;
172  }
173 
174  T value_to_check = (T)row;
175  if (row == 0) {
176  value_to_check = null_value;
177  }
178 
179  if (mapd_val == value_to_check) {
180  return true;
181  }
182 
183  LOG(ERROR) << "row: " << std::to_string(row) << " " << std::to_string(value_to_check)
184  << " vs. " << std::to_string(mapd_val);
185  return false;
186  }
#define LOG(tag)
Definition: Logger.h:182
std::string to_string(char const *&&v)
bool checked_get(size_t row, const SOURCE_TYPE *boost_variant, RETURN_TYPE &val, RETURN_TYPE null_value)
+ Here is the call graph for this function:

◆ get_column_definition() [1/2]

template<typename T >
std::string NumberColumnDescriptor< T >::get_column_definition ( )
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 84 of file CtasUpdateTest.cpp.

84 { return column_definition; };

◆ get_column_definition() [2/2]

template<typename T >
std::string NumberColumnDescriptor< T >::get_column_definition ( )
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 158 of file CtasIntegrationTest.cpp.

158 { return column_definition; };

◆ get_column_value() [1/2]

template<typename T >
std::string NumberColumnDescriptor< T >::get_column_value ( int  row)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 85 of file CtasUpdateTest.cpp.

References to_string().

85  {
86  if (0 == row) {
87  return "null";
88  }
89 
90  return std::to_string(row);
91  };
std::string to_string(char const *&&v)
+ Here is the call graph for this function:

◆ get_column_value() [2/2]

template<typename T >
std::string NumberColumnDescriptor< T >::get_column_value ( int  row)
inlineoverridevirtual

Implements TestColumnDescriptor.

Definition at line 159 of file CtasIntegrationTest.cpp.

References to_string().

159  {
160  if (0 == row) {
161  return "null";
162  }
163 
164  return std::to_string(row);
165  };
std::string to_string(char const *&&v)
+ Here is the call graph for this function:

◆ pow10()

template<typename T >
int64_t NumberColumnDescriptor< T >::pow10 ( int  scale)
inline

Definition at line 124 of file CtasUpdateTest.cpp.

124  {
125  int64_t pow = 1;
126  for (int i = 0; i < scale; i++) {
127  pow *= 10;
128  }
129 
130  return pow;
131  }

◆ skip_test() [1/2]

template<typename T >
bool NumberColumnDescriptor< T >::skip_test ( std::string  name)
inlineoverridevirtual

Reimplemented from TestColumnDescriptor.

Definition at line 74 of file CtasUpdateTest.cpp.

References kDECIMAL, kDOUBLE, and kFLOAT.

74  {
75  if (kDECIMAL == rs_type) {
76  return "Array.UpdateColumnByLiteral" == name;
77  }
78  if (kDOUBLE == rs_type || kFLOAT == rs_type) {
79  return "Array.UpdateColumnByLiteral" == name;
80  }
81  return false;
82  }

◆ skip_test() [2/2]

template<typename T >
bool NumberColumnDescriptor< T >::skip_test ( std::string  name)
inlineoverridevirtual

Reimplemented from TestColumnDescriptor.

Definition at line 148 of file CtasIntegrationTest.cpp.

References kDECIMAL, kDOUBLE, and kFLOAT.

148  {
149  if (kDECIMAL == rs_type) {
150  return "Array.UpdateColumnByLiteral" == name;
151  }
152  if (kDOUBLE == rs_type || kFLOAT == rs_type) {
153  return "Array.UpdateColumnByLiteral" == name;
154  }
155  return false;
156  }

Member Data Documentation

◆ column_definition

template<typename T >
std::string NumberColumnDescriptor< T >::column_definition
private

Definition at line 140 of file CtasIntegrationTest.cpp.

◆ null_value

template<typename T >
T NumberColumnDescriptor< T >::null_value
private

Definition at line 142 of file CtasIntegrationTest.cpp.

◆ rs_type

template<typename T >
SQLTypes NumberColumnDescriptor< T >::rs_type
private

Definition at line 141 of file CtasIntegrationTest.cpp.


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