OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HashTable Class Referenceabstract

#include <HashTable.h>

+ Inheritance diagram for HashTable:

Public Member Functions

virtual ~HashTable ()
 
virtual size_t getHashTableBufferSize (const ExecutorDeviceType device_type) const =0
 
virtual int8_t * getCpuBuffer ()=0
 
virtual int8_t * getGpuBuffer () const =0
 
virtual HashType getLayout () const =0
 
virtual size_t getEntryCount () const =0
 
virtual size_t getEmittedKeysCount () const =0
 
virtual size_t getRowIdSize () const =0
 

Static Public Member Functions

static DecodedJoinHashBufferSet toSet (size_t key_component_count, size_t key_component_width, size_t entry_count, const int8_t *ptr1, const int8_t *ptr2, const int8_t *ptr3, const int8_t *ptr4, size_t buffer_size)
 Decode hash table into a std::set for easy inspection and validation. More...
 
static std::string toString (const std::string &type, const std::string &layout_type, size_t key_component_count, size_t key_component_width, size_t entry_count, const int8_t *ptr1, const int8_t *ptr2, const int8_t *ptr3, const int8_t *ptr4, size_t buffer_size, bool raw=false)
 Decode hash table into a human-readable string. More...
 

Detailed Description

Definition at line 74 of file HashTable.h.

Constructor & Destructor Documentation

virtual HashTable::~HashTable ( )
inlinevirtual

Definition at line 76 of file HashTable.h.

76 {}

Member Function Documentation

virtual int8_t* HashTable::getCpuBuffer ( )
pure virtual

Implemented in BaselineHashTable, and PerfectHashTable.

virtual size_t HashTable::getEmittedKeysCount ( ) const
pure virtual

Implemented in BaselineHashTable, and PerfectHashTable.

virtual size_t HashTable::getEntryCount ( ) const
pure virtual

Implemented in BaselineHashTable, and PerfectHashTable.

virtual int8_t* HashTable::getGpuBuffer ( ) const
pure virtual

Implemented in BaselineHashTable, and PerfectHashTable.

virtual size_t HashTable::getHashTableBufferSize ( const ExecutorDeviceType  device_type) const
pure virtual

Implemented in BaselineHashTable, and PerfectHashTable.

virtual HashType HashTable::getLayout ( ) const
pure virtual

Implemented in BaselineHashTable, and PerfectHashTable.

virtual size_t HashTable::getRowIdSize ( ) const
pure virtual

Implemented in BaselineHashTable, and PerfectHashTable.

DecodedJoinHashBufferSet HashTable::toSet ( size_t  key_component_count,
size_t  key_component_width,
size_t  entry_count,
const int8_t *  ptr1,
const int8_t *  ptr2,
const int8_t *  ptr3,
const int8_t *  ptr4,
size_t  buffer_size 
)
static

Decode hash table into a std::set for easy inspection and validation.

Definition at line 139 of file HashTable.cpp.

References CHECK, CHECK_LE, anonymous_namespace{HashTable.cpp}::perfect_hash::to_set_one_to_many(), and anonymous_namespace{HashTable.cpp}::perfect_hash::to_set_one_to_one().

Referenced by PerfectJoinHashTable::toSet(), BaselineJoinHashTable::toSet(), and BoundingBoxIntersectJoinHashTable::toSet().

147  { // total memory size
149 
150  CHECK_LE(ptr1, ptr2);
151  CHECK_LE(ptr2, ptr3);
152  CHECK_LE(ptr3, ptr4);
153  CHECK_LE(ptr4, ptr1 + buffer_size);
154 
155  bool have_keys = ptr2 > ptr1;
156  bool have_offsets = ptr3 > ptr2;
157  bool have_counts = ptr4 > ptr3;
158  bool have_payloads = (ptr1 + buffer_size) > ptr4;
159 
160  auto i32ptr2 = reinterpret_cast<const int32_t*>(ptr2);
161  auto i32ptr3 = reinterpret_cast<const int32_t*>(ptr3);
162  auto i32ptr4 = reinterpret_cast<const int32_t*>(ptr4);
163 
164  if (have_keys) { // BaselineJoinHashTable or BoundingBoxIntersectJoinHashTable
165  CHECK(key_component_width == 8 || key_component_width == 4);
166  if (key_component_width == 8) {
167  if (!have_offsets && !have_counts) {
168  keyed_hash::to_set_one_to_one<int64_t>(ptr1, entry_count, key_component_count, s);
169  } else {
170  keyed_hash::to_set_one_to_many<int64_t>(
171  ptr1, i32ptr2, i32ptr3, i32ptr4, entry_count, key_component_count, s);
172  }
173  } else if (key_component_width == 4) {
174  if (!have_offsets && !have_counts) {
175  keyed_hash::to_set_one_to_one<int32_t>(ptr1, entry_count, key_component_count, s);
176  } else {
177  keyed_hash::to_set_one_to_many<int32_t>(
178  ptr1, i32ptr2, i32ptr3, i32ptr4, entry_count, key_component_count, s);
179  }
180  }
181  } else { // JoinHashTable
182  if (!have_offsets && !have_counts && have_payloads) {
183  perfect_hash::to_set_one_to_one(i32ptr4, entry_count, s);
184  } else {
185  perfect_hash::to_set_one_to_many(i32ptr2, i32ptr3, i32ptr4, entry_count, s);
186  }
187  }
188 
189  return s;
190 }
#define CHECK_LE(x, y)
Definition: Logger.h:304
std::set< DecodedJoinHashBufferEntry > DecodedJoinHashBufferSet
Definition: HashTable.h:72
#define CHECK(condition)
Definition: Logger.h:291
void to_set_one_to_many(const int32_t *const ptr2, const int32_t *const ptr3, const int32_t *const ptr4, size_t entry_count, DecodedJoinHashBufferSet &s)
Definition: HashTable.cpp:43
void to_set_one_to_one(const int32_t *const ptr4, size_t entry_count, DecodedJoinHashBufferSet &s)
Definition: HashTable.cpp:23

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string HashTable::toString ( const std::string &  type,
const std::string &  layout_type,
size_t  key_component_count,
size_t  key_component_width,
size_t  entry_count,
const int8_t *  ptr1,
const int8_t *  ptr2,
const int8_t *  ptr3,
const int8_t *  ptr4,
size_t  buffer_size,
bool  raw = false 
)
static

