OmniSciDB  04ee39c94c
anonymous_namespace{TopKTest.cpp} Namespace Reference

Classes

class  SQLiteComparator
 

Functions

void run_ddl_statement (const std::string query_str)
 
std::shared_ptr< ResultSetrun_multiple_agg (const string &query_str, const ExecutorDeviceType device_type, const bool allow_loop_joins)
 
std::shared_ptr< ResultSetrun_multiple_agg (const string &query_str, const ExecutorDeviceType device_type)
 
template<class T >
v (const TargetValue &r)
 
bool skip_tests (const ExecutorDeviceType device_type)
 
bool approx_eq (const double v, const double target, const double eps=0.01)
 
void c (const std::string &query_string, const std::string &sqlite_query_string, const ExecutorDeviceType device_type)
 
int create_and_populate_tables ()
 
void drop_tables ()
 

Variables

SQLiteComparator g_sqlite_comparator
 

Function Documentation

◆ approx_eq()

bool anonymous_namespace{TopKTest.cpp}::approx_eq ( const double  v,
const double  target,
const double  eps = 0.01 
)

Definition at line 73 of file TopKTest.cpp.

Referenced by anonymous_namespace{TopKTest.cpp}::SQLiteComparator::compare_impl().

73  {
74  const auto v_u64 = *reinterpret_cast<const uint64_t*>(may_alias_ptr(&v));
75  const auto target_u64 = *reinterpret_cast<const uint64_t*>(may_alias_ptr(&target));
76  return v_u64 == target_u64 || (target - eps < v && v < target + eps);
77 }
T v(const TargetValue &r)
+ Here is the caller graph for this function:

◆ c()

void anonymous_namespace{TopKTest.cpp}::c ( const std::string &  query_string,
const std::string &  sqlite_query_string,
const ExecutorDeviceType  device_type 
)

Definition at line 296 of file TopKTest.cpp.

References anonymous_namespace{TopKTest.cpp}::SQLiteComparator::compare().

Referenced by TEST().

298  {
299  g_sqlite_comparator.compare(query_string, sqlite_query_string, device_type);
300 }
SQLiteComparator g_sqlite_comparator
Definition: TopKTest.cpp:294
void compare(const std::string &query_string, const ExecutorDeviceType device_type)
Definition: TopKTest.cpp:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_and_populate_tables()

int anonymous_namespace{TopKTest.cpp}::create_and_populate_tables ( )

Definition at line 312 of file TopKTest.cpp.

References CPU, logger::ERROR, g_sqlite_comparator, LOG, anonymous_namespace{TopKTest.cpp}::SQLiteComparator::query(), run_ddl_statement(), and run_multiple_agg().

Referenced by main().

312  {
313  try {
314  // Drop old table
315  const std::string drop_old_test{"DROP TABLE IF EXISTS tdata;"};
316  run_ddl_statement(drop_old_test);
317  g_sqlite_comparator.query(drop_old_test);
318 
319  // Create a table
320  const std::string create_test_table{
321  "CREATE TABLE tdata (id SMALLINT, b BOOLEAN, i INT, bi BIGINT, n DECIMAL(10, 2), "
322  "f FLOAT, t TEXT, tt TIME, d "
323  "DATE, ts TIMESTAMP, vc VARCHAR(15));"};
324  run_ddl_statement(create_test_table);
325  g_sqlite_comparator.query(create_test_table);
326 
327  // Insert data into the table
328  std::vector<std::string> data_col_value_list;
329  data_col_value_list.emplace_back(
330  "1, 't', 23, 2349923, 111.1, 1.1, 'SFO', '15:13:14', '1999-09-09', '2014-12-13 "
331  "22:23:15', 'paris'");
332  data_col_value_list.emplace_back(
333  "2, 'f', null, -973273, 7263.11, 87.1, null, '20:05:00', '2017-12-12', "
334  "'2017-12-12 20:05:00', 'toronto'");
335  data_col_value_list.emplace_back(
336  "3, 'f', 702, 87395, 333.5, null, 'YVR', '11:11:11', '2010-01-01', '2010-01-02 "
337  "04:11:45', 'vancouver'");
338  data_col_value_list.emplace_back(
339  "4, null, 864, 100001, null, 9.9, 'SJC', null, '2015-05-05', '2010-05-05 "
340  "05:15:55', 'london'");
341  data_col_value_list.emplace_back(
342  "5, 'f', 333, 112233, 99.9, 9.9, 'ABQ', '22:22:22', '2015-05-05', '2010-05-05 "
343  "05:15:55', 'new york'");
344  data_col_value_list.emplace_back(
345  "6, 't', -3, 18, 765.8, 2.2, 'YYZ', '00:00:01', null, '2009-01-08 12:13:14', "
346  "null");
347  data_col_value_list.emplace_back(
348  "7, 'f', -9873, 3789, 789.3, 4.7, 'DCA', '11:22:33', '2001-02-03', '2005-04-03 "
349  "15:16:17', 'rio de janerio'");
350  data_col_value_list.emplace_back(
351  "8, 't', 12, 4321, 83.9, 1.2, 'DXB', '21:20:10', null, '2007-12-01 23:22:21', "
352  "'dubai'");
353  data_col_value_list.emplace_back(
354  "9, 't', 48, null, 83.9, 1.2, 'BWI', '09:08:07', '2001-09-11', null, "
355  "'washington'");
356  data_col_value_list.emplace_back(
357  "10, 'f', 99, 777, 77.7, 7.7, 'LLBG', '07:07:07', '2017-07-07', '2017-07-07 "
358  "07:07:07', 'Tel Aviv'");
359 
360  for (const auto& data_col_values : data_col_value_list) {
361  std::string insert_query = "INSERT INTO tdata VALUES(" + data_col_values + ");";
363  g_sqlite_comparator.query(insert_query);
364  }
365  } catch (...) {
366  LOG(ERROR) << "Failed to (re-)create table 'test'";
367  return -EEXIST;
368  }
369 
370  return 0;
371 }
SQLiteComparator g_sqlite_comparator
Definition: TopKTest.cpp:294
#define LOG(tag)
Definition: Logger.h:182
void query(const std::string &query_string)
Definition: TopKTest.cpp:83
void run_ddl_statement(std::string ddl)
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ drop_tables()

