Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/exec/key_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void SwissTable::find(const int num_keys, const uint32_t* hashes,
return;
}

auto slot_ids_buf = util::TempVectorHolder<uint32_t>(temp_stack_, num_ids);
auto slot_ids_buf = util::TempVectorHolder<uint32_t>(temp_stack_, num_keys);
uint32_t* slot_ids = slot_ids_buf.mutable_data();
init_slot_ids(num_ids, ids, hashes, local_slots, inout_match_bitvector, slot_ids);

Expand Down
21 changes: 16 additions & 5 deletions cpp/src/arrow/compute/exec/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,35 @@ class TempVectorStack {
// using SIMD when number of vector elements is not divisible
// by the number of SIMD lanes.
//
return ::arrow::BitUtil::RoundUp(num_bytes, sizeof(int64_t)) + padding;
return ::arrow::BitUtil::RoundUp(num_bytes, sizeof(int64_t)) + kPadding;
}
void alloc(uint32_t num_bytes, uint8_t** data, int* id) {
int64_t old_top = top_;
top_ += PaddedAllocationSize(num_bytes);
top_ += PaddedAllocationSize(num_bytes) + 2 * sizeof(uint64_t);
// Stack overflow check
ARROW_DCHECK(top_ <= buffer_size_);
*data = buffer_->mutable_data() + old_top;
*data = buffer_->mutable_data() + old_top + sizeof(uint64_t);
// We set 8 bytes before the beginning of the allocated range and
// 8 bytes after the end to check for stack overflow (which would
// result in those known bytes being corrupted).
reinterpret_cast<uint64_t*>(buffer_->mutable_data() + old_top)[0] = kGuard1;
reinterpret_cast<uint64_t*>(buffer_->mutable_data() + top_)[-1] = kGuard2;
*id = num_vectors_++;
}
void release(int id, uint32_t num_bytes) {
ARROW_DCHECK(num_vectors_ == id + 1);
int64_t size = PaddedAllocationSize(num_bytes);
int64_t size = PaddedAllocationSize(num_bytes) + 2 * sizeof(uint64_t);
ARROW_DCHECK(reinterpret_cast<const uint64_t*>(buffer_->mutable_data() + top_)[-1] ==
kGuard2);
ARROW_DCHECK(top_ >= size);
top_ -= size;
ARROW_DCHECK(reinterpret_cast<const uint64_t*>(buffer_->mutable_data() + top_)[0] ==
kGuard1);
--num_vectors_;
}
static constexpr int64_t padding = 64;
static constexpr uint64_t kGuard1 = 0x3141592653589793ULL;
static constexpr uint64_t kGuard2 = 0x0577215664901532ULL;
static constexpr int64_t kPadding = 64;
int num_vectors_;
int64_t top_;
std::unique_ptr<Buffer> buffer_;
Expand Down