1#pragma once
2
3#include "DictionaryStructure.h"
4#include "IDictionarySource.h"
5#include <Core/Block.h>
6
7
8namespace Poco { class Logger; }
9
10
11namespace DB
12{
13
14/// Allows loading dictionaries from executable
15class ExecutableDictionarySource final : public IDictionarySource
16{
17public:
18 ExecutableDictionarySource(
19 const DictionaryStructure & dict_struct_,
20 const Poco::Util::AbstractConfiguration & config,
21 const std::string & config_prefix,
22 Block & sample_block_,
23 const Context & context_);
24
25 ExecutableDictionarySource(const ExecutableDictionarySource & other);
26 ExecutableDictionarySource & operator=(const ExecutableDictionarySource &) = delete;
27
28 BlockInputStreamPtr loadAll() override;
29
30 /** The logic of this method is flawed, absolutely incorrect and ignorant.
31 * It may lead to skipping some values due to clock sync or timezone changes.
32 * The intended usage of "update_field" is totally different.
33 */
34 BlockInputStreamPtr loadUpdatedAll() override;
35
36 BlockInputStreamPtr loadIds(const std::vector<UInt64> & ids) override;
37
38 BlockInputStreamPtr loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) override;
39
40 bool isModified() const override;
41
42 bool supportsSelectiveLoad() const override;
43
44 bool hasUpdateField() const override;
45
46 DictionarySourcePtr clone() const override;
47
48 std::string toString() const override;
49
50private:
51 Poco::Logger * log;
52
53 time_t update_time = 0;
54 const DictionaryStructure dict_struct;
55 const std::string command;
56 const std::string update_field;
57 const std::string format;
58 Block sample_block;
59 const Context & context;
60};
61
62}
63