mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
dbms: Server: queries with several replicas: development [#METR-14410]
This commit is contained in:
parent
63b254555a
commit
74db087fa6
@ -44,6 +44,10 @@ namespace DB
|
||||
|
||||
std::string dumpAddresses() const;
|
||||
|
||||
size_t size() const;
|
||||
|
||||
void sendExternalTablesData(std::vector<ExternalTablesData> & data);
|
||||
|
||||
private:
|
||||
using ConnectionHash = std::unordered_map<int, ConnectionInfo>;
|
||||
|
||||
|
@ -273,6 +273,7 @@ namespace ErrorCodes
|
||||
CANNOT_COMPILE_CODE,
|
||||
NO_AVAILABLE_REPLICA,
|
||||
UNEXPECTED_REPLICA,
|
||||
MISMATCH_REPLICAS_DATA_SOURCES,
|
||||
|
||||
POCO_EXCEPTION = 1000,
|
||||
STD_EXCEPTION,
|
||||
|
@ -122,7 +122,7 @@ protected:
|
||||
/// Отправить на удаленные сервера все временные таблицы
|
||||
void sendExternalTables()
|
||||
{
|
||||
size_t count = use_many_replicas ? shard_replicas->size() : 1;
|
||||
size_t count = use_many_replicas ? replicas_connections->size() : 1;
|
||||
|
||||
std::vector<ExternalTablesData> instances;
|
||||
instances.reserve(count);
|
||||
@ -145,12 +145,9 @@ protected:
|
||||
}
|
||||
|
||||
if (use_many_replicas)
|
||||
{
|
||||
/// XXX Отправить res по всем соединениям.
|
||||
//replicas_connections->sendExternalTablesData(res);
|
||||
}
|
||||
replicas_connections->sendExternalTablesData(instances);
|
||||
else
|
||||
connection->sendExternalTablesData(res);
|
||||
connection->sendExternalTablesData(instances[0]);
|
||||
}
|
||||
|
||||
Block readImpl() override
|
||||
|
@ -236,4 +236,23 @@ namespace DB
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
size_t ReplicasConnections::size() const
|
||||
{
|
||||
return connection_hash.size();
|
||||
}
|
||||
|
||||
void ReplicasConnections::sendExternalTablesData(std::vector<ExternalTablesData> & data)
|
||||
{
|
||||
if (data.size() != connection_hash.size())
|
||||
throw Exception("Mismatch between replicas and data sources", ErrorCodes::MISMATCH_REPLICAS_DATA_SOURCES);
|
||||
|
||||
auto it = data.begin();
|
||||
for (auto & e : connection_hash)
|
||||
{
|
||||
Connection * connection = e.second.connection;
|
||||
connection->sendExternalTablesData(*it);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user