Files
scylladb/cql3/selection/scalar_function_selector.hh
Avi Kivity fcb8d040e8 treewide: use Software Package Data Exchange (SPDX) license identifiers
Instead of lengthy blurbs, switch to single-line, machine-readable
standardized (https://spdx.dev) license identifiers. The Linux kernel
switched long ago, so there is strong precedent.

Three cases are handled: AGPL-only, Apache-only, and dual licensed.
For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0),
reasoning that our changes are extensive enough to apply our license.

The changes we applied mechanically with a script, except to
licenses/README.md.

Closes #9937
2022-01-18 12:15:18 +01:00

64 lines
1.7 KiB
C++

/*
*/
/*
* Modified by ScyllaDB
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
*/
#pragma once
#include "abstract_function_selector.hh"
#include "cql3/functions/scalar_function.hh"
#include "cql_serialization_format.hh"
namespace cql3 {
namespace selection {
class scalar_function_selector : public abstract_function_selector_for<functions::scalar_function> {
public:
virtual bool is_aggregate() const override {
// We cannot just return true as it is possible to have a scalar function wrapping an aggregation function
if (_arg_selectors.empty()) {
return false;
}
return _arg_selectors[0]->is_aggregate();
}
virtual void add_input(cql_serialization_format sf, result_set_builder& rs) override {
size_t m = _arg_selectors.size();
for (size_t i = 0; i < m; ++i) {
auto&& s = _arg_selectors[i];
s->add_input(sf, rs);
}
}
virtual void reset() override {
}
virtual bytes_opt get_output(cql_serialization_format sf) override {
size_t m = _arg_selectors.size();
for (size_t i = 0; i < m; ++i) {
auto&& s = _arg_selectors[i];
_args[i] = s->get_output(sf);
s->reset();
}
return fun()->execute(sf, _args);
}
virtual bool requires_thread() const override;
scalar_function_selector(shared_ptr<functions::function> fun, std::vector<shared_ptr<selector>> arg_selectors)
: abstract_function_selector_for<functions::scalar_function>(
dynamic_pointer_cast<functions::scalar_function>(std::move(fun)), std::move(arg_selectors)) {
}
};
}
}