MCPcopy Create free account
hub / github.com/apache/arrow / insert_into_empty_slot

Method insert_into_empty_slot

cpp/src/arrow/compute/key_map_internal.h:322–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320};
321
322void SwissTable::insert_into_empty_slot(uint32_t global_slot_id, uint32_t hash,
323 uint32_t group_id) {
324 const int num_groupid_bits = num_groupid_bits_from_log_blocks(log_blocks_);
325
326 // We assume here that the number of bits is rounded up to 8, 16, 32 or 64.
327 // In that case we can insert group id value using aligned 64-bit word access.
328 assert(num_groupid_bits == 8 || num_groupid_bits == 16 || num_groupid_bits == 32 ||
329 num_groupid_bits == 64);
330
331 const int num_block_bytes = num_block_bytes_from_num_groupid_bits(num_groupid_bits);
332 constexpr uint32_t stamp_mask = 0x7f;
333
334 int start_slot = (global_slot_id & kLocalSlotMask);
335 int stamp = (hash >> bits_shift_for_block_and_stamp_) & stamp_mask;
336 uint32_t block_id = global_slot_id >> kLogSlotsPerBlock;
337 uint8_t* blockbase = mutable_block_data(block_id, num_block_bytes);
338
339 blockbase[kMaxLocalSlot - start_slot] = static_cast<uint8_t>(stamp);
340 int groupid_bit_offset = start_slot * num_groupid_bits;
341
342 // Block status bytes should start at an address aligned to 8 bytes
343 assert((reinterpret_cast<uint64_t>(blockbase) & 7) == 0);
344 uint64_t* ptr = reinterpret_cast<uint64_t*>(blockbase + bytes_status_in_block_) +
345 (groupid_bit_offset >> 6);
346 *ptr |= (static_cast<uint64_t>(group_id) << (groupid_bit_offset & 63));
347}
348
349} // namespace compute
350} // namespace arrow

Callers 1

InsertNewGroupMethod · 0.80

Tested by

no test coverage detected