Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::BloomFilter Class Reference
Collaboration diagram for duckdb::BloomFilter:

Public Member Functions

void Initialize (ClientContext &context_p, idx_t number_of_rows)
void InsertHashes (const Vector &hashes_v, idx_t count) const
idx_t LookupHashes (const Vector &hashes_v, SelectionVector &result_sel, idx_t count) const
void InsertOne (hash_t hash) const
bool LookupOne (hash_t hash) const
bool IsInitialized () const

Private Attributes

idx_t num_sectors
uint64_t bitmask
bool initialized = false
AllocatedData buf_
uint64_t * bf

Member Function Documentation

◆ Initialize()

void duckdb::BloomFilter::Initialize ( ClientContext & context_p,
idx_t number_of_rows )
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 // make sure blocks is a 64-byte aligned pointer, i.e., cache-line aligned
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 uint64_t
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()

idx_t duckdb::BloomFilter::LookupHashes ( const Vector & hashes_v,
SelectionVector & result_sel,
idx_t count ) const
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;
379457 const uint64_t mask = GetMask(hash);
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;
379466 const uint64_t mask = GetMask(hash);
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: