OmniSciDB  c07336695a
ResultSetBaselineRadixSortTest.cpp File Reference

Unit tests for the result set baseline layout sort. More...

#include "../QueryEngine/Descriptors/RowSetMemoryOwner.h"
#include "../QueryEngine/ResultSet.h"
#include "../QueryEngine/RuntimeFunctions.h"
#include "ResultSetTestUtils.h"
#include "TestHelpers.h"
#include <gtest/gtest.h>
#include <algorithm>
#include <numeric>
#include <random>
+ Include dependency graph for ResultSetBaselineRadixSortTest.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}
 

Functions

std::vector< TargetInfoanonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::get_sort_int_target_infos ()
 
QueryMemoryDescriptor anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::baseline_sort_desc (const std::vector< TargetInfo > &target_infos, const size_t hash_entry_count, const size_t key_bytewidth)
 
template<class K >
void anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::fill_storage_buffer_baseline_sort_int (int8_t *buff, const std::vector< TargetInfo > &target_infos, const QueryMemoryDescriptor &query_mem_desc, const int64_t upper_bound, const int64_t empty_key)
 
void anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::fill_storage_buffer_baseline_sort_fp (int8_t *buff, const std::vector< TargetInfo > &target_infos, const QueryMemoryDescriptor &query_mem_desc, const int64_t upper_bound)
 
template<class T >
void anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::check_sorted (const ResultSet &result_set, const int64_t bound, const size_t top_n, const size_t desc)
 
std::vector< TargetInfoanonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::get_sort_fp_target_infos ()
 
template<class K >
int64_t anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::empty_key_val ()
 
template<>
int64_t anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::empty_key_val< int64_t > ()
 
template<>
int64_t anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::empty_key_val< int32_t > ()
 
template<class K >
void anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::SortBaselineIntegersTestImpl (const bool desc)
 
 TEST (SortBaseline, IntegersKey64)
 
 TEST (SortBaseline, IntegersKey32)
 
 TEST (SortBaseline, Floats)
 
int main (int argc, char **argv)
 

Detailed Description

Unit tests for the result set baseline layout sort.

Author
Alex Suhan alex@.nosp@m.mapd.nosp@m..com Copyright (c) 2016 MapD Technologies, Inc. All rights reserved.

Definition in file ResultSetBaselineRadixSortTest.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 266 of file ResultSetBaselineRadixSortTest.cpp.

References logger::ERROR, TestHelpers::init_logger_stderr_only(), LOG, and logger::WARNING.

266  {
268  testing::InitGoogleTest(&argc, argv);
269 
270 #ifdef HAVE_CUDA
271  try {
272  g_cuda_mgr.reset(new CudaMgr_Namespace::CudaMgr(0));
273  } catch (...) {
274  LOG(WARNING) << "Could not instantiate CudaMgr, will run on CPU";
275  }
276 #endif // HAVE_CUDA
277 
278  int err{0};
279  try {
280  err = RUN_ALL_TESTS();
281  } catch (const std::exception& e) {
282  LOG(ERROR) << e.what();
283  }
284 
285 #ifdef HAVE_CUDA
286  g_cuda_mgr.reset(nullptr);
287 #endif // HAVE_CUDA
288 
289  return err;
290 }
#define LOG(tag)
Definition: Logger.h:182
void init_logger_stderr_only(int argc, char const *const *argv)
Definition: TestHelpers.h:194
+ Here is the call graph for this function:

◆ TEST() [1/3]

TEST ( SortBaseline  ,
IntegersKey64   
)

Definition at line 230 of file ResultSetBaselineRadixSortTest.cpp.

230  {
231  for (const bool desc : {true, false}) {
232  SortBaselineIntegersTestImpl<int64_t>(desc);
233  }
234 }

◆ TEST() [2/3]

TEST ( SortBaseline  ,
IntegersKey32   
)

Definition at line 236 of file ResultSetBaselineRadixSortTest.cpp.

236  {
237  for (const bool desc : {true, false}) {
238  SortBaselineIntegersTestImpl<int32_t>(desc);
239  }
240 }

◆ TEST() [3/3]

TEST ( SortBaseline  ,
Floats   
)

Definition at line 242 of file ResultSetBaselineRadixSortTest.cpp.

References anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::baseline_sort_desc(), CPU, anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::fill_storage_buffer_baseline_sort_fp(), and anonymous_namespace{ResultSetBaselineRadixSortTest.cpp}::get_sort_fp_target_infos().

242  {
243  for (const bool desc : {true, false}) {
244  for (int tle_no = 1; tle_no <= 3; ++tle_no) {
245  const auto target_infos = get_sort_fp_target_infos();
246  const auto query_mem_desc = baseline_sort_desc(target_infos, 400, 8);
247  const auto row_set_mem_owner = std::make_shared<RowSetMemoryOwner>();
248  const int64_t upper_bound = 200;
249  std::unique_ptr<ResultSet> rs(new ResultSet(target_infos,
251  query_mem_desc,
252  row_set_mem_owner,
253  nullptr));
254  auto storage = rs->allocateStorage();
256  storage->getUnderlyingBuffer(), target_infos, query_mem_desc, upper_bound);
257  std::list<Analyzer::OrderEntry> order_entries;
258  order_entries.emplace_back(tle_no, desc, false);
259  const size_t top_n = 5;
260  rs->sort(order_entries, top_n);
261  check_sorted<float>(*rs, desc ? upper_bound : 1, top_n, desc);
262  }
263  }
264 }
void fill_storage_buffer_baseline_sort_fp(int8_t *buff, const std::vector< TargetInfo > &target_infos, const QueryMemoryDescriptor &query_mem_desc, const int64_t upper_bound)
QueryMemoryDescriptor baseline_sort_desc(const std::vector< TargetInfo > &target_infos, const size_t hash_entry_count, const size_t key_bytewidth)
+ Here is the call graph for this function: