2016-04-10 04:00:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Dictionaries/IDictionarySource.h>
|
|
|
|
#include <DB/Dictionaries/ExternalQueryBuilder.h>
|
2016-12-08 02:49:04 +00:00
|
|
|
#include <DB/Dictionaries/DictionaryStructure.h>
|
2016-08-25 21:55:02 +00:00
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
|
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
namespace Data
|
|
|
|
{
|
|
|
|
class SessionPool;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
|
|
|
}
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/// Allows loading dictionaries from a ODBC source
|
|
|
|
class ODBCDictionarySource final : public IDictionarySource
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|