//===----------------------------------------------------------------------===// // DuckDB // // duckdb/planner/table_filter.hpp // // //===----------------------------------------------------------------------===// #pragma once #include "duckdb/common/common.hpp" #include "duckdb/common/types.hpp" #include "duckdb/common/unordered_map.hpp" #include "duckdb/common/enums/filter_propagate_result.hpp" namespace duckdb { class BaseStatistics; class FieldWriter; class FieldReader; enum class TableFilterType : uint8_t { CONSTANT_COMPARISON = 0, // constant comparison (e.g. =C, >C, >=C, Deserialize(Deserializer &source); public: template TARGET &Cast() { if (filter_type != TARGET::TYPE) { throw InternalException("Failed to cast table to type - table filter type mismatch"); } return reinterpret_cast(*this); } template const TARGET &Cast() const { if (filter_type != TARGET::TYPE) { throw InternalException("Failed to cast table to type - table filter type mismatch"); } return reinterpret_cast(*this); } }; class TableFilterSet { public: unordered_map> filters; public: void PushFilter(idx_t table_index, unique_ptr filter); bool Equals(TableFilterSet &other) { if (filters.size() != other.filters.size()) { return false; } for (auto &entry : filters) { auto other_entry = other.filters.find(entry.first); if (other_entry == other.filters.end()) { return false; } if (!entry.second->Equals(*other_entry->second)) { return false; } } return true; } static bool Equals(TableFilterSet *left, TableFilterSet *right) { if (left == right) { return true; } if (!left || !right) { return false; } return left->Equals(*right); } void Serialize(Serializer &serializer) const; static unique_ptr Deserialize(Deserializer &source); }; } // namespace duckdb