Skip to content

Commit

Permalink
[fix]Empty string key in aggregation was output as NULL (apache#11011)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhhsg authored and whutpencil committed Jul 29, 2022
1 parent 642dc3a commit a929c87
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions be/src/vec/common/hash_table/string_hash_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ struct StringHashTableEmpty //-V730
public:
bool has_zero() const { return _has_zero; }

void set_has_zero() {
void set_has_zero(const typename Cell::key_type& key) {
_has_zero = true;
new (zero_value()) Cell();
zero_value()->value.first = key;
}

void set_has_zero(const Cell& other) {
Expand All @@ -118,9 +119,11 @@ struct StringHashTableEmpty //-V730
using ConstLookupResult = const Cell*;

template <typename KeyHolder>
void ALWAYS_INLINE emplace(KeyHolder&&, LookupResult& it, bool& inserted, size_t = 0) {
void ALWAYS_INLINE emplace(KeyHolder&& key_holder, LookupResult& it, bool& inserted,
size_t = 0) {
if (!has_zero()) {
set_has_zero();
const auto& key = key_holder_get_key(key_holder);
set_has_zero(key);
inserted = true;
} else
inserted = false;
Expand Down Expand Up @@ -467,7 +470,7 @@ class StringHashTable : private boost::noncopyable {
const size_t sz = x.size;
if (sz == 0) {
key_holder_discard_key(key_holder);
return func(self.m0, VoidKey {}, 0);
return func(self.m0, std::forward<KeyHolder>(key_holder), 0);
}

if (x.data[sz - 1] == 0) {
Expand Down

0 comments on commit a929c87

Please sign in to comment.