5#include <userver/storages/mysql/statement_result_set.hpp>
16class CursorResultSet final {
18 explicit CursorResultSet(StatementResultSet&& result_set);
21 CursorResultSet(
const CursorResultSet& other) =
delete;
22 CursorResultSet(CursorResultSet&& other)
noexcept;
30 template <
typename RowCallback>
31 void ForEach(RowCallback&& row_callback, engine::Deadline deadline) &&;
34 StatementResultSet result_set_;
38CursorResultSet<T>::CursorResultSet(StatementResultSet&& result_set)
39 : result_set_{std::move(result_set)} {}
42CursorResultSet<T>::~CursorResultSet() =
default;
45CursorResultSet<T>::CursorResultSet(CursorResultSet<T>&& other)
noexcept =
49template <
typename RowCallback>
51 RowCallback&& row_callback,
54 using IntermediateStorage = std::vector<T>;
56 bool keep_going =
true;
57 auto extractor = impl::io::TypedExtractor<IntermediateStorage, T, RowTag>{};
61 keep_going = result_set_.FetchResult(extractor);
63 fetch
.Reset(impl::tracing::kForEachScope);
64 IntermediateStorage data{extractor.ExtractData()};
65 for (
auto&& row : data) {
66 row_callback(std::move(row));