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

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

Detailed Description

Interface for executing queries on a cluster of ClickHouse servers.

Usually retrieved from components::ClickHouse component.

Definition at line 36 of file cluster.hpp.

Classes

class  NoAvailablePoolError
 Exception that is thrown if all specified endpoints are unavailable. More...
 

Public Member Functions

 Cluster (clients::dns::Resolver &resolver, const impl::ClickhouseSettings &settings, const components::ComponentConfig &config)
 
 ~Cluster ()
 Cluster destructor.
 
 Cluster (const Cluster &)=delete
 
template<typename... Args>
ExecutionResult Execute (const Query &query, const Args &... args) const
 Execute a statement at some host of the cluster with args as query parameters.
 
template<typename... Args>
ExecutionResult Execute (OptionalCommandControl, const Query &query, const Args &... args) const
 Execute a statement with specified command control settings at some host of the cluster with args as query parameters.
 
template<typename T >
void Insert (const std::string &table_name, const std::vector< std::string_view > &column_names, const T &data) const
 Insert data at some host of the cluster; T is expected to be a struct of vectors of same length.
 
template<typename T >
void Insert (OptionalCommandControl, const std::string &table_name, const std::vector< std::string_view > &column_names, const T &data) const
 Insert data with specified command control settings at some host of the cluster; T is expected to be a struct of vectors of same length.
 
template<typename Container >
void InsertRows (const std::string &table_name, const std::vector< std::string_view > &column_names, const Container &data) const
 Insert data at some host of the cluster; Container is expected to be an iterable of clickhouse-mapped type.
 
template<typename Container >
void InsertRows (OptionalCommandControl, const std::string &table_name, const std::vector< std::string_view > &column_names, const Container &data) const
 Insert data with specified command control settings at some host of the cluster; Container is expected to be an iterable of clickhouse-mapped type.
 
void WriteStatistics (::utils::statistics::Writer &writer) const
 Write cluster statistics.
 

Constructor & Destructor Documentation

◆ Cluster()

storages::clickhouse::Cluster::Cluster ( clients::dns::Resolver & resolver,
const impl::ClickhouseSettings & settings,
const components::ComponentConfig & config )

Cluster constructor

Parameters
resolverasynchronous DNS resolver
settingsstruct with settings fields: endpoints - list of endpoints (host + port) auth_settings - authentication settings (user, password, database)
configcomponents::ClickHouse component config

Member Function Documentation

◆ Execute() [1/2]

template<typename... Args>
ExecutionResult storages::clickhouse::Cluster::Execute ( const Query & query,
const Args &... args ) const

Execute a statement at some host of the cluster with args as query parameters.

Definition at line 187 of file cluster.hpp.

◆ Execute() [2/2]

template<typename... Args>
ExecutionResult storages::clickhouse::Cluster::Execute ( OptionalCommandControl optional_cc,
const Query & query,
const Args &... args ) const

Execute a statement with specified command control settings at some host of the cluster with args as query parameters.

Definition at line 192 of file cluster.hpp.

◆ Insert() [1/2]

template<typename T >
void storages::clickhouse::Cluster::Insert ( const std::string & table_name,
const std::vector< std::string_view > & column_names,
const T & data ) const

Insert data at some host of the cluster; T is expected to be a struct of vectors of same length.

Parameters
table_nametable to insert into
column_namesnames of columns of the table
datadata to insert See clickhouse_io for better understanding of T's requirements.

Definition at line 146 of file cluster.hpp.

◆ Insert() [2/2]

template<typename T >
void storages::clickhouse::Cluster::Insert ( OptionalCommandControl optional_cc,
const std::string & table_name,
const std::vector< std::string_view > & column_names,
const T & data ) const

Insert data with specified command control settings at some host of the cluster; T is expected to be a struct of vectors of same length.

Parameters
table_nametable to insert into
column_namesnames of columns of the table
datadata to insert See clickhouse_io for better understanding of T's requirements.

Definition at line 152 of file cluster.hpp.

◆ InsertRows() [1/2]

template<typename Container >
void storages::clickhouse::Cluster::InsertRows ( const std::string & table_name,
const std::vector< std::string_view > & column_names,
const Container & data ) const

Insert data at some host of the cluster; Container is expected to be an iterable of clickhouse-mapped type.

Parameters
table_nametable to insert into
column_namesnames of columns of the table
datadata to insert See clickhouse_io for better understanding of Container::value_type's requirements.
Note
This version of insert is less performant than Insert (it makes 2 copies of data instead of just 1 copy) due to implementation details, so consider using less convenient but more performant analogue if performance is a concern.

Definition at line 164 of file cluster.hpp.

◆ InsertRows() [2/2]

template<typename Container >
void storages::clickhouse::Cluster::InsertRows ( OptionalCommandControl optional_cc,
const std::string & table_name,
const std::vector< std::string_view > & column_names,
const Container & data ) const

Insert data with specified command control settings at some host of the cluster; Container is expected to be an iterable of clickhouse-mapped type.

Parameters
table_nametable to insert into
column_namesnames of columns of the table
datadata to insert See clickhouse_io for better understanding of Container::value_type's requirements.
Note
This version of insert is less performant than Insert (it makes 2 copies of data instead of just 1 copy) due to implementation details, so consider using less convenient but more performant analogue if performance is a concern.

Definition at line 173 of file cluster.hpp.


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