//===----------------------------------------------------------------------===// // DuckDB // // duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp // // //===----------------------------------------------------------------------===// #pragma once #include "duckdb/execution/physical_operator.hpp" #include "duckdb/execution/base_aggregate_hashtable.hpp" namespace duckdb { class ClientContext; class PerfectAggregateHashTable; //! PhysicalPerfectHashAggregate performs a group-by and aggregation using a perfect hash table class PhysicalPerfectHashAggregate : public PhysicalOperator { public: static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::PERFECT_HASH_GROUP_BY; public: PhysicalPerfectHashAggregate(ClientContext &context, vector types, vector> aggregates, vector> groups, const vector> &group_stats, vector required_bits, idx_t estimated_cardinality); //! The groups vector> groups; //! The aggregates that have to be computed vector> aggregates; public: // Source interface unique_ptr GetGlobalSourceState(ClientContext &context) const override; SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override; bool IsSource() const override { return true; } OrderPreservationType SourceOrder() const override { return OrderPreservationType::NO_ORDER; } public: // Sink interface SinkResultType Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const override; void Combine(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate) const override; unique_ptr GetLocalSinkState(ExecutionContext &context) const override; unique_ptr GetGlobalSinkState(ClientContext &context) const override; string ParamsToString() const override; //! Create a perfect aggregate hash table for this node unique_ptr CreateHT(Allocator &allocator, ClientContext &context) const; bool IsSink() const override { return true; } bool ParallelSink() const override { return true; } bool SinkOrderDependent() const override { return false; } public: //! The group types vector group_types; //! The payload types vector payload_types; //! The aggregates to be computed vector aggregate_objects; //! The minimum value of each of the groups vector group_minima; //! The number of bits we need to completely cover each of the groups vector required_bits; unordered_map filter_indexes; }; } // namespace duckdb