OmniSciDB  c07336695a
anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator Class Reference
+ Collaboration diagram for anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator:

Public Member Functions

 ResultSetEmulator (int8_t *buff1, int8_t *buff2, const std::vector< TargetInfo > &target_infos, const QueryMemoryDescriptor &query_mem_desc, NumberGenerator &gen1, NumberGenerator &gen2, const size_t perc1, const size_t perc2, const size_t flow, const bool silent)
 
 ~ResultSetEmulator ()
 
std::queue< std::vector< int64_t > > getReferenceTable () const
 
std::vector< bool > getReferenceGroupMap () const
 
bool getReferenceGroupMapElement (size_t idx)
 
std::vector< int64_t > getReferenceRow (bool keep_row=false)
 
int64_t rse_get_null_val ()
 
void print_rse_generated_result_sets () const
 
void print_merged_result_sets (const std::vector< OneRow > &result)
 

Private Member Functions

void emulateResultSets ()
 
void createResultSet (size_t rs_perc, std::vector< bool > &rs_groups)
 
void mergeResultSets ()
 
void rse_fill_storage_buffer_perfect_hash_colwise (int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
 
void rse_fill_storage_buffer_perfect_hash_rowwise (int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
 
void rse_fill_storage_buffer_baseline_colwise (int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
 
void rse_fill_storage_buffer_baseline_rowwise (int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
 
void rse_fill_storage_buffer (int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
 
void print_emulator_diag ()
 
int64_t rseAggregateKMIN (size_t i)
 
int64_t rseAggregateKMAX (size_t i)
 
int64_t rseAggregateKAVG (size_t i)
 
int64_t rseAggregateKSUM (size_t i)
 
int64_t rseAggregateKCOUNT (size_t i)
 

Private Attributes

int8_t * rs1_buff
 
int8_t * rs2_buff
 
const std::vector< TargetInfors_target_infos
 
const QueryMemoryDescriptor rs_query_mem_desc
 
NumberGeneratorrs1_gen
 
NumberGeneratorrs2_gen
 
size_t rs1_perc
 
size_t rs2_perc
 
size_t rs_flow
 
size_t rs_entry_count
 
bool rs_silent
 
std::vector< bool > rs1_groups
 
std::vector< bool > rs2_groups
 
std::vector< bool > rseReducedGroups
 
std::vector< int64_t > rs1_values
 
std::vector< int64_t > rs2_values
 
std::queue< std::vector< int64_t > > rseReducedTable
 

Detailed Description

Definition at line 61 of file ResultSetTest.cpp.

Constructor & Destructor Documentation

◆ ResultSetEmulator()

anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::ResultSetEmulator ( int8_t *  buff1,
int8_t *  buff2,
const std::vector< TargetInfo > &  target_infos,
const QueryMemoryDescriptor query_mem_desc,
NumberGenerator gen1,
NumberGenerator gen2,
const size_t  perc1,
const size_t  perc2,
const size_t  flow,
const bool  silent 
)
inline

Definition at line 63 of file ResultSetTest.cpp.

References QueryMemoryDescriptor::getEntryCount().

73  :
74 
75  rs1_buff(buff1)
76  , rs2_buff(buff2)
77  , rs_target_infos(target_infos)
78  , rs_query_mem_desc(query_mem_desc)
79  , rs1_gen(gen1)
80  , rs2_gen(gen2)
81  , rs1_perc(perc1)
82  , rs2_perc(perc2)
83  , rs_flow(flow)
84  , rs_entry_count(query_mem_desc.getEntryCount())
85  , rs_silent(silent) {
87  query_mem_desc.getEntryCount(); // it's set to 10 in "small" query_mem_descriptor
88  rs1_groups.resize(rs_entry_count);
89  std::fill(rs1_groups.begin(), rs1_groups.end(), false);
90  rs2_groups.resize(rs_entry_count);
91  std::fill(rs2_groups.begin(), rs2_groups.end(), false);
92  rs1_values.resize(rs_entry_count);
93  std::fill(rs1_values.begin(), rs1_values.end(), 0);
94  rs2_values.resize(rs_entry_count);
95  std::fill(rs2_values.begin(), rs2_values.end(), 0);
97  std::fill(rseReducedGroups.begin(), rseReducedGroups.end(), false);
98 
100  }
+ Here is the call graph for this function:

◆ ~ResultSetEmulator()

anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::~ResultSetEmulator ( )
inline

Definition at line 101 of file ResultSetTest.cpp.

101 {};

Member Function Documentation

◆ createResultSet()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::createResultSet ( size_t  rs_perc,
std::vector< bool > &  rs_groups 
)
private

Definition at line 228 of file ResultSetTest.cpp.

228  {
229  std::vector<int> rs_groups_idx;
230  rs_groups_idx.resize(rs_entry_count);
231  std::iota(rs_groups_idx.begin(), rs_groups_idx.end(), 0);
232  std::random_device rs_rd;
233  std::mt19937 rs_rand_gen(rs_rd());
234  std::shuffle(rs_groups_idx.begin(), rs_groups_idx.end(), rs_rand_gen);
235 
236  for (size_t i = 0; i < (rs_entry_count * rs_perc / 100); i++) {
237  if (!rs_silent) {
238  printf(" %i", rs_groups_idx[i]);
239  }
240  rs_groups[rs_groups_idx[i]] = true;
241  }
242 }

◆ emulateResultSets()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::emulateResultSets ( )
private

Definition at line 180 of file ResultSetTest.cpp.

180  {
181  /* generate topology of ResultSet #1 */
182  if (!rs_silent) {
183  printf("\nResultSetEmulator (ResultSet #1): ");
184  }
185 
187  if (!rs_silent) {
188  printf("\n");
189  for (size_t i = 0; i < rs1_groups.size(); i++) {
190  if (rs1_groups[i]) {
191  printf("1");
192  } else {
193  printf("0");
194  }
195  }
196  }
197 
198  /* generate topology of ResultSet #2 */
199  if (!rs_silent) {
200  printf("\nResultSetEmulator (ResultSet #2): ");
201  }
202 
204  if (!rs_silent) {
205  printf("\n");
206  for (size_t i = 0; i < rs2_groups.size(); i++) {
207  if (rs2_groups[i]) {
208  printf("1");
209  } else {
210  printf("0");
211  }
212  }
213  printf("\n");
214  }
215 
216  /* populate both ResultSet's buffers with real data */
217  // print_emulator_diag();
219  // print_emulator_diag();
221  // print_emulator_diag();
222 
223  /* merge/reduce data contained in both ResultSets and generate golden values */
224  mergeResultSets();
225 }
void rse_fill_storage_buffer(int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
void createResultSet(size_t rs_perc, std::vector< bool > &rs_groups)

◆ getReferenceGroupMap()

std::vector<bool> anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::getReferenceGroupMap ( ) const
inline

Definition at line 104 of file ResultSetTest.cpp.

Referenced by anonymous_namespace{ResultSetTest.cpp}::test_reduce_random_groups().

+ Here is the caller graph for this function:

◆ getReferenceGroupMapElement()

bool anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::getReferenceGroupMapElement ( size_t  idx)
inline

Definition at line 105 of file ResultSetTest.cpp.

References CHECK_LE.

Referenced by anonymous_namespace{ResultSetTest.cpp}::test_reduce_random_groups().

105  {
106  CHECK_LE(idx, rseReducedGroups.size() - 1);
107  return rseReducedGroups[idx];
108  }
#define CHECK_LE(x, y)
Definition: Logger.h:198
+ Here is the caller graph for this function:

◆ getReferenceRow()

std::vector<int64_t> anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::getReferenceRow ( bool  keep_row = false)
inline

Definition at line 109 of file ResultSetTest.cpp.

Referenced by anonymous_namespace{ResultSetTest.cpp}::test_reduce_random_groups().

109  {
110  std::vector<int64_t> rse_reduced_row(rseReducedTable.front());
111  rseReducedTable.pop();
112  if (keep_row) {
113  rseReducedTable.push(rse_reduced_row);
114  }
115  return rse_reduced_row;
116  }
std::queue< std::vector< int64_t > > rseReducedTable
+ Here is the caller graph for this function:

◆ getReferenceTable()

std::queue<std::vector<int64_t> > anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::getReferenceTable ( ) const
inline

Definition at line 103 of file ResultSetTest.cpp.

Referenced by anonymous_namespace{ResultSetTest.cpp}::test_reduce_random_groups().

103 { return rseReducedTable; }
std::queue< std::vector< int64_t > > rseReducedTable
+ Here is the caller graph for this function:

◆ mergeResultSets()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::mergeResultSets ( )
private

Definition at line 245 of file ResultSetTest.cpp.

References CHECK, kAVG, kCOUNT, kMAX, kMIN, and kSUM.

245  {
246  std::vector<int64_t> rse_reduced_row;
247  rse_reduced_row.resize(rs_target_infos.size());
248 
249  for (size_t j = 0; j < rs_entry_count; j++) { // iterates through rows
250  if (rs1_groups[j] || rs2_groups[j]) {
251  rseReducedGroups[j] = true;
252  for (size_t i = 0; i < rs_target_infos.size(); i++) { // iterates through columns
253  switch (rs_target_infos[i].agg_kind) {
254  case kMIN: {
255  rse_reduced_row[i] = rseAggregateKMIN(j);
256  break;
257  }
258  case kMAX: {
259  rse_reduced_row[i] = rseAggregateKMAX(j);
260  break;
261  }
262  case kAVG: {
263  rse_reduced_row[i] = rseAggregateKAVG(j);
264  break;
265  }
266  case kSUM: {
267  rse_reduced_row[i] = rseAggregateKSUM(j);
268  break;
269  }
270  case kCOUNT: {
271  rse_reduced_row[i] = rseAggregateKCOUNT(j);
272  break;
273  }
274  default:
275  CHECK(false);
276  }
277  }
278  rseReducedTable.push(rse_reduced_row);
279  }
280  }
281 }
Definition: sqldefs.h:71
Definition: sqldefs.h:71
Definition: sqldefs.h:71
#define CHECK(condition)
Definition: Logger.h:187
std::queue< std::vector< int64_t > > rseReducedTable
Definition: sqldefs.h:71
Definition: sqldefs.h:71

◆ print_emulator_diag()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::print_emulator_diag ( )
private

Definition at line 607 of file ResultSetTest.cpp.

607  {
608  if (!rs_silent) {
609  for (size_t j = 0; j < rs_entry_count; j++) {
610  int g1 = 0, g2 = 0;
611  if (rs1_groups[j]) {
612  g1 = 1;
613  }
614  if (rs2_groups[j]) {
615  g2 = 1;
616  }
617  printf("\nGroup #%i (%i,%i): Buf1=%lld Buf2=%lld",
618  (int)j,
619  g1,
620  g2,
621  static_cast<long long>(rs1_values[j]),
622  static_cast<long long>(rs2_values[j]));
623  }
624  }
625 }

◆ print_merged_result_sets()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::print_merged_result_sets ( const std::vector< OneRow > &  result)

Definition at line 654 of file ResultSetTest.cpp.

Referenced by anonymous_namespace{ResultSetTest.cpp}::test_reduce_random_groups().

654  {
655  printf("\n ****** KMIN_DATA_FROM_RS_MERGE_CODE ****** %i", (int)result.size());
656  size_t j = 0;
657  for (const auto& row : result) {
658  const auto ival_0 = v<int64_t>(row[0]); // kMIN
659  const auto ival_1 = v<int64_t>(row[1]); // kMAX
660  const auto ival_2 = v<int64_t>(row[2]); // kSUM
661  const auto ival_3 = v<int64_t>(row[3]); // kCOUNT
662  const auto ival_4 = v<double>(row[4]); // kAVG
663  printf("\n Group #%i KMIN/KMAX/KSUM/KCOUNT from RS_MergeCode: %lld %lld %lld %lld %f",
664  (int)j,
665  static_cast<long long>(ival_0),
666  static_cast<long long>(ival_1),
667  static_cast<long long>(ival_2),
668  static_cast<long long>(ival_3),
669  ival_4);
670  j++;
671  }
672 
673  size_t active_group_count = 0;
674  for (size_t j = 0; j < rseReducedGroups.size(); j++) {
675  if (rseReducedGroups[j]) {
676  active_group_count++;
677  }
678  }
679  printf("\n\n ****** KMIN_DATA_FROM_MERGE_BUFFER_CODE ****** Total: %i, Active: %i",
680  (int)rs_entry_count,
681  (int)active_group_count);
682  size_t num_groups = getReferenceTable().size();
683  for (size_t i = 0; i < num_groups; i++) {
684  std::vector<int64_t> ref_row = getReferenceRow(true);
685  int64_t ref_val_0 = ref_row[0]; // kMIN
686  int64_t ref_val_1 = ref_row[1]; // kMAX
687  int64_t ref_val_2 = ref_row[2]; // kSUM
688  int64_t ref_val_3 = ref_row[3]; // kCOUNT
689  int64_t ref_val_4 = ref_row[4]; // kAVG
690  printf(
691  "\n Group #%i KMIN/KMAX/KSUM/KCOUNT from ReducedBuffer: %lld %lld %lld %lld %f",
692  static_cast<int>(i),
693  static_cast<long long>(ref_val_0),
694  static_cast<long long>(ref_val_1),
695  static_cast<long long>(ref_val_2),
696  static_cast<long long>(ref_val_3),
697  static_cast<double>(ref_val_4));
698  }
699  printf("\n");
700 }
std::queue< std::vector< int64_t > > getReferenceTable() const
std::vector< int64_t > getReferenceRow(bool keep_row=false)
+ Here is the caller graph for this function:

◆ print_rse_generated_result_sets()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::print_rse_generated_result_sets ( ) const

Definition at line 633 of file ResultSetTest.cpp.

Referenced by anonymous_namespace{ResultSetTest.cpp}::test_reduce_random_groups().

633  {
634  printf("\nResultSet #1 Final Groups: ");
635  for (size_t i = 0; i < rs1_groups.size(); i++) {
636  if (rs1_groups[i]) {
637  printf("1");
638  } else {
639  printf("0");
640  }
641  }
642 
643  printf("\nResultSet #2 Final Groups: ");
644  for (size_t i = 0; i < rs2_groups.size(); i++) {
645  if (rs2_groups[i]) {
646  printf("1");
647  } else {
648  printf("0");
649  }
650  }
651  printf("\n");
652 }
+ Here is the caller graph for this function:

◆ rse_fill_storage_buffer()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rse_fill_storage_buffer ( int8_t *  buff,
NumberGenerator generator,
const std::vector< bool > &  rs_groups,
std::vector< int64_t > &  rs_values 
)
private

Definition at line 570 of file ResultSetTest.cpp.

References CHECK, GroupByBaselineHash, and GroupByPerfectHash.

573  {
578  buff, generator, rs_groups, rs_values);
579  } else {
581  buff, generator, rs_groups, rs_values);
582  }
583  break;
584  }
587  rse_fill_storage_buffer_baseline_colwise(buff, generator, rs_groups, rs_values);
588  } else {
589  rse_fill_storage_buffer_baseline_rowwise(buff, generator, rs_groups, rs_values);
590  }
591  break;
592  }
593  default:
594  CHECK(false);
595  }
596  CHECK(buff);
597 }
void rse_fill_storage_buffer_perfect_hash_colwise(int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
void rse_fill_storage_buffer_baseline_rowwise(int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
void rse_fill_storage_buffer_perfect_hash_rowwise(int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
void rse_fill_storage_buffer_baseline_colwise(int8_t *buff, NumberGenerator &generator, const std::vector< bool > &rs_groups, std::vector< int64_t > &rs_values)
#define CHECK(condition)
Definition: Logger.h:187
QueryDescriptionType getQueryDescriptionType() const

◆ rse_fill_storage_buffer_baseline_colwise()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rse_fill_storage_buffer_baseline_colwise ( int8_t *  buff,
NumberGenerator generator,
const std::vector< bool > &  rs_groups,
std::vector< int64_t > &  rs_values 
)
private

Definition at line 448 of file ResultSetTest.cpp.

References CHECK, EMPTY_KEY_64, fill_one_entry_one_col(), get_group_value_columnar(), NumberGenerator::getNextValue(), inline_int_null_val(), kAVG, kCOUNT, key_offset_colwise(), slot_offset_colwise(), and v().

452  {
454  const auto key_component_count = rs_query_mem_desc.getKeyCount();
455  const auto i64_buff = reinterpret_cast<int64_t*>(buff);
456  for (size_t i = 0; i < rs_entry_count; i++) {
457  for (size_t key_comp_idx = 0; key_comp_idx < key_component_count; ++key_comp_idx) {
458  i64_buff[key_offset_colwise(i, key_comp_idx, rs_entry_count)] = EMPTY_KEY_64;
459  }
460  size_t target_slot = 0;
461  int64_t init_val = 0;
462  for (const auto& target_info : rs_target_infos) {
463  if (target_info.agg_kind == kCOUNT) {
464  init_val = 0;
465  } else if (!target_info.sql_type.get_notnull() && target_info.skip_null_val &&
466  (rs_flow == 2)) { // null_val support
467  init_val = inline_int_null_val(target_info.sql_type);
468  } else {
469  init_val = 0xdeadbeef;
470  }
471  if (target_info.agg_kind != kAVG) {
472  i64_buff[slot_offset_colwise(
473  i, target_slot, key_component_count, rs_entry_count)] = init_val;
474  } else {
475  i64_buff[slot_offset_colwise(
476  i, target_slot, key_component_count, rs_entry_count)] = 0;
477  }
478  target_slot++;
479  }
480  }
481  for (size_t i = 0; i < rs_entry_count; i++) {
482  const auto v = generator.getNextValue();
483  if (rs_groups[i]) {
484  bool null_val = false;
485  if ((rs_flow == 2) &&
486  (i >= rs_entry_count - 4)) { // null_val test-cases: last four rows
487  rs_values[i] = -1;
488  null_val = true;
489  } else {
490  rs_values[i] = v;
491  }
492  std::vector<int64_t> key(key_component_count, v);
493  auto value_slots =
494  get_group_value_columnar(i64_buff, rs_entry_count, &key[0], key.size());
495  CHECK(value_slots);
496  for (const auto& target_info : rs_target_infos) {
498  value_slots, v, target_info, rs_entry_count, false, null_val);
499  value_slots += rs_entry_count;
500  if (target_info.agg_kind == kAVG) {
501  value_slots += rs_entry_count;
502  }
503  }
504  }
505  }
506 }
NEVER_INLINE DEVICE int64_t * get_group_value_columnar(int64_t *groups_buffer, const uint32_t groups_buffer_entry_count, const int64_t *key, const uint32_t key_qw_count)
#define EMPTY_KEY_64
size_t slot_offset_colwise(const size_t entry_idx, const size_t slot_idx, const size_t key_count, const size_t entry_count)
void fill_one_entry_one_col(int8_t *ptr1, const int8_t compact_sz1, int8_t *ptr2, const int8_t compact_sz2, int64_t v, const TargetInfo &target_info, const bool empty_entry, const bool null_val)
T v(const TargetValue &r)
size_t key_offset_colwise(const size_t entry_idx, const size_t key_idx, const size_t entry_count)
Definition: sqldefs.h:71
#define CHECK(condition)
Definition: Logger.h:187
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
virtual int64_t getNextValue()=0
Definition: sqldefs.h:71
+ Here is the call graph for this function:

◆ rse_fill_storage_buffer_baseline_rowwise()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rse_fill_storage_buffer_baseline_rowwise ( int8_t *  buff,
NumberGenerator generator,
const std::vector< bool > &  rs_groups,
std::vector< int64_t > &  rs_values 
)
private

Definition at line 508 of file ResultSetTest.cpp.

References CHECK, CHECK_EQ, EMPTY_KEY_64, fill_one_entry_baseline(), get_group_value(), get_slot_count(), NumberGenerator::getNextValue(), inline_int_null_val(), kAVG, kCOUNT, key_offset_rowwise(), slot_offset_rowwise(), and v().

512  {
514  CHECK_EQ(rs_groups.size(), rs_query_mem_desc.getEntryCount());
515  const auto key_component_count = rs_query_mem_desc.getKeyCount();
516  const auto i64_buff = reinterpret_cast<int64_t*>(buff);
517  const auto target_slot_count = get_slot_count(rs_target_infos);
518  for (size_t i = 0; i < rs_entry_count; i++) {
519  const auto first_key_comp_offset =
520  key_offset_rowwise(i, key_component_count, target_slot_count);
521  for (size_t key_comp_idx = 0; key_comp_idx < key_component_count; ++key_comp_idx) {
522  i64_buff[first_key_comp_offset + key_comp_idx] = EMPTY_KEY_64;
523  }
524  size_t target_slot = 0;
525  int64_t init_val = 0;
526  for (const auto& target_info : rs_target_infos) {
527  if (target_info.agg_kind == kCOUNT) {
528  init_val = 0;
529  } else if (!target_info.sql_type.get_notnull() && target_info.skip_null_val &&
530  (rs_flow == 2)) { // null_val support
531  init_val = inline_int_null_val(target_info.sql_type);
532  } else {
533  init_val = 0xdeadbeef;
534  }
535  i64_buff[slot_offset_rowwise(
536  i, target_slot, key_component_count, target_slot_count)] = init_val;
537  target_slot++;
538  if (target_info.agg_kind == kAVG) {
539  i64_buff[slot_offset_rowwise(
540  i, target_slot, key_component_count, target_slot_count)] = 0;
541  target_slot++;
542  }
543  }
544  }
545 
546  for (size_t i = 0; i < rs_entry_count; i++) {
547  const auto v = generator.getNextValue();
548  if (rs_groups[i]) {
549  std::vector<int64_t> key(key_component_count, v);
550  auto value_slots = get_group_value(i64_buff,
551  rs_entry_count,
552  &key[0],
553  key.size(),
554  sizeof(int64_t),
555  key_component_count + target_slot_count,
556  nullptr);
557  CHECK(value_slots);
558  if ((rs_flow == 2) &&
559  (i >= rs_entry_count - 4)) { // null_val test-cases: last four rows
560  rs_values[i] = -1;
561  fill_one_entry_baseline(value_slots, v, rs_target_infos, false, true);
562  } else {
563  rs_values[i] = v;
564  fill_one_entry_baseline(value_slots, v, rs_target_infos, false, false);
565  }
566  }
567  }
568 }
size_t slot_offset_rowwise(const size_t entry_idx, const size_t slot_idx, const size_t key_count, const size_t slot_count)
#define CHECK_EQ(x, y)
Definition: Logger.h:195
#define EMPTY_KEY_64
size_t get_slot_count(const std::vector< TargetInfo > &target_infos)
T v(const TargetValue &r)
NEVER_INLINE DEVICE int64_t * get_group_value(int64_t *groups_buffer, const uint32_t groups_buffer_entry_count, const int64_t *key, const uint32_t key_count, const uint32_t key_width, const uint32_t row_size_quad, const int64_t *init_vals)
Definition: sqldefs.h:71
size_t key_offset_rowwise(const size_t entry_idx, const size_t key_count, const size_t slot_count)
#define CHECK(condition)
Definition: Logger.h:187
void fill_one_entry_baseline(int64_t *value_slots, const int64_t v, const std::vector< TargetInfo > &target_infos, const bool empty, const bool null_val)
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
virtual int64_t getNextValue()=0
Definition: sqldefs.h:71
+ Here is the call graph for this function:

◆ rse_fill_storage_buffer_perfect_hash_colwise()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rse_fill_storage_buffer_perfect_hash_colwise ( int8_t *  buff,
NumberGenerator generator,
const std::vector< bool > &  rs_groups,
std::vector< int64_t > &  rs_values 
)
private

Definition at line 283 of file ResultSetTest.cpp.

References advance_slot(), advance_to_next_columnar_key_buff(), advance_to_next_columnar_target_buff(), CHECK, CHECK_EQ, EMPTY_KEY_64, fill_one_entry_one_col(), NumberGenerator::getNextValue(), kAVG, NumberGenerator::reset(), v(), and write_key().

287  {
288  const auto key_component_count = rs_query_mem_desc.getKeyCount();
290  // initialize the key buffer(s)
291  auto col_ptr = buff;
292  for (size_t key_idx = 0; key_idx < key_component_count; ++key_idx) {
293  auto key_entry_ptr = col_ptr;
294  const auto key_bytes = rs_query_mem_desc.groupColWidth(key_idx);
295  CHECK_EQ(8, key_bytes);
296  for (size_t i = 0; i < rs_entry_count; i++) {
297  const auto v = generator.getNextValue();
298  if (rs_groups[i]) {
299  // const auto v = generator.getNextValue();
300  write_key(v, key_entry_ptr, key_bytes);
301  } else {
302  write_key(EMPTY_KEY_64, key_entry_ptr, key_bytes);
303  }
304  key_entry_ptr += key_bytes;
305  }
306  col_ptr = advance_to_next_columnar_key_buff(col_ptr, rs_query_mem_desc, key_idx);
307  generator.reset();
308  }
309  // initialize the value buffer(s)
310  size_t slot_idx = 0;
311  for (const auto& target_info : rs_target_infos) {
312  auto col_entry_ptr = col_ptr;
313  const auto col_bytes = rs_query_mem_desc.getPaddedSlotWidthBytes(slot_idx);
314  for (size_t i = 0; i < rs_entry_count; i++) {
315  int8_t* ptr2{nullptr};
316  if (target_info.agg_kind == kAVG) {
317  ptr2 = col_entry_ptr + rs_query_mem_desc.getEntryCount() * col_bytes;
318  }
319  const auto v = generator.getNextValue();
320  if (rs_groups[i]) {
321  // const auto v = generator.getNextValue();
322  rs_values[i] = v;
323  if (rs_flow == 2) { // null_val test-cases
324  if (i >= rs_entry_count - 4) { // only the last four rows of RS #1 and RS #2
325  // exersized for null_val test
326  rs_values[i] = -1;
328  col_entry_ptr,
329  col_bytes,
330  ptr2,
332  v,
333  target_info,
334  false,
335  true);
336  } else {
338  col_entry_ptr,
339  col_bytes,
340  ptr2,
342  v,
343  target_info,
344  false,
345  false);
346  }
347  } else {
348  fill_one_entry_one_col(col_entry_ptr,
349  col_bytes,
350  ptr2,
352  v,
353  target_info,
354  false,
355  false);
356  }
357  } else {
358  if (rs_flow == 2) { // null_val test-cases
359  if (i >= rs_entry_count - 4) { // only the last four rows of RS #1 and RS #2
360  // exersized for null_val test
361  rs_values[i] = -1;
362  }
363  fill_one_entry_one_col(col_entry_ptr,
364  col_bytes,
365  ptr2,
367  rs_query_mem_desc.hasKeylessHash() ? 0 : 0xdeadbeef,
368  target_info,
369  true,
370  true);
371  } else {
372  fill_one_entry_one_col(col_entry_ptr,
373  col_bytes,
374  ptr2,
376  rs_query_mem_desc.hasKeylessHash() ? 0 : 0xdeadbeef,
377  target_info,
378  true,
379  false);
380  }
381  }
382  col_entry_ptr += col_bytes;
383  }
384  col_ptr = advance_to_next_columnar_target_buff(col_ptr, rs_query_mem_desc, slot_idx);
385  if (target_info.is_agg && target_info.agg_kind == kAVG) {
386  col_ptr =
388  }
389  slot_idx = advance_slot(slot_idx, target_info, false);
390  generator.reset();
391  }
392 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
#define EMPTY_KEY_64
void fill_one_entry_one_col(int8_t *ptr1, const int8_t compact_sz1, int8_t *ptr2, const int8_t compact_sz2, int64_t v, const TargetInfo &target_info, const bool empty_entry, const bool null_val)
T advance_to_next_columnar_target_buff(T target_ptr, const QueryMemoryDescriptor &query_mem_desc, const size_t target_slot_idx)
int8_t * advance_to_next_columnar_key_buff(int8_t *key_ptr, const QueryMemoryDescriptor &query_mem_desc, const size_t key_idx)
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
size_t advance_slot(const size_t j, const TargetInfo &target_info, const bool separate_varlen_storage)
T v(const TargetValue &r)
virtual void reset()=0
int8_t groupColWidth(const size_t key_idx) const
#define CHECK(condition)
Definition: Logger.h:187
virtual int64_t getNextValue()=0
Definition: sqldefs.h:71
void write_key(const int64_t k, int8_t *ptr, const int8_t key_bytes)
+ Here is the call graph for this function:

◆ rse_fill_storage_buffer_perfect_hash_rowwise()

void anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rse_fill_storage_buffer_perfect_hash_rowwise ( int8_t *  buff,
NumberGenerator generator,
const std::vector< bool > &  rs_groups,
std::vector< int64_t > &  rs_values 
)
private

Definition at line 394 of file ResultSetTest.cpp.

References CHECK, CHECK_EQ, EMPTY_KEY_64, fill_one_entry_no_collisions(), NumberGenerator::getNextValue(), and v().

398  {
399  const auto key_component_count = rs_query_mem_desc.getKeyCount();
401  auto key_buff = buff;
402  CHECK_EQ(rs_groups.size(), rs_query_mem_desc.getEntryCount());
403  for (size_t i = 0; i < rs_groups.size(); i++) {
404  const auto v = generator.getNextValue();
405  if (rs_groups[i]) {
406  // const auto v = generator.getNextValue();
407  rs_values[i] = v;
408  auto key_buff_i64 = reinterpret_cast<int64_t*>(key_buff);
409  for (size_t key_comp_idx = 0; key_comp_idx < key_component_count; ++key_comp_idx) {
410  *key_buff_i64++ = v;
411  }
412  auto entries_buff = reinterpret_cast<int8_t*>(key_buff_i64);
413  if (rs_flow == 2) { // null_vall test-cases
414  if (i >= rs_entry_count - 4) { // only the last four rows of RS #1 and RS #2
415  // exersized for null_val test
416  rs_values[i] = -1;
417  key_buff = fill_one_entry_no_collisions(
418  entries_buff, rs_query_mem_desc, v, rs_target_infos, false, true);
419  } else {
420  key_buff = fill_one_entry_no_collisions(
421  entries_buff, rs_query_mem_desc, v, rs_target_infos, false, false);
422  }
423  } else {
424  key_buff = fill_one_entry_no_collisions(
425  entries_buff, rs_query_mem_desc, v, rs_target_infos, false);
426  }
427  } else {
428  auto key_buff_i64 = reinterpret_cast<int64_t*>(key_buff);
429  for (size_t key_comp_idx = 0; key_comp_idx < key_component_count; ++key_comp_idx) {
430  *key_buff_i64++ = EMPTY_KEY_64;
431  }
432  auto entries_buff = reinterpret_cast<int8_t*>(key_buff_i64);
433  if (rs_flow == 2) { // null_val test-cases
434  if (i >= rs_entry_count - 4) { // only the last four rows of RS #1 and RS #2
435  // exersized for null_val test
436  rs_values[i] = -1;
437  }
438  key_buff = fill_one_entry_no_collisions(
439  entries_buff, rs_query_mem_desc, 0xdeadbeef, rs_target_infos, true, true);
440  } else {
441  key_buff = fill_one_entry_no_collisions(
442  entries_buff, rs_query_mem_desc, 0xdeadbeef, rs_target_infos, true);
443  }
444  }
445  }
446 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
#define EMPTY_KEY_64
T v(const TargetValue &r)
int8_t * fill_one_entry_no_collisions(int8_t *buff, const QueryMemoryDescriptor &query_mem_desc, const int64_t v, const std::vector< TargetInfo > &target_infos, const bool empty, const bool null_val)
#define CHECK(condition)
Definition: Logger.h:187
virtual int64_t getNextValue()=0
+ Here is the call graph for this function:

◆ rse_get_null_val()

int64_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rse_get_null_val ( )
inline

Definition at line 117 of file ResultSetTest.cpp.

References inline_int_null_val(), and run-benchmark-import::result.

117  {
118  int64_t null_val = 0;
119  for (const auto& target_info : rs_target_infos) {
120  null_val = inline_int_null_val(target_info.sql_type);
121  break; // currently all of TargetInfo's columns used in tests have same type, so
122  // the they all share same null_val, and that's why the first column is used
123  // here.
124  }
125  return null_val;
126  }
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
+ Here is the call graph for this function:

◆ rseAggregateKAVG()

int64_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rseAggregateKAVG ( size_t  i)
private

Definition at line 758 of file ResultSetTest.cpp.

References run-benchmark-import::result.

758  {
759  int64_t result = 0;
760  int n1 = 1,
761  n2 = 1; // for test purposes count of elements in each group is 1 (see proc
762  // "fill_one_entry_no_collisions")
763 
764  if (rs1_groups[i] && rs2_groups[i]) {
765  if ((rs1_values[i] == -1) && (rs2_values[i] == -1)) {
766  // return rse_get_null_val();
767  return result;
768  }
769  int n = 0;
770  if (rs1_values[i] != -1) {
771  result += rs1_values[i] / n1;
772  n++;
773  }
774  if (rs2_values[i] != -1) {
775  result += rs2_values[i] / n2;
776  n++;
777  }
778  if (n > 1) {
779  result /= n;
780  }
781  } else {
782  // result = rse_get_null_val();
783  if (rs1_groups[i]) {
784  if (rs1_values[i] != -1) {
785  result = rs1_values[i] / n1;
786  }
787  } else {
788  if (rs2_groups[i]) {
789  if (rs2_values[i] != -1) {
790  result = rs2_values[i] / n2;
791  }
792  }
793  }
794  }
795 
796  return result;
797 }

◆ rseAggregateKCOUNT()

int64_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rseAggregateKCOUNT ( size_t  i)
private

Definition at line 830 of file ResultSetTest.cpp.

References run-benchmark-import::result.

830  {
831  int64_t result = 0;
832 
833  if (rs1_groups[i] && rs2_groups[i]) {
834  if ((rs1_values[i] == -1) && (rs2_values[i] == -1)) {
835  return 0;
836  }
837  if (rs1_values[i] != -1) {
838  result += rs1_values[i];
839  }
840  if (rs2_values[i] != -1) {
841  result += rs2_values[i];
842  }
843  } else {
844  if (rs1_groups[i]) {
845  if (rs1_values[i] != -1) {
846  result = rs1_values[i];
847  }
848  } else {
849  if (rs2_groups[i]) {
850  if (rs2_values[i] != -1) {
851  result = rs2_values[i];
852  }
853  }
854  }
855  }
856 
857  return result;
858 }

◆ rseAggregateKMAX()

int64_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rseAggregateKMAX ( size_t  i)
private

Definition at line 732 of file ResultSetTest.cpp.

References run-benchmark-import::result.

732  {
733  int64_t result = rse_get_null_val();
734 
735  if (rs1_groups[i] && rs2_groups[i]) {
736  if ((rs1_values[i] == -1) && (rs2_values[i] == -1)) {
737  return result;
738  } else {
739  result = std::max(rs1_values[i], rs2_values[i]);
740  }
741  } else {
742  if (rs1_groups[i]) {
743  if (rs1_values[i] != -1) {
744  result = rs1_values[i];
745  }
746  } else {
747  if (rs2_groups[i]) {
748  if (rs2_values[i] != -1) {
749  result = rs2_values[i];
750  }
751  }
752  }
753  }
754 
755  return result;
756 }

◆ rseAggregateKMIN()

int64_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rseAggregateKMIN ( size_t  i)
private

Definition at line 702 of file ResultSetTest.cpp.

References run-benchmark-import::result.

702  {
703  int64_t result = rse_get_null_val();
704 
705  if (rs1_groups[i] && rs2_groups[i]) {
706  if ((rs1_values[i] == -1) && (rs2_values[i] == -1)) {
707  return result;
708  } else {
709  if ((rs1_values[i] != -1) && (rs2_values[i] != -1)) {
710  result = std::min(rs1_values[i], rs2_values[i]);
711  } else {
712  result = std::max(rs1_values[i], rs2_values[i]);
713  }
714  }
715  } else {
716  if (rs1_groups[i]) {
717  if (rs1_values[i] != -1) {
718  result = rs1_values[i];
719  }
720  } else {
721  if (rs2_groups[i]) {
722  if (rs2_values[i] != -1) {
723  result = rs2_values[i];
724  }
725  }
726  }
727  }
728 
729  return result;
730 }

◆ rseAggregateKSUM()

int64_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rseAggregateKSUM ( size_t  i)
private

Definition at line 799 of file ResultSetTest.cpp.

References run-benchmark-import::result.

799  {
800  int64_t result = 0;
801 
802  if (rs1_groups[i] && rs2_groups[i]) {
803  if ((rs1_values[i] == -1) && (rs2_values[i] == -1)) {
804  return rse_get_null_val();
805  }
806  if (rs1_values[i] != -1) {
807  result += rs1_values[i];
808  }
809  if (rs2_values[i] != -1) {
810  result += rs2_values[i];
811  }
812  } else {
813  result = rse_get_null_val();
814  if (rs1_groups[i]) {
815  if (rs1_values[i] != -1) {
816  result = rs1_values[i];
817  }
818  } else {
819  if (rs2_groups[i]) {
820  if (rs2_values[i] != -1) {
821  result = rs2_values[i];
822  }
823  }
824  }
825  }
826 
827  return result;
828 }

Member Data Documentation

◆ rs1_buff

int8_t* anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs1_buff
private

Definition at line 134 of file ResultSetTest.cpp.

◆ rs1_gen

NumberGenerator& anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs1_gen
private

Definition at line 137 of file ResultSetTest.cpp.

◆ rs1_groups

std::vector<bool> anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs1_groups
private

Definition at line 141 of file ResultSetTest.cpp.

◆ rs1_perc

size_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs1_perc
private

Definition at line 138 of file ResultSetTest.cpp.

◆ rs1_values

std::vector<int64_t> anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs1_values
private

Definition at line 145 of file ResultSetTest.cpp.

◆ rs2_buff

int8_t * anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs2_buff
private

Definition at line 134 of file ResultSetTest.cpp.

◆ rs2_gen

NumberGenerator & anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs2_gen
private

Definition at line 137 of file ResultSetTest.cpp.

◆ rs2_groups

std::vector<bool> anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs2_groups
private

Definition at line 142 of file ResultSetTest.cpp.

◆ rs2_perc

size_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs2_perc
private

Definition at line 138 of file ResultSetTest.cpp.

◆ rs2_values

std::vector<int64_t> anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs2_values
private

Definition at line 146 of file ResultSetTest.cpp.

◆ rs_entry_count

size_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs_entry_count
private

Definition at line 139 of file ResultSetTest.cpp.

◆ rs_flow

size_t anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs_flow
private

Definition at line 138 of file ResultSetTest.cpp.

◆ rs_query_mem_desc

const QueryMemoryDescriptor anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs_query_mem_desc
private

Definition at line 136 of file ResultSetTest.cpp.

◆ rs_silent

bool anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs_silent
private

Definition at line 140 of file ResultSetTest.cpp.

◆ rs_target_infos

const std::vector<TargetInfo> anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rs_target_infos
private

Definition at line 135 of file ResultSetTest.cpp.

◆ rseReducedGroups

std::vector<bool> anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rseReducedGroups
private

Definition at line 144 of file ResultSetTest.cpp.

◆ rseReducedTable

std::queue<std::vector<int64_t> > anonymous_namespace{ResultSetTest.cpp}::ResultSetEmulator::rseReducedTable
private

Definition at line 148 of file ResultSetTest.cpp.


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