Files
scylladb/cql3/functions/user_aggregate.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

46 lines
1.4 KiB
C++

/*
* Copyright (C) 2021-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include "abstract_function.hh"
#include "scalar_function.hh"
#include "aggregate_function.hh"
#include "db/functions/stateless_aggregate_function.hh"
#include "data_dictionary/keyspace_element.hh"
namespace cql3 {
namespace functions {
class user_aggregate : public db::functions::aggregate_function, public data_dictionary::keyspace_element {
public:
user_aggregate(function_name fname, bytes_opt initcond, ::shared_ptr<scalar_function> sfunc, ::shared_ptr<scalar_function> reducefunc, ::shared_ptr<scalar_function> finalfunc);
bool has_finalfunc() const;
virtual sstring keypace_name() const override { return name().keyspace; }
virtual sstring element_name() const override { return name().name; }
virtual sstring element_type() const override { return "aggregate"; }
virtual std::ostream& describe(std::ostream& os) const override;
seastar::shared_ptr<scalar_function> sfunc() const {
return _agg.aggregation_function;
}
seastar::shared_ptr<scalar_function> reducefunc() const {
return _agg.state_reduction_function;
}
seastar::shared_ptr<scalar_function> finalfunc() const {
return _agg.state_to_result_function;
}
const bytes_opt& initcond() const {
return _agg.initial_state;
}
};
}
}