Decode hash table into a human-readable string.

Definition at line 226 of file HashTable.cpp.

References CHECK, to_string(), and run_benchmark_import::type.

Referenced by PerfectJoinHashTable::toString(), BaselineJoinHashTable::toString(), and BoundingBoxIntersectJoinHashTable::toString().

237  {
238  std::string txt;
239 
240  CHECK(ptr1 <= ptr2);
241  CHECK(ptr2 <= ptr3);
242  CHECK(ptr3 <= ptr4);
243  CHECK(ptr4 <= ptr1 + buffer_size);
244 
245  bool have_keys = ptr2 > ptr1;
246  bool have_offsets = ptr3 > ptr2;
247  bool have_counts = ptr4 > ptr3;
248  bool have_payloads = (ptr1 + buffer_size) > ptr4;
249 
250  // table heading
251  txt += "| " + type;
252  if (!have_offsets && !have_counts) {
253  txt += layout_type;
254  } else if (have_offsets && have_counts) {
255  txt += layout_type;
256  } else {
257  CHECK(false);
258  }
259 
260  // first section: keys
261  if (have_keys) {
262  CHECK(key_component_width == 8 || key_component_width == 4);
263 
264  if (!txt.empty()) {
265  txt += " ";
266  }
267  txt += "| keys ";
268 
269  if (key_component_width == 8) {
270  inner_to_string<int64_t>(ptr1, entry_count, key_component_count, raw, txt);
271  } else if (key_component_width == 4) {
272  inner_to_string<int32_t>(ptr1, entry_count, key_component_count, raw, txt);
273  }
274  }
275 
276  // second section: offsets
277  if (have_offsets) {
278  if (!txt.empty()) {
279  txt += " ";
280  }
281  txt += "| offsets ";
282 
283  auto i32ptr2 = reinterpret_cast<const int32_t*>(ptr2);
284  auto i32ptr3 = reinterpret_cast<const int32_t*>(ptr3);
285  for (size_t i = 0; &i32ptr2[i] < i32ptr3; ++i) {
286  if (i != 0) {
287  txt += " ";
288  }
289  if (i32ptr2[i] == -1 && !raw) {
290  txt += "*"; // null
291  } else {
292  txt += std::to_string(i32ptr2[i]);
293  }
294  }
295  }
296 
297  // third section: counts
298  if (have_counts) {
299  if (!txt.empty()) {
300  txt += " ";
301  }
302  txt += "| counts ";
303 
304  auto i32ptr3 = reinterpret_cast<const int32_t*>(ptr3);
305  auto i32ptr4 = reinterpret_cast<const int32_t*>(ptr4);
306  for (size_t i = 0; &i32ptr3[i] < i32ptr4; ++i) {
307  if (i != 0) {
308  txt += " ";
309  }
310  if (i32ptr3[i] == 0 && !raw) {
311  txt += "*"; // null
312  } else {
313  txt += std::to_string(i32ptr3[i]);
314  }
315  }
316  }
317 
318  // fourth section: payloads (rowids)
319  if (have_payloads) {
320  if (!txt.empty()) {
321  txt += " ";
322  }
323  txt += "| payloads ";
324 
325  auto i32ptr4 = reinterpret_cast<const int32_t*>(ptr4);
326  auto i32ptr5 = reinterpret_cast<const int32_t*>(ptr1 + buffer_size);
327  for (size_t i = 0; &i32ptr4[i] < i32ptr5; ++i) {
328  if (i != 0) {
329  txt += " ";
330  }
331  if (i32ptr4[i] == -1 && !raw) {
332  txt += "*"; // null
333  } else {
334  txt += std::to_string(i32ptr4[i]);
335  }
336  }
337  }
338 
339  if (!txt.empty()) {
340  txt += " |";
341  }
342  return txt;
343 }
std::string to_string(char const *&&v)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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