void anonymous_namespace{TopKTest.cpp}::drop_tables ( )

Definition at line 373 of file TopKTest.cpp.

References g_sqlite_comparator, anonymous_namespace{TopKTest.cpp}::SQLiteComparator::query(), and run_ddl_statement().

373  {
374  const std::string drop_test_inner{"DROP TABLE tdata;"};
375  run_ddl_statement(drop_test_inner);
376  g_sqlite_comparator.query(drop_test_inner);
377 }
SQLiteComparator g_sqlite_comparator
Definition: TopKTest.cpp:294
void query(const std::string &query_string)
Definition: TopKTest.cpp:83
void run_ddl_statement(std::string ddl)
+ Here is the call graph for this function:

◆ run_ddl_statement()

void anonymous_namespace{TopKTest.cpp}::run_ddl_statement ( const std::string  query_str)
inline

Definition at line 41 of file TopKTest.cpp.

References QueryRunner::QueryRunner::get(), and QueryRunner::QueryRunner::runDDLStatement().

41  {
42  QR::get()->runDDLStatement(query_str);
43 }
virtual void runDDLStatement(const std::string &)
static QueryRunner * get()
Definition: QueryRunner.h:115
+ Here is the call graph for this function:

◆ run_multiple_agg() [1/2]

std::shared_ptr<ResultSet> anonymous_namespace{TopKTest.cpp}::run_multiple_agg ( const string &  query_str,
const ExecutorDeviceType  device_type,
const bool  allow_loop_joins 
)

Definition at line 45 of file TopKTest.cpp.

References QueryRunner::QueryRunner::get(), and QueryRunner::QueryRunner::runSQL().

47  {
48  return QR::get()->runSQL(query_str, device_type, true, allow_loop_joins);
49 }
virtual std::shared_ptr< ResultSet > runSQL(const std::string &query_str, const ExecutorDeviceType device_type, const bool hoist_literals=true, const bool allow_loop_joins=true)
static QueryRunner * get()
Definition: QueryRunner.h:115
+ Here is the call graph for this function:

◆ run_multiple_agg() [2/2]

std::shared_ptr<ResultSet> anonymous_namespace{TopKTest.cpp}::run_multiple_agg ( const string &  query_str,
const ExecutorDeviceType  device_type 
)

Definition at line 51 of file TopKTest.cpp.

References run_multiple_agg().

52  {
53  return run_multiple_agg(query_str, device_type, true);
54 }
TQueryResult run_multiple_agg(std::string sql)
+ Here is the call graph for this function:

◆ skip_tests()

bool anonymous_namespace{TopKTest.cpp}::skip_tests ( const ExecutorDeviceType  device_type)

Definition at line 65 of file TopKTest.cpp.

References QueryRunner::QueryRunner::get(), GPU, and QueryRunner::QueryRunner::gpusPresent().

65  {
66 #ifdef HAVE_CUDA
67  return device_type == ExecutorDeviceType::GPU && !QR::get()->gpusPresent();
68 #else
69  return device_type == ExecutorDeviceType::GPU;
70 #endif
71 }
static QueryRunner * get()
Definition: QueryRunner.h:115
+ Here is the call graph for this function:

◆ v()

template<class T >
T anonymous_namespace{TopKTest.cpp}::v ( const TargetValue r)

Definition at line 57 of file TopKTest.cpp.

References CHECK.

57  {
58  auto scalar_r = boost::get<ScalarTargetValue>(&r);
59  CHECK(scalar_r);
60  auto p = boost::get<T>(scalar_r);
61  CHECK(p);
62  return *p;
63 }
#define CHECK(condition)
Definition: Logger.h:187

Variable Documentation

◆ g_sqlite_comparator

SQLiteComparator anonymous_namespace{TopKTest.cpp}::g_sqlite_comparator

Definition at line 294 of file TopKTest.cpp.

Referenced by create_and_populate_tables(), and drop_tables().