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::BFTableFilter Class Referencefinal
Inheritance diagram for duckdb::BFTableFilter:
Collaboration diagram for duckdb::BFTableFilter:

Public Member Functions

 BFTableFilter (BloomFilter &filter_p, const bool filters_null_values_p, const string &key_column_name_p, const LogicalType &key_type_p)
bool FiltersNullValues () const
LogicalType GetKeyType () const
string ToString (const string &column_name) const override
idx_t Filter (Vector &keys_v, SelectionVector &sel, idx_t &approved_tuple_count, BFTableFilterState &state) const
bool FilterValue (const Value &value) const
FilterPropagateResult CheckStatistics (BaseStatistics &stats) const override
 Returns true if the statistics indicate that the segment can contain values that satisfy that filter.
Public Member Functions inherited from duckdb::TableFilter
 TableFilter (TableFilterType filter_type_p)
string DebugToString () const
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Attributes

static constexpr auto TYPE = TableFilterType::BLOOM_FILTER

Private Member Functions

bool Equals (const TableFilter &other) const override
unique_ptr< TableFilter > Copy () const override
unique_ptr< Expression > ToExpression (const Expression &column) const override
void Serialize (Serializer &serializer) const override

Static Private Member Functions

static void HashInternal (Vector &keys_v, const SelectionVector &sel, const idx_t approved_count, BFTableFilterState &state)
static unique_ptr< TableFilter > Deserialize (Deserializer &deserializer)

Private Attributes

BloomFilter & filter
bool filters_null_values
string key_column_name
LogicalType key_type

Additional Inherited Members

Static Public Member Functions inherited from duckdb::TableFilter
static unique_ptr< TableFilter > Deserialize (Deserializer &deserializer)
Public Attributes inherited from duckdb::TableFilter
TableFilterType filter_type

Constructor & Destructor Documentation

◆ BFTableFilter()

duckdb::BFTableFilter::BFTableFilter ( BloomFilter & filter_p,
const bool filters_null_values_p,
const string & key_column_name_p,
const LogicalType & key_type_p )
inlineexplicit
81283 : TableFilter(TYPE), filter(filter_p), filters_null_values(filters_null_values_p),
81284 key_column_name(key_column_name_p), key_type(key_type_p) {
81285 }

Member Function Documentation

◆ FiltersNullValues()

bool duckdb::BFTableFilter::FiltersNullValues ( ) const
inline

If the join condition is e.g. "A = B", the bf will filter null values. If the condition is "A is B" the filter will let nulls pass

81289 {
81290 return filters_null_values;
81291 }
Here is the caller graph for this function:

◆ GetKeyType()

LogicalType duckdb::BFTableFilter::GetKeyType ( ) const
inline
81293 {
81294 return key_type;
81295 }

◆ ToString()

string duckdb::BFTableFilter::ToString ( const string & column_name) const
overridevirtual

Implements duckdb::TableFilter.

379473 {
379474 return column_name + " IN BF(" + key_column_name + ")";
379475}

◆ Filter()

idx_t duckdb::BFTableFilter::Filter ( Vector & keys_v,
SelectionVector & sel,
idx_t & approved_tuple_count,
BFTableFilterState & state ) const
379488 {
379489 if (state.current_capacity < approved_tuple_count) {
379490 state.hashes_v.Initialize(false, approved_tuple_count);
379491 state.bf_sel.Initialize(approved_tuple_count);
379492 state.current_capacity = approved_tuple_count;
379493 }
379494
379495 HashInternal(keys_v, sel, approved_tuple_count, state);
379496
379497 idx_t found_count;
379498 if (state.hashes_v.GetVectorType() == VectorType::CONSTANT_VECTOR) {
379499 const auto constant_hash = *ConstantVector::GetData<hash_t>(state.hashes_v);
379500 const bool found = this->filter.LookupOne(constant_hash);
379501 found_count = found ? approved_tuple_count : 0;
379502 } else {
379503 state.hashes_v.Flatten(approved_tuple_count);
379504 found_count = this->filter.LookupHashes(state.hashes_v, state.bf_sel, approved_tuple_count);
379505 }
379506
379507 // all the elements have been found, we don't need to translate anything
379508 if (found_count == approved_tuple_count) {
379509 return approved_tuple_count;
379510 }
379511
379512 if (sel.IsSet()) {
379513 for (idx_t idx = 0; idx < found_count; idx++) {
379514 const idx_t flat_sel_idx = state.bf_sel.get_index(idx);
379515 const idx_t original_sel_idx = sel.get_index(flat_sel_idx);
379516 sel.set_index(idx, original_sel_idx);
379517 }
379518 } else {
379519 sel.Initialize(state.bf_sel);
379520 }
379521
379522 approved_tuple_count = found_count;
379523 return approved_tuple_count;
379524}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ FilterValue()

bool duckdb::BFTableFilter::FilterValue ( const Value & value) const
379526 {
379527 const auto hash = value.Hash();
379528 return filter.LookupOne(hash);
379529}
DUCKDB_API hash_t Hash() const
Hashes the Value.
Definition duckdb.cpp:133306

