userver: storages::clickhouse::ExecutionResult Class Reference
Loading...
Searching...
No Matches
storages::clickhouse::ExecutionResult Class Referencefinal

#include <userver/storages/clickhouse/execution_result.hpp>

Detailed Description

Thin wrapper over underlying block of data, returned by storages::clickhouse::Cluster Execute methods

Usage example:

namespace {
struct Data final {
std::vector<uint64_t> numbers;
std::vector<std::string> strings;
std::vector<uint64_t> other_numbers;
std::vector<std::chrono::system_clock::time_point> tps;
};
struct RowData final {
uint64_t number;
std::string string;
uint64_t other_number;
std::chrono::system_clock::time_point tp;
};
} // namespace
template <>
struct CppToClickhouse<Data> final {
using mapped_type =
std::tuple<columns::UInt64Column, columns::StringColumn, columns::UInt64Column, columns::DateTime64ColumnNano>;
};
template <>
struct CppToClickhouse<RowData> final {
using mapped_type =
std::tuple<columns::UInt64Column, columns::StringColumn, columns::UInt64Column, columns::DateTime64ColumnNano>;
};
} // namespace storages::clickhouse::io
const Data as_columns{cluster->Execute(common_query).As<Data>()};
const std::vector<RowData> as_rows{cluster->Execute(common_query).AsContainer<std::vector<RowData>>()};
const auto as_rows_iterable{cluster->Execute(common_query).AsRows<RowData>()};

Definition at line 32 of file execution_result.hpp.

Public Member Functions

 ExecutionResult (impl::BlockWrapperPtr)
 
 ExecutionResult (ExecutionResult &&) noexcept
 
size_t GetColumnsCount () const
 Returns number of columns in underlying block.
 
size_t GetRowsCount () const
 Returns number of rows in underlying block columns.
 
template<typename T >
As () &&
 
template<typename T >
auto AsRows () &&
 
template<typename Container >
Container AsContainer () &&
 

Member Function Documentation

◆ As()

template<typename T >
T storages::clickhouse::ExecutionResult::As ( ) &&

Converts underlying block to strongly-typed struct of vectors. See clickhouse_io for better understanding of T's requirements.

Definition at line 65 of file execution_result.hpp.

◆ AsContainer()

template<typename Container >
Container storages::clickhouse::ExecutionResult::AsContainer ( ) &&

Converts underlying block to strongly-typed container. See clickhouse_io for better understanding of Container::value_type's requirements.

Definition at line 89 of file execution_result.hpp.

◆ AsRows()

template<typename T >
auto storages::clickhouse::ExecutionResult::AsRows ( ) &&

Converts underlying block to iterable of strongly-typed struct. See clickhouse_io for better understanding of T's requirements.

Definition at line 80 of file execution_result.hpp.


The documentation for this class was generated from the following file: