OmniSciDB  2e3a973ef4
JoinHashTableInterface Class Referenceabstract

#include <JoinHashTableInterface.h>

+ Inheritance diagram for JoinHashTableInterface:

Public Types

enum  HashType : int { HashType::OneToOne, HashType::OneToMany, HashType::ManyToMany }
 

Public Member Functions

virtual int64_t getJoinHashBuffer (const ExecutorDeviceType device_type, const int device_id=0) const noexcept=0
 
virtual size_t getJoinHashBufferSize (const ExecutorDeviceType device_type, const int device_id=0) const noexcept=0
 
virtual std::string toString (const ExecutorDeviceType device_type, const int device_id=0, bool raw=false) const =0
 
virtual std::string toStringFlat64 (const ExecutorDeviceType device_type, const int device_id) const
 
virtual std::string toStringFlat32 (const ExecutorDeviceType device_type, const int device_id) const
 
virtual DecodedJoinHashBufferSet toSet (const ExecutorDeviceType device_type, const int device_id) const =0
 
virtual llvm::Value * codegenSlot (const CompilationOptions &, const size_t)=0
 
virtual HashJoinMatchingSet codegenMatchingSet (const CompilationOptions &, const size_t)=0
 
virtual int getInnerTableId () const noexcept=0
 
virtual int getInnerTableRteIdx () const noexcept=0
 
virtual HashType getHashType () const noexcept=0
 
virtual bool layoutRequiresAdditionalBuffers (JoinHashTableInterface::HashType layout) const noexcept=0
 
virtual Data_Namespace::MemoryLevel getMemoryLevel () const noexcept=0
 
virtual int getDeviceCount () const noexcept=0
 
virtual size_t offsetBufferOff () const noexcept=0
 
virtual size_t countBufferOff () const noexcept=0
 
virtual size_t payloadBufferOff () const noexcept=0
 
JoinColumn fetchJoinColumn (const Analyzer::ColumnVar *hash_col, const std::vector< Fragmenter_Namespace::FragmentInfo > &fragment_info, const Data_Namespace::MemoryLevel effective_memory_level, const int device_id, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, DeviceAllocator *dev_buff_owner, std::vector< std::shared_ptr< void >> &malloc_owner, Executor *executor, ColumnCacheMap *column_cache)
 

Static Public Member Functions

static std::string getHashTypeString (HashType ht) noexcept
 
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...
 
static std::shared_ptr< JoinHashTableInterfacegetInstance (const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
 Make hash table from an in-flight SQL query's parse tree etc. More...
 
static std::shared_ptr< JoinHashTableInterfacegetSyntheticInstance (std::string_view table1, std::string_view column1, std::string_view table2, std::string_view column2, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
 Make hash table from named tables and columns (such as for testing). More...
 
static std::shared_ptr< JoinHashTableInterfacegetSyntheticInstance (const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
 Make hash table from named tables and columns (such as for testing). More...
 

Detailed Description

Definition at line 87 of file JoinHashTableInterface.h.

Member Enumeration Documentation

◆ HashType

Enumerator
OneToOne 
OneToMany 
ManyToMany 

Definition at line 118 of file JoinHashTableInterface.h.

118 : int { OneToOne, OneToMany, ManyToMany };

Member Function Documentation

◆ codegenMatchingSet()

virtual HashJoinMatchingSet JoinHashTableInterface::codegenMatchingSet ( const CompilationOptions ,
const size_t   
)
pure virtual

◆ codegenSlot()

virtual llvm::Value* JoinHashTableInterface::codegenSlot ( const CompilationOptions ,
const size_t   
)
pure virtual

Implemented in JoinHashTable, and BaselineJoinHashTable.

◆ countBufferOff()

virtual size_t JoinHashTableInterface::countBufferOff ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

◆ fetchJoinColumn()

JoinColumn JoinHashTableInterface::fetchJoinColumn ( const Analyzer::ColumnVar hash_col,
const std::vector< Fragmenter_Namespace::FragmentInfo > &  fragment_info,
const Data_Namespace::MemoryLevel  effective_memory_level,
const int  device_id,
std::vector< std::shared_ptr< Chunk_NS::Chunk >> &  chunks_owner,
DeviceAllocator dev_buff_owner,
std::vector< std::shared_ptr< void >> &  malloc_owner,
Executor executor,
ColumnCacheMap column_cache 
)

fetchJoinColumn() calls ColumnFetcher::makeJoinColumn(), then copies the JoinColumn's col_chunks_buff memory onto the GPU if required by the effective_memory_level parameter. The dev_buff_owner parameter will manage the GPU memory.

Definition at line 34 of file JoinHashTableInterface.cpp.

References Allocator::alloc(), CHECK, JoinColumn::col_chunks_buff, JoinColumn::col_chunks_buff_sz, DeviceAllocator::copyToDevice(), Data_Namespace::GPU_LEVEL, and ColumnFetcher::makeJoinColumn().

Referenced by OverlapsJoinHashTable::fetchColumnsForDevice(), and BaselineJoinHashTable::fetchColumnsForDevice().

43  {
44  static std::mutex fragment_fetch_mutex;
45  std::lock_guard<std::mutex> fragment_fetch_lock(fragment_fetch_mutex);
46  try {
47  JoinColumn join_column = ColumnFetcher::makeJoinColumn(executor,
48  *hash_col,
49  fragment_info,
50  effective_memory_level,
51  device_id,
52  dev_buff_owner,
53  chunks_owner,
54  malloc_owner,
55  *column_cache);
56  if (effective_memory_level == Data_Namespace::GPU_LEVEL) {
57  CHECK(dev_buff_owner);
58  auto device_col_chunks_buff = dev_buff_owner->alloc(join_column.col_chunks_buff_sz);
59  dev_buff_owner->copyToDevice(device_col_chunks_buff,
60  join_column.col_chunks_buff,
61  join_column.col_chunks_buff_sz);
62  join_column.col_chunks_buff = device_col_chunks_buff;
63  }
64  return join_column;
65  } catch (...) {
66  throw FailedToFetchColumn();
67  }
68 }
virtual void copyToDevice(int8_t *device_dst, const int8_t *host_src, const size_t num_bytes) const =0
virtual int8_t * alloc(const size_t num_bytes)=0
static JoinColumn makeJoinColumn(Executor *executor, const Analyzer::ColumnVar &hash_col, const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const Data_Namespace::MemoryLevel effective_mem_lvl, const int device_id, DeviceAllocator *device_allocator, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, std::vector< std::shared_ptr< void >> &malloc_owner, ColumnCacheMap &column_cache)
Creates a JoinColumn struct containing an array of JoinChunk structs.
size_t col_chunks_buff_sz
const int8_t * col_chunks_buff
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeviceCount()

virtual int JoinHashTableInterface::getDeviceCount ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

◆ getHashType()

virtual HashType JoinHashTableInterface::getHashType ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

◆ getHashTypeString()

static std::string JoinHashTableInterface::getHashTypeString ( HashType  ht)
inlinestaticnoexcept

Definition at line 125 of file JoinHashTableInterface.h.

References getSyntheticColumnVar(), operator<<(), toString(), and run_benchmark_import::type.

Referenced by BaselineJoinHashTable::getInstance(), OverlapsJoinHashTable::getInstance(), OverlapsJoinHashTable::reifyWithLayout(), and BaselineJoinHashTable::toString().

125  {
126  const char* HashTypeStrings[3] = {"OneToOne", "OneToMany", "ManyToMany"};
127  return HashTypeStrings[static_cast<int>(ht)];
128  };
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInnerTableId()

virtual int JoinHashTableInterface::getInnerTableId ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

◆ getInnerTableRteIdx()

virtual int JoinHashTableInterface::getInnerTableRteIdx ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

◆ getInstance()

std::shared_ptr< JoinHashTableInterface > JoinHashTableInterface::getInstance ( const std::shared_ptr< Analyzer::BinOper qual_bin_oper,
const std::vector< InputTableInfo > &  query_infos,
const Data_Namespace::MemoryLevel  memory_level,
const HashType  preferred_hash_type,
const int  device_count,
ColumnCacheMap column_cache,
Executor executor 
)
static

Make hash table from an in-flight SQL query's parse tree etc.

Definition at line 472 of file JoinHashTableInterface.cpp.

References CHECK, CHECK_EQ, CHECK_GT, coalesce_singleton_equi_join(), CPU, DEBUG_TIMER, g_enable_overlaps_hashjoin, OverlapsJoinHashTable::getInstance(), BaselineJoinHashTable::getInstance(), JoinHashTable::getInstance(), GPU, Data_Namespace::GPU_LEVEL, VLOG, and VLOGGING.

Referenced by Executor::buildHashTableForQualifier(), and getSyntheticInstance().

479  {
480  auto timer = DEBUG_TIMER(__func__);
481  std::shared_ptr<JoinHashTableInterface> join_hash_table;
482  CHECK_GT(device_count, 0);
483  if (!g_enable_overlaps_hashjoin && qual_bin_oper->is_overlaps_oper()) {
484  throw std::runtime_error(
485  "Overlaps hash join disabled, attempting to fall back to loop join");
486  }
487  if (qual_bin_oper->is_overlaps_oper()) {
488  VLOG(1) << "Trying to build geo hash table:";
489  join_hash_table = OverlapsJoinHashTable::getInstance(
490  qual_bin_oper, query_infos, memory_level, device_count, column_cache, executor);
491  } else if (dynamic_cast<const Analyzer::ExpressionTuple*>(
492  qual_bin_oper->get_left_operand())) {
493  VLOG(1) << "Trying to build keyed hash table:";
494  join_hash_table = BaselineJoinHashTable::getInstance(qual_bin_oper,
495  query_infos,
496  memory_level,
497  preferred_hash_type,
498  device_count,
499  column_cache,
500  executor);
501  } else {
502  try {
503  VLOG(1) << "Trying to build perfect hash table:";
504  join_hash_table = JoinHashTable::getInstance(qual_bin_oper,
505  query_infos,
506  memory_level,
507  preferred_hash_type,
508  device_count,
509  column_cache,
510  executor);
511  } catch (TooManyHashEntries&) {
512  const auto join_quals = coalesce_singleton_equi_join(qual_bin_oper);
513  CHECK_EQ(join_quals.size(), size_t(1));
514  const auto join_qual =
515  std::dynamic_pointer_cast<Analyzer::BinOper>(join_quals.front());
516  VLOG(1) << "Trying to build keyed hash table after perfect hash table:";
517  join_hash_table = BaselineJoinHashTable::getInstance(join_qual,
518  query_infos,
519  memory_level,
520  preferred_hash_type,
521  device_count,
522  column_cache,
523  executor);
524  }
525  }
526  CHECK(join_hash_table);
527  if (VLOGGING(2)) {
528  if (join_hash_table->getMemoryLevel() == Data_Namespace::MemoryLevel::GPU_LEVEL) {
529  for (int device_id = 0; device_id < join_hash_table->getDeviceCount();
530  ++device_id) {
531  if (join_hash_table->getJoinHashBufferSize(ExecutorDeviceType::GPU, device_id) <=
532  1000) {
533  VLOG(2) << "Built GPU hash table: "
534  << join_hash_table->toString(ExecutorDeviceType::GPU, device_id);
535  }
536  }
537  } else {
538  if (join_hash_table->getJoinHashBufferSize(ExecutorDeviceType::CPU) <= 1000) {
539  VLOG(2) << "Built CPU hash table: "
540  << join_hash_table->toString(ExecutorDeviceType::CPU);
541  }
542  }
543  }
544  return join_hash_table;
545 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
std::list< std::shared_ptr< Analyzer::Expr > > coalesce_singleton_equi_join(const std::shared_ptr< Analyzer::BinOper > &join_qual)
static std::shared_ptr< OverlapsJoinHashTable > getInstance(const std::shared_ptr< Analyzer::BinOper > condition, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
Make hash table from an in-flight SQL query&#39;s parse tree etc.
#define CHECK_GT(x, y)
Definition: Logger.h:209
static std::shared_ptr< BaselineJoinHashTable > getInstance(const std::shared_ptr< Analyzer::BinOper > condition, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
Make hash table from an in-flight SQL query&#39;s parse tree etc.
static std::shared_ptr< JoinHashTable > getInstance(const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
Make hash table from an in-flight SQL query&#39;s parse tree etc.
bool g_enable_overlaps_hashjoin
Definition: Execute.cpp:92
#define VLOGGING(n)
Definition: Logger.h:195
#define CHECK(condition)
Definition: Logger.h:197
#define DEBUG_TIMER(name)
Definition: Logger.h:313
#define VLOG(n)
Definition: Logger.h:291
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getJoinHashBuffer()

virtual int64_t JoinHashTableInterface::getJoinHashBuffer ( const ExecutorDeviceType  device_type,
const int  device_id = 0 
) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

Referenced by anonymous_namespace{JoinHashTableInterface.cpp}::toStringFlat().

+ Here is the caller graph for this function:

◆ getJoinHashBufferSize()

virtual size_t JoinHashTableInterface::getJoinHashBufferSize ( const ExecutorDeviceType  device_type,
const int  device_id = 0 
) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

Referenced by anonymous_namespace{JoinHashTableInterface.cpp}::toStringFlat().

+ Here is the caller graph for this function:

◆ getMemoryLevel()

virtual Data_Namespace::MemoryLevel JoinHashTableInterface::getMemoryLevel ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

◆ getSyntheticInstance() [1/2]

std::shared_ptr< JoinHashTableInterface > JoinHashTableInterface::getSyntheticInstance ( std::string_view  table1,
std::string_view  column1,
std::string_view  table2,
std::string_view  column2,
const Data_Namespace::MemoryLevel  memory_level,
const HashType  preferred_hash_type,
const int  device_count,
ColumnCacheMap column_cache,
Executor executor 
)
static

Make hash table from named tables and columns (such as for testing).

Definition at line 659 of file JoinHashTableInterface.cpp.

References getInstance(), getSyntheticColumnVar(), getSyntheticInputTableInfo(), kBOOLEAN, kEQ, kONE, setupSyntheticCaching(), and ScalarExprVisitor< T >::visit().

668  {
669  auto a1 = getSyntheticColumnVar(table1, column1, 0, executor);
670  auto a2 = getSyntheticColumnVar(table2, column2, 1, executor);
671 
672  auto qual_bin_oper = std::make_shared<Analyzer::BinOper>(kBOOLEAN, kEQ, kONE, a1, a2);
673 
674  std::set<const Analyzer::ColumnVar*> cvs =
675  AllColumnVarsVisitor().visit(qual_bin_oper.get());
676  auto query_infos = getSyntheticInputTableInfo(cvs, executor);
677  setupSyntheticCaching(cvs, executor);
678 
679  auto hash_table = JoinHashTableInterface::getInstance(qual_bin_oper,
680  query_infos,
681  memory_level,
682  preferred_hash_type,
683  device_count,
684  column_cache,
685  executor);
686  return hash_table;
687 }
std::shared_ptr< Analyzer::ColumnVar > getSyntheticColumnVar(std::string_view table, std::string_view column, int rte_idx, Executor *executor)
Definition: sqldefs.h:30
static std::shared_ptr< JoinHashTableInterface > getInstance(const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
Make hash table from an in-flight SQL query&#39;s parse tree etc.
Definition: sqldefs.h:69
T visit(const Analyzer::Expr *expr) const
void setupSyntheticCaching(std::set< const Analyzer::ColumnVar *> cvs, Executor *executor)
std::vector< InputTableInfo > getSyntheticInputTableInfo(std::set< const Analyzer::ColumnVar *> cvs, Executor *executor)
+ Here is the call graph for this function:

◆ getSyntheticInstance() [2/2]

std::shared_ptr< JoinHashTableInterface > JoinHashTableInterface::getSyntheticInstance ( const std::shared_ptr< Analyzer::BinOper qual_bin_oper,
const Data_Namespace::MemoryLevel  memory_level,
const HashType  preferred_hash_type,
const int  device_count,
ColumnCacheMap column_cache,
Executor executor 
)
static

Make hash table from named tables and columns (such as for testing).

Definition at line 690 of file JoinHashTableInterface.cpp.

References getInstance(), getSyntheticInputTableInfo(), setupSyntheticCaching(), and ScalarExprVisitor< T >::visit().

696  {
697  std::set<const Analyzer::ColumnVar*> cvs =
698  AllColumnVarsVisitor().visit(qual_bin_oper.get());
699  auto query_infos = getSyntheticInputTableInfo(cvs, executor);
700  setupSyntheticCaching(cvs, executor);
701 
702  auto hash_table = JoinHashTableInterface::getInstance(qual_bin_oper,
703  query_infos,
704  memory_level,
705  preferred_hash_type,
706  device_count,
707  column_cache,
708  executor);
709  return hash_table;
710 }
static std::shared_ptr< JoinHashTableInterface > getInstance(const std::shared_ptr< Analyzer::BinOper > qual_bin_oper, const std::vector< InputTableInfo > &query_infos, const Data_Namespace::MemoryLevel memory_level, const HashType preferred_hash_type, const int device_count, ColumnCacheMap &column_cache, Executor *executor)
Make hash table from an in-flight SQL query&#39;s parse tree etc.
T visit(const Analyzer::Expr *expr) const
void setupSyntheticCaching(std::set< const Analyzer::ColumnVar *> cvs, Executor *executor)
std::vector< InputTableInfo > getSyntheticInputTableInfo(std::set< const Analyzer::ColumnVar *> cvs, Executor *executor)
+ Here is the call graph for this function:

◆ layoutRequiresAdditionalBuffers()

virtual bool JoinHashTableInterface::layoutRequiresAdditionalBuffers ( JoinHashTableInterface::HashType  layout) const
pure virtualnoexcept

Implemented in BaselineJoinHashTable, and JoinHashTable.

◆ offsetBufferOff()

virtual size_t JoinHashTableInterface::offsetBufferOff ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

◆ payloadBufferOff()

virtual size_t JoinHashTableInterface::payloadBufferOff ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

◆ toSet() [1/2]

virtual DecodedJoinHashBufferSet JoinHashTableInterface::toSet ( const ExecutorDeviceType  device_type,
const int  device_id 
) const
pure virtual

Implemented in JoinHashTable, and BaselineJoinHashTable.

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

+ Here is the caller graph for this function:

◆ toSet() [2/2]

DecodedJoinHashBufferSet JoinHashTableInterface::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 418 of file JoinHashTableInterface.cpp.

References CHECK, CHECK_LE, anonymous_namespace{JoinHashTableInterface.cpp}::keyed_hash::to_set_one_to_many(), and anonymous_namespace{JoinHashTableInterface.cpp}::keyed_hash::to_set_one_to_one().

426  { // total memory size
428 
429  CHECK_LE(ptr1, ptr2);
430  CHECK_LE(ptr2, ptr3);
431  CHECK_LE(ptr3, ptr4);
432  CHECK_LE(ptr4, ptr1 + buffer_size);
433 
434  bool have_keys = ptr2 > ptr1;
435  bool have_offsets = ptr3 > ptr2;
436  bool have_counts = ptr4 > ptr3;
437  bool have_payloads = (ptr1 + buffer_size) > ptr4;
438 
439  auto i32ptr2 = reinterpret_cast<const int32_t*>(ptr2);
440  auto i32ptr3 = reinterpret_cast<const int32_t*>(ptr3);
441  auto i32ptr4 = reinterpret_cast<const int32_t*>(ptr4);
442 
443  if (have_keys) { // BaselineJoinHashTable or OverlapsJoinHashTable
444  CHECK(key_component_width == 8 || key_component_width == 4);
445  if (key_component_width == 8) {
446  if (!have_offsets && !have_counts) {
447  keyed_hash::to_set_one_to_one<int64_t>(ptr1, entry_count, key_component_count, s);
448  } else {
449  keyed_hash::to_set_one_to_many<int64_t>(
450  ptr1, i32ptr2, i32ptr3, i32ptr4, entry_count, key_component_count, s);
451  }
452  } else if (key_component_width == 4) {
453  if (!have_offsets && !have_counts) {
454  keyed_hash::to_set_one_to_one<int32_t>(ptr1, entry_count, key_component_count, s);
455  } else {
456  keyed_hash::to_set_one_to_many<int32_t>(
457  ptr1, i32ptr2, i32ptr3, i32ptr4, entry_count, key_component_count, s);
458  }
459  }
460  } else { // JoinHashTable
461  if (!have_offsets && !have_counts && have_payloads) {
462  perfect_hash::to_set_one_to_one(i32ptr4, entry_count, s);
463  } else {
464  perfect_hash::to_set_one_to_many(i32ptr2, i32ptr3, i32ptr4, entry_count, s);
465  }
466  }
467 
468  return s;
469 }
std::set< DecodedJoinHashBufferEntry > DecodedJoinHashBufferSet
void to_set_one_to_one(const int8_t *ptr1, size_t entry_count, size_t key_component_count, DecodedJoinHashBufferSet &s)
#define CHECK_LE(x, y)
Definition: Logger.h:208
#define CHECK(condition)
Definition: Logger.h:197
void to_set_one_to_many(const int8_t *ptr1, const int32_t *const ptr2, const int32_t *const ptr3, const int32_t *const ptr4, size_t entry_count, size_t key_component_count, DecodedJoinHashBufferSet &s)
+ Here is the call graph for this function:

◆ toString() [1/2]

virtual std::string JoinHashTableInterface::toString ( const ExecutorDeviceType  device_type,
const int  device_id = 0,
bool  raw = false 
) const
pure virtual

Implemented in JoinHashTable, and BaselineJoinHashTable.

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

+ Here is the caller graph for this function:

◆ toString() [2/2]

std::string JoinHashTableInterface::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 104 of file JoinHashTableInterface.cpp.

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

115  {
116  std::string txt;
117 
118  CHECK(ptr1 <= ptr2);
119  CHECK(ptr2 <= ptr3);
120  CHECK(ptr3 <= ptr4);
121  CHECK(ptr4 <= ptr1 + buffer_size);
122 
123  bool have_keys = ptr2 > ptr1;
124  bool have_offsets = ptr3 > ptr2;
125  bool have_counts = ptr4 > ptr3;
126  bool have_payloads = (ptr1 + buffer_size) > ptr4;
127 
128  // table heading
129  txt += "| " + type;
130  if (!have_offsets && !have_counts) {
131  txt += layout_type;
132  } else if (have_offsets && have_counts) {
133  txt += layout_type;
134  } else {
135  CHECK(false);
136  }
137 
138  // first section: keys
139  if (have_keys) {
140  CHECK(key_component_width == 8 || key_component_width == 4);
141 
142  if (!txt.empty()) {
143  txt += " ";
144  }
145  txt += "| keys ";
146 
147  if (key_component_width == 8) {
148  innerToString<int64_t>(ptr1, entry_count, key_component_count, raw, txt);
149  } else if (key_component_width == 4) {
150  innerToString<int32_t>(ptr1, entry_count, key_component_count, raw, txt);
151  }
152  }
153 
154  // second section: offsets
155  if (have_offsets) {
156  if (!txt.empty()) {
157  txt += " ";
158  }
159  txt += "| offsets ";
160 
161  auto i32ptr2 = reinterpret_cast<const int32_t*>(ptr2);
162  auto i32ptr3 = reinterpret_cast<const int32_t*>(ptr3);
163  for (size_t i = 0; &i32ptr2[i] < i32ptr3; ++i) {
164  if (i != 0) {
165  txt += " ";
166  }
167  if (i32ptr2[i] == -1 && !raw) {
168  txt += "*"; // null
169  } else {
170  txt += std::to_string(i32ptr2[i]);
171  }
172  }
173  }
174 
175  // third section: counts
176  if (have_counts) {
177  if (!txt.empty()) {
178  txt += " ";
179  }
180  txt += "| counts ";
181 
182  auto i32ptr3 = reinterpret_cast<const int32_t*>(ptr3);
183  auto i32ptr4 = reinterpret_cast<const int32_t*>(ptr4);
184  for (size_t i = 0; &i32ptr3[i] < i32ptr4; ++i) {
185  if (i != 0) {
186  txt += " ";
187  }
188  if (i32ptr3[i] == 0 && !raw) {
189  txt += "*"; // null
190  } else {
191  txt += std::to_string(i32ptr3[i]);
192  }
193  }
194  }
195 
196  // fourth section: payloads (rowids)
197  if (have_payloads) {
198  if (!txt.empty()) {
199  txt += " ";
200  }
201  txt += "| payloads ";
202 
203  auto i32ptr4 = reinterpret_cast<const int32_t*>(ptr4);
204  auto i32ptr5 = reinterpret_cast<const int32_t*>(ptr1 + buffer_size);
205  for (size_t i = 0; &i32ptr4[i] < i32ptr5; ++i) {
206  if (i != 0) {
207  txt += " ";
208  }
209  if (i32ptr4[i] == -1 && !raw) {
210  txt += "*"; // null
211  } else {
212  txt += std::to_string(i32ptr4[i]);
213  }
214  }
215  }
216 
217  if (!txt.empty()) {
218  txt += " |";
219  }
220  return txt;
221 }
std::string to_string(char const *&&v)
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:

◆ toStringFlat32()

std::string JoinHashTableInterface::toStringFlat32 ( const ExecutorDeviceType  device_type,
const int  device_id 
) const
virtual

Definition at line 249 of file JoinHashTableInterface.cpp.

250  {
251  return toStringFlat<int32_t>(this, device_type, device_id);
252 }

◆ toStringFlat64()

std::string JoinHashTableInterface::toStringFlat64 ( const ExecutorDeviceType  device_type,
const int  device_id 
) const
virtual

Definition at line 244 of file JoinHashTableInterface.cpp.

245  {
246  return toStringFlat<int64_t>(this, device_type, device_id);
247 }

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