//===----------------------------------------------------------------------===// // DuckDB // // duckdb/execution/perfect_aggregate_hashtable.hpp // // //===----------------------------------------------------------------------===// #pragma once #include "duckdb/execution/base_aggregate_hashtable.hpp" #include "duckdb/storage/arena_allocator.hpp" namespace duckdb { class PerfectAggregateHashTable : public BaseAggregateHashTable { public: PerfectAggregateHashTable(ClientContext &context, Allocator &allocator, const vector &group_types, vector payload_types_p, vector aggregate_objects, vector group_minima, vector required_bits); ~PerfectAggregateHashTable() override; public: //! Add the given data to the HT void AddChunk(DataChunk &groups, DataChunk &payload); //! Combines the target perfect aggregate HT into this one void Combine(PerfectAggregateHashTable &other); //! Scan the HT starting from the scan_position void Scan(idx_t &scan_position, DataChunk &result); protected: Vector addresses; //! The required bits per group vector required_bits; //! The total required bits for the HT (this determines the max capacity) idx_t total_required_bits; //! The total amount of groups idx_t total_groups; //! The tuple size idx_t tuple_size; //! The number of grouping columns idx_t grouping_columns; // The actual pointer to the data data_ptr_t data; //! The owned data of the HT unsafe_unique_array owned_data; //! Information on whether or not a specific group has any entries unsafe_unique_array group_is_set; //! The minimum values for each of the group columns vector group_minima; //! Reused selection vector SelectionVector sel; //! The arena allocator used by the aggregates for their internal state ArenaAllocator aggregate_allocator; private: //! Destroy the perfect aggregate HT (called automatically by the destructor) void Destroy(); }; } // namespace duckdb