◆ Initialize()
379405 {
379406 BufferManager &buffer_manager = BufferManager::GetBufferManager(context_p);
379407
379408 const idx_t min_bits = std::max<idx_t>(MIN_NUM_BITS, number_of_rows * MIN_NUM_BITS_PER_KEY);
379409 num_sectors = std::min(NextPowerOfTwo(min_bits) >> LOG_SECTOR_SIZE, MAX_NUM_SECTORS);
379410 bitmask = num_sectors - 1;
379411
379412 buf_ = buffer_manager.GetBufferAllocator().Allocate(64 + num_sectors * sizeof(uint64_t));
379413
379414 bf =
reinterpret_cast<uint64_t *
>((64ULL +
reinterpret_cast<uint64_t>(buf_.get())) & ~63ULL);
379415 std::fill_n(bf, num_sectors, 0);
379416
379417 initialized = true;
379418}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
◆ InsertHashes()
| void duckdb::BloomFilter::InsertHashes |
( |
const Vector & | hashes_v, |
|
|
idx_t | count ) const |
379434 {
379435 auto hashes = FlatVector::GetData<uint64_t>(hashes_v);
379436 for (
idx_t i = 0; i < count; i++) {
379437 InsertOne(hashes[i]);
379438 }
379439}
◆ LookupHashes()
379441 {
379442 D_ASSERT(hashes_v.GetVectorType() == VectorType::FLAT_VECTOR);
379443 D_ASSERT(hashes_v.GetType() == LogicalType::HASH);
379444
379445 const auto hashes = FlatVector::GetData<uint64_t>(hashes_v);
379446 idx_t found_count = 0;
379447 for (
idx_t i = 0; i < count; i++) {
379448 result_sel.set_index(found_count, i);
379449 found_count += LookupOne(hashes[i]);
379450 }
379451 return found_count;
379452}
◆ InsertOne()
| void duckdb::BloomFilter::InsertOne |
( |
hash_t | hash | ) |
const |
|
inline |
379454 {
379455 D_ASSERT(initialized);
379456 const uint64_t bf_offset = hash & bitmask;
379458 std::atomic<uint64_t> &slot = *reinterpret_cast<std::atomic<uint64_t> *>(&bf[bf_offset]);
379459
379460 slot.fetch_or(mask, std::memory_order_relaxed);
379461}
GMat mask(const GMat &src, const GMat &mask)
◆ LookupOne()
| bool duckdb::BloomFilter::LookupOne |
( |
hash_t | hash | ) |
const |
|
inline |
379463 {
379464 D_ASSERT(initialized);
379465 const uint64_t bf_offset = hash & bitmask;
379467 atomic<uint64_t> &slot = *reinterpret_cast<atomic<uint64_t> *>(&bf[bf_offset]);
379468 auto bf_entry = slot.load(std::memory_order_relaxed);
379469
379470 return (bf_entry & mask) ==
mask;
379471}
◆ IsInitialized()
| bool duckdb::BloomFilter::IsInitialized |
( |
| ) |
const |
|
inline |
81256 {
81257 return initialized;
81258 }
The documentation for this class was generated from the following file: