OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JoinHashTableInterface.cpp File Reference
+ Include dependency graph for JoinHashTableInterface.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{JoinHashTableInterface.cpp}
 

Functions

template<typename T >
void anonymous_namespace{JoinHashTableInterface.cpp}::innerDecodeJoinHashBufferToString (const int8_t *ptr1, size_t entry_count, size_t key_component_count, bool raw, std::string &txt)
 
std::string decodeJoinHashBufferToString (size_t key_component_count, size_t key_component_width, const int8_t *ptr1, const int8_t *ptr2, const int8_t *ptr3, const int8_t *ptr4, size_t buffer_size, bool raw)
 
template<typename T >
std::string anonymous_namespace{JoinHashTableInterface.cpp}::decodeJoinHashBufferToStringFlat (const JoinHashTableInterface *hash_table, const ExecutorDeviceType device_type, const int device_id) noexcept
 
std::ostream & operator<< (std::ostream &os, const DecodedJoinHashBufferEntry &e)
 
std::ostream & operator<< (std::ostream &os, const std::set< DecodedJoinHashBufferEntry > &s)
 
template<typename T >
void anonymous_namespace{JoinHashTableInterface.cpp}::innerDecodeJoinHashBuffer (const int8_t *ptr1, const int32_t *ptr2, const int32_t *ptr3, const int32_t *ptr4, size_t entry_count, size_t key_component_count, std::set< DecodedJoinHashBufferEntry > &s)
 
template<typename T >
void anonymous_namespace{JoinHashTableInterface.cpp}::innerDecodeJoinHashBuffer (const int32_t *ptr2, const int32_t *ptr3, const int32_t *ptr4, size_t entry_count, std::set< DecodedJoinHashBufferEntry > &s)
 
std::set
< DecodedJoinHashBufferEntry
decodeJoinHashBuffer (size_t key_component_count, size_t key_component_width, const int8_t *ptr1, const int8_t *ptr2, const int8_t *ptr3, const int8_t *ptr4, size_t buffer_size)
 

Function Documentation

std::set<DecodedJoinHashBufferEntry> decodeJoinHashBuffer ( size_t  key_component_count,
size_t  key_component_width,
const int8_t *  ptr1,
const int8_t *  ptr2,
const int8_t *  ptr3,
const int8_t *  ptr4,
size_t  buffer_size 
)

Definition at line 268 of file JoinHashTableInterface.cpp.

References CHECK(), CHECK_LE, and CHECK_LT.

Referenced by BaselineJoinHashTable::decodeJoinHashBuffer(), and JoinHashTable::decodeJoinHashBuffer().

275  { // total memory size
276  std::set<DecodedJoinHashBufferEntry> s;
277 
278  CHECK(key_component_width == 8 || key_component_width == 4);
279 
280  auto i64ptr1 = reinterpret_cast<const int64_t*>(ptr1);
281  auto i64ptr2 = reinterpret_cast<const int64_t*>(ptr2);
282  auto i32ptr2 = reinterpret_cast<const int32_t*>(ptr2);
283  auto i32ptr3 = reinterpret_cast<const int32_t*>(ptr3);
284  auto i32ptr4 = reinterpret_cast<const int32_t*>(ptr4);
285  auto i32ptr5 = reinterpret_cast<const int32_t*>(ptr1 + buffer_size);
286  auto i64ptr5 = reinterpret_cast<const int64_t*>(i32ptr5);
287 
288  CHECK_LE(i64ptr1, i64ptr2);
289  CHECK_LT(i64ptr2, i64ptr5);
290  CHECK_LT(i32ptr2, i32ptr3);
291  CHECK_LT(i32ptr3, i32ptr4);
292  CHECK_LT(i32ptr4, i32ptr5);
293 
294  size_t entry_count = (ptr3 - ptr2) / sizeof(int32_t);
295 
296  if (i64ptr1 < i64ptr2) { // BaselineJoinHashTable or OverlapsJoinHashTable
297  if (key_component_width == 8) {
298  innerDecodeJoinHashBuffer<int64_t>(
299  ptr1, i32ptr2, i32ptr3, i32ptr4, entry_count, key_component_count, s);
300  } else if (key_component_width == 4) {
301  innerDecodeJoinHashBuffer<int32_t>(
302  ptr1, i32ptr2, i32ptr3, i32ptr4, entry_count, key_component_count, s);
303  }
304  } else { // JoinHashTable
305  if (key_component_width == 8) {
306  innerDecodeJoinHashBuffer<int64_t>(i32ptr2, i32ptr3, i32ptr4, entry_count, s);
307  } else if (key_component_width == 4) {
308  innerDecodeJoinHashBuffer<int32_t>(i32ptr2, i32ptr3, i32ptr4, entry_count, s);
309  }
310  }
311 
312  return s;
313 }
CHECK(cgen_state)
#define CHECK_LT(x, y)
Definition: Logger.h:200
#define CHECK_LE(x, y)
Definition: Logger.h:201

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string decodeJoinHashBufferToString ( size_t  key_component_count,
size_t  key_component_width,
const int8_t *  ptr1,
const int8_t *  ptr2,
const int8_t *  ptr3,
const int8_t *  ptr4,
size_t  buffer_size,
bool  raw 
)

