OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AggregateUtils.h File Reference
#include "../Shared/sqltypes.h"
#include "BufferCompaction.h"
#include "TypePunning.h"
#include "Logger/Logger.h"
+ Include dependency graph for AggregateUtils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void set_component (int8_t *group_by_buffer, const size_t comp_sz, const int64_t val, const size_t index=0)
 
int64_t float_to_double_bin (int32_t val, bool nullable=false)
 
std::vector< int64_t > compact_init_vals (const size_t cmpt_size, const std::vector< int64_t > &init_vec, const QueryMemoryDescriptor &query_mem_desc)
 

Function Documentation

std::vector<int64_t> compact_init_vals ( const size_t  cmpt_size,
const std::vector< int64_t > &  init_vec,
const QueryMemoryDescriptor query_mem_desc 
)
inline

Definition at line 68 of file AggregateUtils.h.

References align_to_int64(), CHECK_LT, QueryMemoryDescriptor::getPaddedSlotWidthBytes(), QueryMemoryDescriptor::getSlotCount(), and set_component().

Referenced by QueryExecutionContext::copyInitAggValsToDevice(), and QueryExecutionContext::launchCpuCode().

71  {
72  std::vector<int64_t> cmpt_res(cmpt_size, 0);
73  int8_t* buffer_ptr = reinterpret_cast<int8_t*>(cmpt_res.data());
74  for (size_t col_idx = 0, init_vec_idx = 0, col_count = query_mem_desc.getSlotCount();
75  col_idx < col_count;
76  ++col_idx) {
77  const auto chosen_bytes =
78  static_cast<unsigned>(query_mem_desc.getPaddedSlotWidthBytes(col_idx));
79  if (chosen_bytes == 0) {
80  continue;
81  }
82  if (chosen_bytes == sizeof(int64_t)) {
83  buffer_ptr = align_to_int64(buffer_ptr);
84  }
85  CHECK_LT(init_vec_idx, init_vec.size());
86  set_component(buffer_ptr, chosen_bytes, init_vec[init_vec_idx++]);
87  buffer_ptr += chosen_bytes;
88  }
89  return cmpt_res;
90 }
const int8_t getPaddedSlotWidthBytes(const size_t slot_idx) const
#define CHECK_LT(x, y)
Definition: Logger.h:303
void set_component(int8_t *group_by_buffer, const size_t comp_sz, const int64_t val, const size_t index=0)
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t float_to_double_bin ( int32_t  val,
bool  nullable = false 
)
inline

Definition at line 58 of file AggregateUtils.h.

References NULL_DOUBLE, NULL_FLOAT, and run_benchmark_import::res.

Referenced by Executor::reduceResults().

58  {
59  const float null_float = NULL_FLOAT;
60  if (nullable && val == *reinterpret_cast<const int32_t*>(may_alias_ptr(&null_float))) {
61  double null_double = NULL_DOUBLE;
62  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&null_double));
63  }
64  double res = *reinterpret_cast<const float*>(may_alias_ptr(&val));
65  return *reinterpret_cast<const int64_t*>(may_alias_ptr(&res));
66 }
#define NULL_DOUBLE
#define NULL_FLOAT

+ Here is the caller graph for this function:

void set_component ( int8_t *  group_by_buffer,
const size_t  comp_sz,
const int64_t  val,
const size_t  index = 0 
)
inline

Definition at line 26 of file AggregateUtils.h.

References CHECK.

Referenced by compact_init_vals().

29  {
30  switch (comp_sz) {
31  case 1: {
32  group_by_buffer[index] = static_cast<int8_t>(val);
33  break;
34  }
35  case 2: {
36  int16_t* buffer_ptr = reinterpret_cast<int16_t*>(group_by_buffer);
37  buffer_ptr[index] = (int16_t)val;
38  break;
39  }
40  case 4: {
41  int32_t* buffer_ptr = reinterpret_cast<int32_t*>(group_by_buffer);
42  buffer_ptr[index] = (int32_t)val;
43  break;
44  }
45  case 8: {
46  int64_t* buffer_ptr = reinterpret_cast<int64_t*>(group_by_buffer);
47  buffer_ptr[index] = val;
48  break;
49  }
50  case 0: {
51  break;
52  }
53  default:
54  CHECK(false);
55  }
56 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function: