Files
scylladb/db/functions/stateless_aggregate_function.hh
Avi Kivity 58eb21aa5d db: functions: fold stateless_aggregate_function_adapter into aggregate_function
Now that all aggregate functions are derived from
stateless_aggregate_function_adapter, we can just fold its functionality
into the base class. This exposes stateless_aggregate_function to
all users of aggregate_function, so they can begin to benefit from
the transformation, though this patch doesn't touch those users.

The aggregate_function base class is partiallly devirtualized since
there is just a single implementation now.
2023-03-28 23:47:11 +03:00

36 lines
1010 B
C++

// Copyright (C) 2023-present ScyllaDB
// SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
#pragma once
#include "scalar_function.hh"
#include "function_name.hh"
#include <optional>
namespace db::functions {
struct stateless_aggregate_function final {
function_name name;
std::optional<sstring> column_name_override; // if unset, column name is synthesized from name and argument names
data_type state_type;
data_type result_type;
std::vector<data_type> argument_types;
bytes_opt initial_state;
// aggregates another input
// signature: (state_type, argument_types...) -> state_type
shared_ptr<scalar_function> aggregation_function;
// converts the state type to a result
// signature: (state_type) -> result_type
shared_ptr<scalar_function> state_to_result_function;
// optional: reduces states computed in parallel
// signature: (state_type, state_type) -> state_type
shared_ptr<scalar_function> state_reduction_function;
};
}