9#include <boost/pfr/core.hpp>
11#include <userver/storages/clickhouse/impl/block_wrapper_fwd.hpp>
12#include <userver/storages/clickhouse/io/impl/validate.hpp>
14#include <userver/storages/clickhouse/io/result_mapper.hpp>
16USERVER_NAMESPACE_BEGIN
32class ExecutionResult
final {
34 explicit ExecutionResult(impl::BlockWrapperPtr);
35 ExecutionResult(ExecutionResult&&)
noexcept;
57 template <
typename Container>
61 impl::BlockWrapperPtr block_;
65T ExecutionResult::
As() && {
68 io::impl::ValidateColumnsMapping(result);
69 io::impl::ValidateColumnsCount<T>(GetColumnsCount());
71 using MappedType =
typename io::CppToClickhouse<T>::mapped_type;
72 io::ColumnsMapper<MappedType> mapper{*block_};
74 boost::pfr::for_each_field(result, mapper);
82 io::impl::ValidateRowsMapping<T>();
83 io::impl::ValidateColumnsCount<T>(GetColumnsCount());
85 return io::RowsMapper<T>{std::move(block_)};
88template <
typename Container>
91 using Row =
typename Container::value_type;
94 if constexpr (
io::traits::kIsReservable<Container>) {
95 result.reserve(GetRowsCount());
98 auto rows = std::move(*
this).AsRows<Row>();
99 std::move(rows.begin(), rows.end(), io::traits::Inserter(result));