ClickHouse/dbms/include/DB/Dictionaries/MySQLBlockInputStream.h

42 lines
1022 B
C++
Raw Normal View History

#pragma once
#include <DB/Core/Block.h>
#include <DB/DataStreams/IProfilingBlockInputStream.h>
2016-04-10 02:32:59 +00:00
#include <DB/Dictionaries/ExternalResultDescription.h>
#include <mysqlxx/Query.h>
2015-04-16 06:12:35 +00:00
#include <mysqlxx/PoolWithFailover.h>
#include <string>
2016-12-08 02:49:04 +00:00
namespace DB
2016-01-12 02:21:15 +00:00
{
/// Allows processing results of a MySQL query as a sequence of Blocks, simplifies chaining
class MySQLBlockInputStream final : public IProfilingBlockInputStream
{
public:
MySQLBlockInputStream(
2016-04-10 02:29:45 +00:00
const mysqlxx::PoolWithFailover::Entry & entry, const std::string & query_str, const Block & sample_block,
2016-12-08 02:49:04 +00:00
const size_t max_block_size);
String getName() const override { return "MySQL"; }
2016-12-08 02:49:04 +00:00
String getID() const override;
private:
2016-12-08 02:49:04 +00:00
Block readImpl() override;
static void insertDefaultValue(IColumn * const column, const IColumn & sample_column)
{
column->insertFrom(sample_column, 0);
}
mysqlxx::PoolWithFailover::Entry entry;
mysqlxx::Query query;
mysqlxx::UseQueryResult result;
2016-12-08 02:49:04 +00:00
const size_t max_block_size;
2016-04-10 02:32:59 +00:00
ExternalResultDescription description;
};
}