blob: 8ca2e172aa6f593ad02484b3a65051043e586c25 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#pragma once
#include <IO/ConnectionTimeouts.h>
#include <Poco/Data/SessionPool.h>
#include <Poco/URI.h>
#include <BridgeHelper/XDBCBridgeHelper.h>
#include "DictionaryStructure.h"
#include "ExternalQueryBuilder.h"
#include "IDictionarySource.h"
namespace Poco
{
namespace Util
{
class AbstractConfiguration;
}
class Logger;
}
namespace DB
{
/// Allows loading dictionaries from a XDBC source via bridges
class XDBCDictionarySource final : public IDictionarySource, WithContext
{
public:
struct Configuration
{
const std::string db;
const std::string schema;
const std::string table;
const std::string query;
const std::string where;
const std::string invalidate_query;
const std::string update_field;
const UInt64 update_lag;
};
XDBCDictionarySource(
const DictionaryStructure & dict_struct_,
const Configuration & configuration_,
const Block & sample_block_,
ContextPtr context_,
BridgeHelperPtr bridge);
/// copy-constructor is provided in order to support cloneability
XDBCDictionarySource(const XDBCDictionarySource & other);
XDBCDictionarySource & operator=(const XDBCDictionarySource &) = delete;
QueryPipeline loadAll() override;
QueryPipeline loadUpdatedAll() override;
QueryPipeline loadIds(const std::vector<UInt64> & ids) override;
QueryPipeline loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) override;
bool isModified() const override;
bool supportsSelectiveLoad() const override;
bool hasUpdateField() const override;
DictionarySourcePtr clone() const override;
std::string toString() const override;
private:
std::string getUpdateFieldAndDate();
// execute invalidate_query. expects single cell in result
std::string doInvalidateQuery(const std::string & request) const;
QueryPipeline loadFromQuery(const Poco::URI & url, const Block & required_sample_block, const std::string & query) const;
Poco::Logger * log;
std::chrono::time_point<std::chrono::system_clock> update_time;
const DictionaryStructure dict_struct;
const Configuration configuration;
Block sample_block;
ExternalQueryBuilder query_builder;
const std::string load_all_query;
mutable std::string invalidate_query_response;
BridgeHelperPtr bridge_helper;
Poco::URI bridge_url;
ConnectionTimeouts timeouts;
Poco::Net::HTTPBasicCredentials credentials{};
};
}
|