1 | #pragma once |
---|---|
2 | |
3 | #include <IO/ConnectionTimeouts.h> |
4 | #include <IO/ReadWriteBufferFromHTTP.h> |
5 | #include <Poco/Net/HTTPBasicCredentials.h> |
6 | #include <Poco/URI.h> |
7 | #include <common/LocalDateTime.h> |
8 | #include "DictionaryStructure.h" |
9 | #include "IDictionarySource.h" |
10 | |
11 | namespace Poco |
12 | { |
13 | class Logger; |
14 | } |
15 | |
16 | |
17 | namespace DB |
18 | { |
19 | /// Allows loading dictionaries from http[s] source |
20 | class HTTPDictionarySource final : public IDictionarySource |
21 | { |
22 | public: |
23 | HTTPDictionarySource( |
24 | const DictionaryStructure & dict_struct_, |
25 | const Poco::Util::AbstractConfiguration & config, |
26 | const std::string & config_prefix, |
27 | Block & sample_block_, |
28 | const Context & context_, |
29 | bool check_config); |
30 | |
31 | HTTPDictionarySource(const HTTPDictionarySource & other); |
32 | HTTPDictionarySource & operator=(const HTTPDictionarySource &) = delete; |
33 | |
34 | BlockInputStreamPtr loadAll() override; |
35 | |
36 | BlockInputStreamPtr loadUpdatedAll() override; |
37 | |
38 | BlockInputStreamPtr loadIds(const std::vector<UInt64> & ids) override; |
39 | |
40 | BlockInputStreamPtr loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) override; |
41 | |
42 | bool isModified() const override; |
43 | |
44 | bool supportsSelectiveLoad() const override; |
45 | |
46 | bool hasUpdateField() const override; |
47 | |
48 | DictionarySourcePtr clone() const override; |
49 | |
50 | std::string toString() const override; |
51 | |
52 | private: |
53 | void getUpdateFieldAndDate(Poco::URI & uri); |
54 | |
55 | Poco::Logger * log; |
56 | |
57 | LocalDateTime getLastModification() const; |
58 | |
59 | std::chrono::time_point<std::chrono::system_clock> update_time; |
60 | const DictionaryStructure dict_struct; |
61 | const std::string url; |
62 | Poco::Net::HTTPBasicCredentials credentials; |
63 | ReadWriteBufferFromHTTP::HTTPHeaderEntries header_entries; |
64 | std::string update_field; |
65 | const std::string format; |
66 | Block sample_block; |
67 | const Context & context; |
68 | ConnectionTimeouts timeouts; |
69 | }; |
70 | |
71 | } |
72 |