From d948e77fe2b4bfc2aeec13c5b24dfc2cc0cf55b4 Mon Sep 17 00:00:00 2001 From: Rossi Sun Date: Fri, 27 Dec 2024 13:30:45 +0800 Subject: [PATCH] Fix --- cpp/src/arrow/compute/key_map_internal.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/compute/key_map_internal.cc b/cpp/src/arrow/compute/key_map_internal.cc index fbde367e30250..1f752be85d35c 100644 --- a/cpp/src/arrow/compute/key_map_internal.cc +++ b/cpp/src/arrow/compute/key_map_internal.cc @@ -106,6 +106,10 @@ void SwissTable::extract_group_ids_imp(const int num_keys, const uint16_t* selec } } else { int64_t num_groupid_bits = num_groupid_bits_from_log_blocks(log_blocks_); + int64_t num_groupid_bytes = num_groupid_bits / 8; + uint32_t mask = num_groupid_bytes == 1 ? 0xFF + : num_groupid_bytes == 2 ? 0xFFFF + : 0xFFFFFFFF; int64_t num_block_bytes = num_block_bytes_from_num_groupid_bits(num_groupid_bits); const uint8_t* slots_base = blocks_->data() + bytes_status_; @@ -113,8 +117,9 @@ void SwissTable::extract_group_ids_imp(const int num_keys, const uint16_t* selec uint32_t id = use_selection ? selection[i] : i; uint32_t hash = hashes[id]; uint32_t block_id = hash >> (bits_hash_ - log_blocks_); - uint32_t group_id = reinterpret_cast( - slots_base + block_id * num_block_bytes)[local_slots[id]]; + uint32_t group_id = *reinterpret_cast( + slots_base + block_id * num_block_bytes + local_slots[id] * num_groupid_bytes); + group_id &= mask; out_group_ids[id] = group_id; } }