Skip to content

Commit

Permalink
More refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
zanmato1984 committed Dec 26, 2024
1 parent 8ede8ea commit 9dec0b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions cpp/src/arrow/compute/key_map_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ void SwissTable::init_slot_ids(const int num_keys, const uint16_t* selection,
for (int i = 0; i < num_keys; ++i) {
uint16_t id = selection[i];
uint32_t hash = hashes[id];
uint32_t iblock = hash >> (bits_hash_ - log_blocks_);
uint32_t match = ::arrow::bit_util::GetBit(match_bitvector, id) ? 1 : 0;
uint32_t block_id = hash >> (bits_hash_ - log_blocks_);
uint32_t slot_id = block_id * 8u + local_slots[id] + match;
uint32_t slot_id = iblock * 8u + local_slots[id] + match;
out_slot_ids[id] = slot_id;
}
}
Expand All @@ -186,8 +186,8 @@ void SwissTable::init_slot_ids_for_new_keys(uint32_t num_ids, const uint16_t* id
uint32_t iblock = hash >> (bits_hash_ - log_blocks_);
uint64_t block;
for (;;) {
int64_t pos = num_block_bytes * iblock;
block = *reinterpret_cast<const uint64_t*>(blocks_->mutable_data() + pos);
block = *reinterpret_cast<const uint64_t*>(blocks_->mutable_data() +
num_block_bytes * iblock);
block &= kHighBitOfEachByte;
if (block) {
break;
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/arrow/compute/key_map_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,14 @@ uint64_t SwissTable::extract_group_id(const uint8_t* block_ptr, int slot,

void SwissTable::insert_into_empty_slot(uint32_t slot_id, uint32_t hash,
uint32_t group_id) {
const uint64_t num_groupid_bits = num_groupid_bits_from_log_blocks(log_blocks_);
const int64_t num_groupid_bits = num_groupid_bits_from_log_blocks(log_blocks_);

// We assume here that the number of bits is rounded up to 8, 16, 32 or 64.
// In that case we can insert group id value using aligned 64-bit word access.
assert(num_groupid_bits == 8 || num_groupid_bits == 16 || num_groupid_bits == 32 ||
num_groupid_bits == 64);

const uint64_t num_block_bytes =
num_block_bytes_from_num_groupid_bits(num_groupid_bits);
const int64_t num_block_bytes = num_block_bytes_from_num_groupid_bits(num_groupid_bits);
constexpr uint64_t stamp_mask = 0x7f;

int start_slot = (slot_id & 7);
Expand Down

0 comments on commit 9dec0b9

Please sign in to comment.