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

[NSE-293] fix unsafemap with key = '0' #294

Merged
merged 1 commit into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion native-sql-engine/cpp/src/codegen/common/hash_relation.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ class HashRelation {
throw std::runtime_error("HashRelation Get failed, hash_table is null.");
}
if (sizeof(payload) <= 8) {
if (*(CType*)recent_cached_key_ == payload) return recent_cached_key_probe_res_;
if (has_cached_ && *(CType*)recent_cached_key_ == payload) {
return recent_cached_key_probe_res_;
}
has_cached_ = true;
*(CType*)recent_cached_key_ = payload;
}
int32_t v = hash32(payload, true);
Expand Down Expand Up @@ -445,6 +448,7 @@ class HashRelation {
std::vector<ArrayItemIndex> arrayid_list_;
int key_size_;
char recent_cached_key_[8] = {0};
bool has_cached_ = false;
int recent_cached_key_probe_res_ = -1;

arrow::Status Insert(int32_t v, std::shared_ptr<UnsafeRow> payload, uint32_t array_id,
Expand Down