Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Remove redundant translation map code.
Browse files Browse the repository at this point in the history
Signed-off-by: ienkovich <[email protected]>
  • Loading branch information
ienkovich committed Oct 5, 2023
1 parent f17209c commit 9729b44
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 176 deletions.
27 changes: 8 additions & 19 deletions omniscidb/QueryEngine/JoinHashTable/BaselineJoinHashTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ std::pair<size_t, size_t> BaselineJoinHashTable::approximateTupleCount(
true,
join_columns_gpu,
join_column_types_gpu,
nullptr,
nullptr);
const auto key_handler_gpu =
transfer_flat_object_to_gpu(key_handler, allocator);
Expand Down Expand Up @@ -528,24 +527,19 @@ Data_Namespace::MemoryLevel BaselineJoinHashTable::getEffectiveMemoryLevel(
return memory_level_;
}

StrProxyTranslationMapsPtrsAndOffsets decomposeStrDictTranslationMaps(
StrProxyTranslationMapsPtrs decomposeStrDictTranslationMaps(
const std::vector<const StringDictionaryProxy::IdMap*>& str_proxy_translation_maps) {
StrProxyTranslationMapsPtrsAndOffsets translation_map_ptrs_and_offsets;
StrProxyTranslationMapsPtrs translation_map_ptrs_and_offsets;
// First element of pair is vector of int32_t* pointing to translation map "vector"
// Second element of pair is vector of int32_t of min inner dictionary ids (offsets)
const size_t num_translation_maps = str_proxy_translation_maps.size();
translation_map_ptrs_and_offsets.first.reserve(num_translation_maps);
translation_map_ptrs_and_offsets.second.reserve(num_translation_maps);
translation_map_ptrs_and_offsets.reserve(num_translation_maps);
for (const auto& str_proxy_translation_map : str_proxy_translation_maps) {
if (str_proxy_translation_map) {
translation_map_ptrs_and_offsets.first.emplace_back(
str_proxy_translation_map->data());
translation_map_ptrs_and_offsets.second.emplace_back(
str_proxy_translation_map->domainStart());
translation_map_ptrs_and_offsets.emplace_back(str_proxy_translation_map->data());
} else {
// dummy values
translation_map_ptrs_and_offsets.first.emplace_back(nullptr);
translation_map_ptrs_and_offsets.second.emplace_back(0);
translation_map_ptrs_and_offsets.emplace_back(nullptr);
}
}
return translation_map_ptrs_and_offsets;
Expand Down Expand Up @@ -635,8 +629,7 @@ int BaselineJoinHashTable::initHashTableForDevice(
true,
&join_columns[0],
&join_column_types[0],
&str_proxy_translation_map_ptrs_and_offsets.first[0],
&str_proxy_translation_map_ptrs_and_offsets.second[0]);
&str_proxy_translation_map_ptrs_and_offsets[0]);
err = builder.initHashTableOnCpu(&key_handler,
composite_key_info,
join_columns,
Expand Down Expand Up @@ -714,12 +707,8 @@ int BaselineJoinHashTable::initHashTableForDevice(
transfer_vector_of_flat_objects_to_gpu(join_column_types, allocator);
auto join_columns_gpu =
transfer_vector_of_flat_objects_to_gpu(join_columns, allocator);
const auto key_handler = GenericKeyHandler(key_component_count,
true,
join_columns_gpu,
join_column_types_gpu,
nullptr,
nullptr);
const auto key_handler = GenericKeyHandler(
key_component_count, true, join_columns_gpu, join_column_types_gpu, nullptr);

err = builder.initHashTableOnGpu(&key_handler,
join_columns,
Expand Down
3 changes: 1 addition & 2 deletions omniscidb/QueryEngine/JoinHashTable/BaselineJoinHashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@

class Executor;

using StrProxyTranslationMapsPtrsAndOffsets =
std::pair<std::vector<const int32_t*>, std::vector<int32_t>>;
using StrProxyTranslationMapsPtrs = std::vector<const int32_t*>;

// Representation for a hash table using the baseline layout: an open-addressing
// hash with a fill rate of 50%. It is used for equi-joins on multiple columns and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,18 @@ class BaselineJoinHashTableBuilder {
public:
BaselineJoinHashTableBuilder() = default;
template <class KEY_HANDLER>
int initHashTableOnCpu(KEY_HANDLER* key_handler,
const CompositeKeyInfo& composite_key_info,
const std::vector<JoinColumn>& join_columns,
const std::vector<JoinColumnTypeInfo>& join_column_types,
const StrProxyTranslationMapsPtrsAndOffsets&
str_proxy_translation_maps_ptrs_and_offsets,
const size_t keyspace_entry_count,
const size_t keys_for_all_rows,
const HashType layout,
const JoinType join_type,
const size_t key_component_width,
const size_t key_component_count) {
int initHashTableOnCpu(
KEY_HANDLER* key_handler,
const CompositeKeyInfo& composite_key_info,
const std::vector<JoinColumn>& join_columns,
const std::vector<JoinColumnTypeInfo>& join_column_types,
const StrProxyTranslationMapsPtrs& str_proxy_translation_maps_ptrs_and_offsets,
const size_t keyspace_entry_count,
const size_t keys_for_all_rows,
const HashType layout,
const JoinType join_type,
const size_t key_component_width,
const size_t key_component_count) {
auto timer = DEBUG_TIMER(__func__);
const auto entry_size =
(key_component_count + (layout == HashType::OneToOne ? 1 : 0)) *
Expand Down Expand Up @@ -321,8 +321,7 @@ class BaselineJoinHashTableBuilder {
key_component_count,
join_columns,
join_column_types,
str_proxy_translation_maps_ptrs_and_offsets.first,
str_proxy_translation_maps_ptrs_and_offsets.second,
str_proxy_translation_maps_ptrs_and_offsets,
thread_count);
break;
}
Expand All @@ -336,8 +335,7 @@ class BaselineJoinHashTableBuilder {
key_component_count,
join_columns,
join_column_types,
str_proxy_translation_maps_ptrs_and_offsets.first,
str_proxy_translation_maps_ptrs_and_offsets.second,
str_proxy_translation_maps_ptrs_and_offsets,
thread_count);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ class PerfectJoinHashTableBuilder {
join_column,
type_info,
str_proxy_translation_map ? str_proxy_translation_map->data() : nullptr,
str_proxy_translation_map ? str_proxy_translation_map->domainStart()
: 0, // 0 is dummy value
hash_entry_info.bucket_normalization);
if (error) {
// Too many hash entries, need to retry with a 1:many table
Expand Down Expand Up @@ -255,8 +253,6 @@ class PerfectJoinHashTableBuilder {
col_range.getIntMax() + 1,
get_join_column_type_kind(type)},
str_proxy_translation_map ? str_proxy_translation_map->data() : nullptr,
str_proxy_translation_map ? str_proxy_translation_map->domainStart()
: 0 /*dummy*/,
thread_count);
} else {
fill_one_to_many_hash_table(
Expand All @@ -272,8 +268,6 @@ class PerfectJoinHashTableBuilder {
col_range.getIntMax() + 1,
get_join_column_type_kind(type)},
str_proxy_translation_map ? str_proxy_translation_map->data() : nullptr,
str_proxy_translation_map ? str_proxy_translation_map->domainStart()
: 0 /*dummy*/,
thread_count);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ struct GenericKeyHandler {
const JoinColumnTypeInfo* type_info_per_key
#ifndef __CUDACC__
,
const int32_t* const* sd_inner_to_outer_translation_maps,
const int32_t* sd_min_inner_elems
const int32_t* const* sd_inner_to_outer_translation_maps
#endif
)
: key_component_count_(key_component_count)
Expand All @@ -51,14 +50,11 @@ struct GenericKeyHandler {
, type_info_per_key_(type_info_per_key) {
#ifndef __CUDACC__
if (sd_inner_to_outer_translation_maps) {
CHECK(sd_min_inner_elems);
sd_inner_to_outer_translation_maps_ = sd_inner_to_outer_translation_maps;
sd_min_inner_elems_ = sd_min_inner_elems;
} else
#endif
{
sd_inner_to_outer_translation_maps_ = nullptr;
sd_min_inner_elems_ = nullptr;
}
}

Expand All @@ -81,11 +77,9 @@ struct GenericKeyHandler {
if (sd_inner_to_outer_translation_maps_) {
const auto sd_inner_to_outer_translation_map =
sd_inner_to_outer_translation_maps_[key_component_index];
const auto sd_min_inner_elem = sd_min_inner_elems_[key_component_index];
if (sd_inner_to_outer_translation_map &&
elem != join_column_iterator.type_info->null_val) {
const auto outer_id =
sd_inner_to_outer_translation_map[elem - sd_min_inner_elem];
const auto outer_id = sd_inner_to_outer_translation_map[elem];
if (outer_id == StringDictionary::INVALID_STR_ID) {
skip_entry = true;
break;
Expand Down Expand Up @@ -119,7 +113,6 @@ struct GenericKeyHandler {
const JoinColumn* join_column_per_key_;
const JoinColumnTypeInfo* type_info_per_key_;
const int32_t* const* sd_inner_to_outer_translation_maps_;
const int32_t* sd_min_inner_elems_;
};

#endif // QUERYENGINE_HASHJOINKEYHANDLERS_H
Loading

0 comments on commit 9729b44

Please sign in to comment.