OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PerfectHashTable Class Reference

#include <PerfectHashTable.h>

+ Inheritance diagram for PerfectHashTable:
+ Collaboration diagram for PerfectHashTable:

Public Member Functions

 PerfectHashTable (Data_Namespace::DataMgr *data_mgr, const HashType layout, const ExecutorDeviceType device_type, const size_t entry_count, const size_t emitted_keys_count, const bool for_window_framing=false)
 
 ~PerfectHashTable () override
 
size_t gpuReservedSize () const
 
void allocateGpuMemory (const size_t entries, const int device_id)
 
size_t getHashTableBufferSize (const ExecutorDeviceType device_type) const override
 
HashType getLayout () const override
 
int8_t * getCpuBuffer () override
 
int8_t * getGpuBuffer () const override
 
size_t getEntryCount () const override
 
size_t getEmittedKeysCount () const override
 
void setHashEntryInfo (BucketizedHashEntryInfo &hash_entry_info)
 
void setColumnNumElems (size_t elem)
 
BucketizedHashEntryInfo getHashEntryInfo () const
 
size_t getColumnNumElems () const
 
- Public Member Functions inherited from HashTable
virtual ~HashTable ()
 

Private Attributes

Data_Namespace::AbstractBuffergpu_hash_table_buff_ {nullptr}
 
Data_Namespace::DataMgrdata_mgr_
 
std::unique_ptr< int32_t[]> cpu_hash_table_buff_
 
size_t cpu_hash_table_buff_size_
 
HashType layout_
 
size_t entry_count_
 
size_t emitted_keys_count_
 
BucketizedHashEntryInfo hash_entry_info_
 
size_t column_num_elems_
 

Additional Inherited Members

- Static Public Member Functions inherited from HashTable
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 25 of file PerfectHashTable.h.

Constructor & Destructor Documentation

PerfectHashTable::PerfectHashTable ( Data_Namespace::DataMgr data_mgr,
const HashType  layout,
const ExecutorDeviceType  device_type,
const size_t  entry_count,
const size_t  emitted_keys_count,
const bool  for_window_framing = false 
)
inline

Definition at line 28 of file PerfectHashTable.h.

References CPU, cpu_hash_table_buff_, cpu_hash_table_buff_size_, emitted_keys_count_, entry_count_, layout_, OneToOne, HashTable::toString(), and VLOG.

34  : data_mgr_(data_mgr)
35  , layout_(layout)
36  , entry_count_(entry_count)
37  , emitted_keys_count_(emitted_keys_count) {
38  std::string device_str = "GPU";
39  if (device_type == ExecutorDeviceType::CPU) {
40  device_str = "CPU";
43  ? entry_count_
44  : 2 * entry_count_ + ((1 + for_window_framing) * emitted_keys_count_);
46  }
47  VLOG(1) << "Initialize a " << device_str << " perfect hash table for join type "
48  << ::toString(layout) << " # hash entries: " << entry_count
49  << ", # entries stored in the payload buffer: " << emitted_keys_count
50  << ", hash table size : " << cpu_hash_table_buff_size_ * 4 << " Bytes";
51  }
size_t cpu_hash_table_buff_size_
std::unique_ptr< int32_t[]> cpu_hash_table_buff_
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.
Definition: HashTable.cpp:226
Data_Namespace::DataMgr * data_mgr_
#define VLOG(n)
Definition: Logger.h:387

+ Here is the call graph for this function:

PerfectHashTable::~PerfectHashTable ( )
inlineoverride

Definition at line 53 of file PerfectHashTable.h.

References CHECK, data_mgr_, Data_Namespace::DataMgr::free(), and gpu_hash_table_buff_.

53  {
57  }
58  }
Data_Namespace::AbstractBuffer * gpu_hash_table_buff_
#define CHECK(condition)
Definition: Logger.h:291
void free(AbstractBuffer *buffer)
Definition: DataMgr.cpp:525
Data_Namespace::DataMgr * data_mgr_

+ Here is the call graph for this function:

Member Function Documentation

void PerfectHashTable::allocateGpuMemory ( const size_t  entries,
const int  device_id 
)
inline

Definition at line 65 of file PerfectHashTable.h.

References CudaAllocator::allocGpuAbstractBuffer(), CHECK, CHECK_GE, data_mgr_, and gpu_hash_table_buff_.

65  {
66  CHECK_GE(device_id, 0);
69  data_mgr_, entries * sizeof(int32_t), device_id);
70  }
#define CHECK_GE(x, y)
Definition: Logger.h:306
Data_Namespace::AbstractBuffer * gpu_hash_table_buff_
static Data_Namespace::AbstractBuffer * allocGpuAbstractBuffer(Data_Namespace::DataMgr *data_mgr, const size_t num_bytes, const int device_id)
#define CHECK(condition)
Definition: Logger.h:291
Data_Namespace::DataMgr * data_mgr_

+ Here is the call graph for this function:

size_t PerfectHashTable::getColumnNumElems ( ) const
inline

Definition at line 103 of file PerfectHashTable.h.

References column_num_elems_.

103 { return column_num_elems_; }
int8_t* PerfectHashTable::getCpuBuffer ( )
inlineoverridevirtual

