Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
Fix q14a/b segfault (#193)
Browse files Browse the repository at this point in the history
Signed-off-by: Chendi Xue <chendi.xue@intel.com>
  • Loading branch information
xuechendi authored Mar 25, 2021
1 parent 53993e3 commit ca9ddb7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,16 @@ class HashRelationKernel::Impl {
if (num_total_cached_ > 32) {
init_key_capacity = pow(2, ceil(log2(num_total_cached_)) + 1);
}
long tmp_capacity = init_key_capacity;
if (key_size_ != -1) {
init_bytes_map_capacity = init_key_capacity * 12;
tmp_capacity *= 12;
} else {
init_bytes_map_capacity = init_key_capacity * 128;
tmp_capacity *= 128;
}
if (tmp_capacity > INT_MAX) {
init_bytes_map_capacity = INT_MAX;
} else {
init_bytes_map_capacity = tmp_capacity;
}
RETURN_NOT_OK(
hash_relation_->InitHashTable(init_key_capacity, init_bytes_map_capacity));
Expand Down
6 changes: 6 additions & 0 deletions native-sql-engine/cpp/src/codegen/common/hash_relation.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "precompile/unsafe_array.h"
#include "third_party/murmurhash/murmurhash32.h"
#include "third_party/row_wise_memory/hashMap.h"
#include "utils/macros.h"

using sparkcolumnarplugin::codegen::arrowcompute::extra::ArrayItemIndex;
using sparkcolumnarplugin::precompile::enable_if_number;
Expand Down Expand Up @@ -142,6 +143,11 @@ class HashRelation {
}

arrow::Status InitHashTable(int init_key_capacity, int initial_bytesmap_capacity) {
if (init_key_capacity < 0 || initial_bytesmap_capacity < 0) {
THROW_NOT_OK(arrow::Status::Invalid(
"initialization size is overflowed, init_key_capacity is ", init_key_capacity,
", initial_bytesmap_capacity is ", initial_bytesmap_capacity));
}
hash_table_ = createUnsafeHashMap(ctx_->memory_pool(), init_key_capacity,
initial_bytesmap_capacity, key_size_);
return arrow::Status::OK();
Expand Down

0 comments on commit ca9ddb7

Please sign in to comment.