2016-11-15 19:51:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-11-28 11:37:12 +00:00
|
|
|
#include "DictionaryStructure.h"
|
2018-12-10 15:25:45 +00:00
|
|
|
#include "IDictionarySource.h"
|
2019-05-17 14:34:25 +00:00
|
|
|
#include <Core/Block.h>
|
2020-04-03 21:32:06 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2017-01-21 04:24:28 +00:00
|
|
|
|
2019-05-17 14:34:25 +00:00
|
|
|
namespace Poco { class Logger; }
|
2017-01-21 04:24:28 +00:00
|
|
|
|
|
|
|
|
2016-11-15 19:51:06 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2019-03-01 16:38:52 +00:00
|
|
|
|
2016-11-15 19:51:06 +00:00
|
|
|
/// Allows loading dictionaries from executable
|
|
|
|
class ExecutableDictionarySource final : public IDictionarySource
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
ExecutableDictionarySource(
|
|
|
|
const DictionaryStructure & dict_struct_,
|
|
|
|
const Poco::Util::AbstractConfiguration & config,
|
|
|
|
const std::string & config_prefix,
|
2019-08-03 11:02:40 +00:00
|
|
|
Block & sample_block_,
|
|
|
|
const Context & context_);
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ExecutableDictionarySource(const ExecutableDictionarySource & other);
|
2019-07-08 00:51:43 +00:00
|
|
|
ExecutableDictionarySource & operator=(const ExecutableDictionarySource &) = delete;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
BlockInputStreamPtr loadAll() override;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2019-03-01 16:38:52 +00:00
|
|
|
/** The logic of this method is flawed, absolutely incorrect and ignorant.
|
|
|
|
* It may lead to skipping some values due to clock sync or timezone changes.
|
|
|
|
* The intended usage of "update_field" is totally different.
|
|
|
|
*/
|
2018-02-15 13:08:23 +00:00
|
|
|
BlockInputStreamPtr loadUpdatedAll() override;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
BlockInputStreamPtr loadIds(const std::vector<UInt64> & ids) override;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
BlockInputStreamPtr loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) override;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
bool isModified() const override;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
bool supportsSelectiveLoad() const override;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2018-01-15 12:44:39 +00:00
|
|
|
bool hasUpdateField() const override;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
DictionarySourcePtr clone() const override;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
std::string toString() const override;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
Poco::Logger * log;
|
2019-03-01 16:38:52 +00:00
|
|
|
time_t update_time = 0;
|
2017-04-01 07:20:54 +00:00
|
|
|
const DictionaryStructure dict_struct;
|
2021-01-26 20:49:52 +00:00
|
|
|
bool implicit_key;
|
2017-04-01 07:20:54 +00:00
|
|
|
const std::string command;
|
2018-01-15 12:44:39 +00:00
|
|
|
const std::string update_field;
|
2017-04-01 07:20:54 +00:00
|
|
|
const std::string format;
|
|
|
|
Block sample_block;
|
2020-04-03 21:32:06 +00:00
|
|
|
Context context;
|
2016-11-15 19:51:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|