Definition at line 53 of file JoinHashTableInterface.cpp.

References CHECK(), CHECK_LE, CHECK_LT, and to_string().

Referenced by BaselineJoinHashTable::toString(), and JoinHashTable::toString().

61  {
62  std::string txt;
63 
64  CHECK(key_component_width == 8 || key_component_width == 4);
65 
66  auto i64ptr1 = reinterpret_cast<const int64_t*>(ptr1);
67  auto i64ptr2 = reinterpret_cast<const int64_t*>(ptr2);
68  auto i32ptr2 = reinterpret_cast<const int32_t*>(ptr2);
69  auto i32ptr3 = reinterpret_cast<const int32_t*>(ptr3);
70  auto i32ptr4 = reinterpret_cast<const int32_t*>(ptr4);
71  auto i32ptr5 = reinterpret_cast<const int32_t*>(ptr1 + buffer_size);
72  auto i64ptr5 = reinterpret_cast<const int64_t*>(i32ptr5);
73 
74  CHECK_LE(i64ptr1, i64ptr2);
75  CHECK_LT(i64ptr2, i64ptr5);
76  CHECK_LT(i32ptr2, i32ptr3);
77  CHECK_LT(i32ptr3, i32ptr4);
78  CHECK_LT(i32ptr4, i32ptr5);
79 
80  size_t entry_count = (ptr3 - ptr2) / sizeof(int32_t);
81 
82  // first section: keys
83  if (i64ptr1 < i64ptr2) {
84  if (key_component_width == 8) {
85  innerDecodeJoinHashBufferToString<int64_t>(
86  ptr1, entry_count, key_component_count, raw, txt);
87  } else if (key_component_width == 4) {
88  innerDecodeJoinHashBufferToString<int32_t>(
89  ptr1, entry_count, key_component_count, raw, txt);
90  }
91 
92  txt += " | ";
93  }
94 
95  // second section: offsets
96  for (size_t i = 0; &i32ptr2[i] < i32ptr3; ++i) {
97  if (i != 0) {
98  txt += " ";
99  }
100  if (i32ptr2[i] == -1) {
101  txt += "*"; // null
102  } else {
103  txt += std::to_string(i32ptr2[i]);
104  }
105  }
106 
107  txt += " | ";
108 
109  // third section: counts
110  for (size_t i = 0; &i32ptr3[i] < i32ptr4; ++i) {
111  if (i != 0) {
112  txt += " ";
113  }
114  if (i32ptr3[i] == 0) {
115  txt += "*"; // null
116  } else {
117  txt += std::to_string(i32ptr3[i]);
118  }
119  }
120 
121  txt += " | ";
122 
123  // fourth section: payloads (rowids)
124  for (size_t i = 0; &i32ptr4[i] < i32ptr5; ++i) {
125  if (i != 0) {
126  txt += " ";
127  }
128  if (i32ptr4[i] == -1) {
129  txt += "*"; // null
130  } else {
131  txt += std::to_string(i32ptr4[i]);
132  }
133  }
134 
135  return txt;
136 }
std::string to_string(char const *&&v)
CHECK(cgen_state)
#define CHECK_LT(x, y)
Definition: Logger.h:200
#define CHECK_LE(x, y)
Definition: Logger.h:201

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::ostream& operator<< ( std::ostream &  os,
const DecodedJoinHashBufferEntry e 
)

Definition at line 169 of file JoinHashTableInterface.cpp.

References DecodedJoinHashBufferEntry::key, and DecodedJoinHashBufferEntry::payload.

169  {
170  os << "(";
171  bool first = true;
172  for (auto k : e.key) {
173  if (!first) {
174  os << ",";
175  } else {
176  first = false;
177  }
178  os << k;
179  }
180  os << ")";
181  os << ": ";
182  first = true;
183  for (auto p : e.payload) {
184  if (!first) {
185  os << " ";
186  } else {
187  first = false;
188  }
189  os << p;
190  }
191  return os;
192 }
std::set< int32_t > payload
std::vector< int64_t > key
std::ostream& operator<< ( std::ostream &  os,
const std::set< DecodedJoinHashBufferEntry > &  s 
)

Definition at line 194 of file JoinHashTableInterface.cpp.

195  {
196  for (auto e : s) {
197  os << e << "\n";
198  }
199  return os;
200 }