◆ CheckStatistics()

FilterPropagateResult duckdb::BFTableFilter::CheckStatistics ( BaseStatistics & stats) const
overridevirtual

Returns true if the statistics indicate that the segment can contain values that satisfy that filter.

Implements duckdb::TableFilter.

379564 {
379565 switch (stats.GetType().InternalType()) {
379566 case PhysicalType::UINT8:
379567 return TemplatedCheckStatistics<uint8_t>(filter, stats);
379569 return TemplatedCheckStatistics<uint16_t>(filter, stats);
379571 return TemplatedCheckStatistics<uint32_t>(filter, stats);
379573 return TemplatedCheckStatistics<uint64_t>(filter, stats);
379574 case PhysicalType::UINT128:
379575 return TemplatedCheckStatistics<uhugeint_t>(filter, stats);
379576 case PhysicalType::INT8:
379577 return TemplatedCheckStatistics<int8_t>(filter, stats);
379578 case PhysicalType::INT16:
379579 return TemplatedCheckStatistics<int16_t>(filter, stats);
379580 case PhysicalType::INT32:
379581 return TemplatedCheckStatistics<int32_t>(filter, stats);
379582 case PhysicalType::INT64:
379583 return TemplatedCheckStatistics<int64_t>(filter, stats);
379584 case PhysicalType::INT128:
379585 return TemplatedCheckStatistics<hugeint_t>(filter, stats);
379586 default:
379587 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
379588 }
379589}
@ UINT32
Unsigned 32-bit little-endian integer.
Definition duckdb.hpp:2758
@ UINT16
Unsigned 16-bit little-endian integer.
Definition duckdb.hpp:2752
@ INT64
Signed 64-bit little-endian integer.
Definition duckdb.hpp:2767
@ INT16
Signed 16-bit little-endian integer.
Definition duckdb.hpp:2755
@ INT32
Signed 32-bit little-endian integer.
Definition duckdb.hpp:2761
@ UINT64
Unsigned 64-bit little-endian integer.
Definition duckdb.hpp:2764
@ UINT8
Unsigned 8-bit little-endian integer.
Definition duckdb.hpp:2746
@ INT8
Signed 8-bit little-endian integer.
Definition duckdb.hpp:2749

◆ HashInternal()

void duckdb::BFTableFilter::HashInternal ( Vector & keys_v,
const SelectionVector & sel,
const idx_t approved_count,
BFTableFilterState & state )
staticprivate
379478 {
379479 if (sel.IsSet()) {
379480 state.keys_sliced_v.Slice(keys_v, sel, approved_count);
379481 VectorOperations::Hash(state.keys_sliced_v, state.hashes_v, approved_count);
379482 } else {
379483 VectorOperations::Hash(keys_v, state.hashes_v, approved_count);
379484 }
379485}

◆ Equals()

bool duckdb::BFTableFilter::Equals ( const TableFilter & other) const
overrideprivatevirtual

Reimplemented from duckdb::TableFilter.

379591 {
379592 if (!TableFilter::Equals(other)) {
379593 return false;
379594 }
379595 return false;
379596}

◆ Copy()

unique_ptr< TableFilter > duckdb::BFTableFilter::Copy ( ) const
overrideprivatevirtual

Implements duckdb::TableFilter.

379597 {
379598 return make_uniq<BFTableFilter>(this->filter, this->filters_null_values, this->key_column_name, this->key_type);
379599}

◆ ToExpression()

unique_ptr< Expression > duckdb::BFTableFilter::ToExpression ( const Expression & column) const
overrideprivatevirtual

Implements duckdb::TableFilter.

379601 {
379602 auto bound_constant = make_uniq<BoundConstantExpression>(Value(true));
379603 return std::move(bound_constant);
379604}

◆ Serialize()

void duckdb::BFTableFilter::Serialize ( Serializer & serializer) const
overrideprivatevirtual

Reimplemented from duckdb::TableFilter.

379606 {
379607 TableFilter::Serialize(serializer);
379608 serializer.WriteProperty<bool>(200, "filters_null_values", filters_null_values);
379609 serializer.WriteProperty<string>(201, "key_column_name", key_column_name);
379610 serializer.WriteProperty<LogicalType>(202, "key_type", key_type);
379611}

◆ Deserialize()

unique_ptr< TableFilter > duckdb::BFTableFilter::Deserialize ( Deserializer & deserializer)
staticprivate
379613 {
379614 auto filters_null_values = deserializer.ReadProperty<bool>(200, "filters_null_values");
379615 auto key_column_name = deserializer.ReadProperty<string>(201, "key_column_name");
379616 auto key_type = deserializer.ReadProperty<LogicalType>(202, "key_type");
379617
379618 BloomFilter filter;
379619 auto result = make_uniq<BFTableFilter>(filter, filters_null_values, key_column_name, key_type);
379620 return std::move(result);
379621}

The documentation for this class was generated from the following file: