OmniSciDB  17c254d2f8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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, ThrustAllocator &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
< 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's parse tree etc. More...
 
static std::shared_ptr
< 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)
 Make hash table from named tables and columns (such as for testing). More...
 
static std::shared_ptr
< 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)
 Make hash table from named tables and columns (such as for testing). More...
 

Detailed Description

Definition at line 82 of file JoinHashTableInterface.h.

Member Enumeration Documentation

Enumerator
OneToOne 
OneToMany 
ManyToMany 

Definition at line 113 of file JoinHashTableInterface.h.

113 : int { OneToOne, OneToMany, ManyToMany };

Member Function Documentation

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

Implemented in JoinHashTable, and BaselineJoinHashTable.

virtual size_t JoinHashTableInterface::countBufferOff ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

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,
ThrustAllocator 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 30 of file JoinHashTableInterface.cpp.

References ThrustAllocator::allocate(), JoinColumn::col_chunks_buff, JoinColumn::col_chunks_buff_sz, copy_to_gpu(), Data_Namespace::GPU_LEVEL, and ColumnFetcher::makeJoinColumn().

Referenced by OverlapsJoinHashTable::fetchColumnsForDevice(), BaselineJoinHashTable::fetchColumnsForDevice(), JoinHashTable::reifyOneToManyForDevice(), and JoinHashTable::reifyOneToOneForDevice().

39  {
40  static std::mutex fragment_fetch_mutex;
41  const auto& catalog = *executor->getCatalog();
42  auto& data_mgr = catalog.getDataMgr();
43  {
44  std::lock_guard<std::mutex> fragment_fetch_lock(fragment_fetch_mutex);
45  try {
46  JoinColumn join_column = ColumnFetcher::makeJoinColumn(executor,
47  *hash_col,
48  fragment_info,
49  effective_memory_level,
50  device_id,
51  chunks_owner,
52  malloc_owner,
53  *column_cache);
54  if (effective_memory_level == Data_Namespace::GPU_LEVEL) {
55  const int8_t* device_col_chunks_buff =
56  dev_buff_owner.allocate(join_column.col_chunks_buff_sz);
57  copy_to_gpu(&data_mgr,
58  reinterpret_cast<CUdeviceptr>(device_col_chunks_buff),
59  join_column.col_chunks_buff,
60  join_column.col_chunks_buff_sz,
61  device_id);
62  join_column.col_chunks_buff = device_col_chunks_buff;
63  }
64  return join_column;
65  } catch (...) {
66  throw FailedToFetchColumn();
67  }
68  }
69 }
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, 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.
int8_t * allocate(std::ptrdiff_t num_bytes)
size_t col_chunks_buff_sz
void copy_to_gpu(Data_Namespace::DataMgr *data_mgr, CUdeviceptr dst, const void *src, const size_t num_bytes, const int device_id)
Definition: GpuMemUtils.cpp:31
const int8_t * col_chunks_buff

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual int JoinHashTableInterface::getDeviceCount ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

virtual HashType JoinHashTableInterface::getHashType ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

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

Definition at line 120 of file JoinHashTableInterface.h.

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

120  {
121  const char* HashTypeStrings[3] = {"OneToOne", "OneToMany", "ManyToMany"};
122  return HashTypeStrings[static_cast<int>(ht)];
123  };

+ Here is the caller graph for this function:

virtual int JoinHashTableInterface::getInnerTableId ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

virtual int JoinHashTableInterface::getInnerTableRteIdx ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

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 473 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().

480  {
481  auto timer = DEBUG_TIMER(__func__);
482  std::shared_ptr<JoinHashTableInterface> join_hash_table;
483  CHECK_GT(device_count, 0);
484  if (!g_enable_overlaps_hashjoin && qual_bin_oper->is_overlaps_oper()) {
485  throw std::runtime_error(
486  "Overlaps hash join disabled, attempting to fall back to loop join");
487  }
488  if (qual_bin_oper->is_overlaps_oper()) {
489  VLOG(1) << "Trying to build geo hash table:";
490  join_hash_table = OverlapsJoinHashTable::getInstance(
491  qual_bin_oper, query_infos, memory_level, device_count, column_cache, executor);
492  } else if (dynamic_cast<const Analyzer::ExpressionTuple*>(
493  qual_bin_oper->get_left_operand())) {
494  VLOG(1) << "Trying to build keyed hash table:";
495  join_hash_table = BaselineJoinHashTable::getInstance(qual_bin_oper,
496  query_infos,
497  memory_level,
498  preferred_hash_type,
499  device_count,
500  column_cache,
501  executor);
502  } else {
503  try {
504  VLOG(1) << "Trying to build perfect hash table:";
505  join_hash_table = JoinHashTable::getInstance(qual_bin_oper,
506  query_infos,
507  memory_level,
508  preferred_hash_type,
509  device_count,
510  column_cache,
511  executor);
512  } catch (TooManyHashEntries&) {
513  const auto join_quals = coalesce_singleton_equi_join(qual_bin_oper);
514  CHECK_EQ(join_quals.size(), size_t(1));
515  const auto join_qual =
516  std::dynamic_pointer_cast<Analyzer::BinOper>(join_quals.front());
517  VLOG(1) << "Trying to build keyed hash table after perfect hash table:";
518  join_hash_table = BaselineJoinHashTable::getInstance(join_qual,
519  query_infos,
520  memory_level,
521  preferred_hash_type,
522  device_count,
523  column_cache,
524  executor);
525  }
526  }
527  CHECK(join_hash_table);
528  if (VLOGGING(2)) {
529  if (join_hash_table->getMemoryLevel() == Data_Namespace::MemoryLevel::GPU_LEVEL) {
530  for (int device_id = 0; device_id < join_hash_table->getDeviceCount();
531  ++device_id) {
532  if (join_hash_table->getJoinHashBufferSize(ExecutorDeviceType::GPU, device_id) <=
533  1000) {
534  VLOG(2) << "Built GPU hash table: "
535  << join_hash_table->toString(ExecutorDeviceType::GPU, device_id);
536  }
537  }
538  } else {
539  if (join_hash_table->getJoinHashBufferSize(ExecutorDeviceType::CPU) <= 1000) {
540  VLOG(2) << "Built CPU hash table: "
541  << join_hash_table->toString(ExecutorDeviceType::CPU);
542  }
543  }
544  }
545  return join_hash_table;
546 }
#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.
bool g_enable_overlaps_hashjoin
Definition: Execute.cpp:90
CHECK(cgen_state)
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.
#define VLOGGING(n)
Definition: Logger.h:195
#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:

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:

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:

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

Implemented in JoinHashTable, and BaselineJoinHashTable.

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 660 of file JoinHashTableInterface.cpp.

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

669  {
670  auto a1 = getSyntheticColumnVar(table1, column1, 0, executor);
671  auto a2 = getSyntheticColumnVar(table2, column2, 1, executor);
672 
673  auto qual_bin_oper = std::make_shared<Analyzer::BinOper>(kBOOLEAN, kEQ, kONE, a1, a2);
674 
675  std::set<const Analyzer::ColumnVar*> cvs =
676  AllColumnVarsVisitor().visit(qual_bin_oper.get());
677  auto query_infos = getSyntheticInputTableInfo(cvs, executor);
678  setupSyntheticCaching(cvs, executor);
679 
680  auto hash_table = JoinHashTableInterface::getInstance(qual_bin_oper,
681  query_infos,
682  memory_level,
683  preferred_hash_type,
684  device_count,
685  column_cache,
686  executor);
687  return hash_table;
688 }
std::vector< InputTableInfo > getSyntheticInputTableInfo(std::set< const Analyzer::ColumnVar * > cvs, Executor *executor)
std::shared_ptr< Analyzer::ColumnVar > getSyntheticColumnVar(std::string_view table, std::string_view column, int rte_idx, Executor *executor)
Definition: sqldefs.h:30
T visit(const Analyzer::Expr *expr) const
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
void setupSyntheticCaching(std::set< const Analyzer::ColumnVar * > cvs, Executor *executor)

+ Here is the call graph for this function:

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 691 of file JoinHashTableInterface.cpp.

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

697  {
698  std::set<const Analyzer::ColumnVar*> cvs =
699  AllColumnVarsVisitor().visit(qual_bin_oper.get());
700  auto query_infos = getSyntheticInputTableInfo(cvs, executor);
701  setupSyntheticCaching(cvs, executor);
702 
703  auto hash_table = JoinHashTableInterface::getInstance(qual_bin_oper,
704  query_infos,
705  memory_level,
706  preferred_hash_type,
707  device_count,
708  column_cache,
709  executor);
710  return hash_table;
711 }
std::vector< InputTableInfo > getSyntheticInputTableInfo(std::set< const Analyzer::ColumnVar * > cvs, Executor *executor)
T visit(const Analyzer::Expr *expr) const
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.
void setupSyntheticCaching(std::set< const Analyzer::ColumnVar * > cvs, Executor *executor)

+ Here is the call graph for this function:

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

Implemented in BaselineJoinHashTable, and JoinHashTable.

virtual size_t JoinHashTableInterface::offsetBufferOff ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

virtual size_t JoinHashTableInterface::payloadBufferOff ( ) const
pure virtualnoexcept

Implemented in JoinHashTable, and BaselineJoinHashTable.

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:

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 419 of file JoinHashTableInterface.cpp.

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

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

+ Here is the call graph for this function:

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:

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 105 of file JoinHashTableInterface.cpp.

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

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

+ Here is the call graph for this function:

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

Definition at line 250 of file JoinHashTableInterface.cpp.

251  {
252  return toStringFlat<int32_t>(this, device_type, device_id);
253 }
std::string JoinHashTableInterface::toStringFlat64 ( const ExecutorDeviceType  device_type,
const int  device_id 
) const
virtual

Definition at line 245 of file JoinHashTableInterface.cpp.

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

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