Implements HashTable.

Definition at line 83 of file PerfectHashTable.h.

References cpu_hash_table_buff_.

83  {
84  return reinterpret_cast<int8_t*>(cpu_hash_table_buff_.get());
85  }
std::unique_ptr< int32_t[]> cpu_hash_table_buff_
size_t PerfectHashTable::getEmittedKeysCount ( ) const
inlineoverridevirtual

Implements HashTable.

Definition at line 93 of file PerfectHashTable.h.

References emitted_keys_count_.

93 { return emitted_keys_count_; }
size_t PerfectHashTable::getEntryCount ( ) const
inlineoverridevirtual

Implements HashTable.

Definition at line 91 of file PerfectHashTable.h.

References entry_count_.

91 { return entry_count_; }
int8_t* PerfectHashTable::getGpuBuffer ( ) const
inlineoverridevirtual

Implements HashTable.

Definition at line 87 of file PerfectHashTable.h.

References Data_Namespace::AbstractBuffer::getMemoryPtr(), and gpu_hash_table_buff_.

87  {
89  }
virtual int8_t * getMemoryPtr()=0
Data_Namespace::AbstractBuffer * gpu_hash_table_buff_

+ Here is the call graph for this function:

BucketizedHashEntryInfo PerfectHashTable::getHashEntryInfo ( ) const
inline

Definition at line 101 of file PerfectHashTable.h.

References hash_entry_info_.

101 { return hash_entry_info_; }
BucketizedHashEntryInfo hash_entry_info_
size_t PerfectHashTable::getHashTableBufferSize ( const ExecutorDeviceType  device_type) const
inlineoverridevirtual

Implements HashTable.

Definition at line 72 of file PerfectHashTable.h.

References CPU, cpu_hash_table_buff_, cpu_hash_table_buff_size_, gpu_hash_table_buff_, and Data_Namespace::AbstractBuffer::reservedSize().

72  {
73  if (device_type == ExecutorDeviceType::CPU) {
75  sizeof(decltype(cpu_hash_table_buff_)::element_type);
76  } else {
78  }
79  }
size_t cpu_hash_table_buff_size_
std::unique_ptr< int32_t[]> cpu_hash_table_buff_
virtual size_t reservedSize() const =0
Data_Namespace::AbstractBuffer * gpu_hash_table_buff_

+ Here is the call graph for this function:

HashType PerfectHashTable::getLayout ( ) const
inlineoverridevirtual

Implements HashTable.

Definition at line 81 of file PerfectHashTable.h.

References layout_.

81 { return layout_; }
size_t PerfectHashTable::gpuReservedSize ( ) const
inline

Definition at line 60 of file PerfectHashTable.h.

References CHECK, gpu_hash_table_buff_, and Data_Namespace::AbstractBuffer::reservedSize().

60  {
63  }
virtual size_t reservedSize() const =0
Data_Namespace::AbstractBuffer * gpu_hash_table_buff_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

void PerfectHashTable::setColumnNumElems ( size_t  elem)
inline

Definition at line 99 of file PerfectHashTable.h.

References column_num_elems_.

99 { column_num_elems_ = elem; }
void PerfectHashTable::setHashEntryInfo ( BucketizedHashEntryInfo hash_entry_info)
inline

Definition at line 95 of file PerfectHashTable.h.

References hash_entry_info_.

95  {
96  hash_entry_info_ = hash_entry_info;
97  }
BucketizedHashEntryInfo hash_entry_info_

Member Data Documentation

size_t PerfectHashTable::column_num_elems_
private

Definition at line 116 of file PerfectHashTable.h.

Referenced by getColumnNumElems(), and setColumnNumElems().

std::unique_ptr<int32_t[]> PerfectHashTable::cpu_hash_table_buff_
private

Definition at line 108 of file PerfectHashTable.h.

Referenced by getCpuBuffer(), getHashTableBufferSize(), and PerfectHashTable().

size_t PerfectHashTable::cpu_hash_table_buff_size_
private

Definition at line 109 of file PerfectHashTable.h.

Referenced by getHashTableBufferSize(), and PerfectHashTable().

Data_Namespace::DataMgr* PerfectHashTable::data_mgr_
private

Definition at line 107 of file PerfectHashTable.h.

Referenced by allocateGpuMemory(), and ~PerfectHashTable().

size_t PerfectHashTable::emitted_keys_count_
private

Definition at line 113 of file PerfectHashTable.h.

Referenced by getEmittedKeysCount(), and PerfectHashTable().

size_t PerfectHashTable::entry_count_
private

Definition at line 112 of file PerfectHashTable.h.

Referenced by getEntryCount(), and PerfectHashTable().

Data_Namespace::AbstractBuffer* PerfectHashTable::gpu_hash_table_buff_ {nullptr}
private
BucketizedHashEntryInfo PerfectHashTable::hash_entry_info_
private

Definition at line 115 of file PerfectHashTable.h.

Referenced by getHashEntryInfo(), and setHashEntryInfo().

HashType PerfectHashTable::layout_
private

Definition at line 111 of file PerfectHashTable.h.

Referenced by getLayout(), and PerfectHashTable().


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