2016-04-10 04:00:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Dictionaries/IDictionarySource.h>
|
|
|
|
#include <DB/Dictionaries/ODBCBlockInputStream.h>
|
|
|
|
#include <DB/Dictionaries/ExternalQueryBuilder.h>
|
|
|
|
#include <ext/range.hpp>
|
|
|
|
#include <mysqlxx/Pool.h>
|
2016-08-25 21:55:02 +00:00
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
#include <Poco/Util/AbstractConfiguration.h>
|
|
|
|
#include <Poco/Data/SessionPool.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/// Allows loading dictionaries from a ODBC source
|
|
|
|
class ODBCDictionarySource final : public IDictionarySource
|
|
|
|
{
|
2016-05-29 00:07:29 +00:00
|
|
|
static constexpr auto max_block_size = 8192;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
ODBCDictionarySource(const DictionaryStructure & dict_struct_,
|
|
|
|
const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix,
|
2016-06-05 15:21:35 +00:00
|
|
|
const Block & sample_block);
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
/// copy-constructor is provided in order to support cloneability
|
2016-06-05 15:21:35 +00:00
|
|
|
ODBCDictionarySource(const ODBCDictionarySource & other);
|
|
|
|
|
|
|
|
BlockInputStreamPtr loadAll() override;
|
|
|
|
|
2016-10-26 22:27:38 +00:00
|
|
|
BlockInputStreamPtr loadIds(const std::vector<UInt64> & ids) override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
BlockInputStreamPtr loadKeys(
|
2016-06-05 15:21:35 +00:00
|
|
|
const ConstColumnPlainPtrs & key_columns, const std::vector<std::size_t> & requested_rows) override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2016-06-05 15:21:35 +00:00
|
|
|
bool isModified() const override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2016-06-05 15:21:35 +00:00
|
|
|
bool supportsSelectiveLoad() const override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2016-06-05 15:21:35 +00:00
|
|
|
DictionarySourcePtr clone() const override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
2016-06-05 15:21:35 +00:00
|
|
|
std::string toString() const override;
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Logger * log = &Logger::get("ODBCDictionarySource");
|
|
|
|
|
|
|
|
const DictionaryStructure dict_struct;
|
|
|
|
const std::string db;
|
|
|
|
const std::string table;
|
|
|
|
const std::string where;
|
|
|
|
Block sample_block;
|
|
|
|
std::shared_ptr<Poco::Data::SessionPool> pool;
|
|
|
|
ExternalQueryBuilder query_builder;
|
|
|
|
const std::string load_all_query;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|