2016-11-15 19:51:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <IO/ConnectionTimeouts.h>
|
2018-05-16 13:22:27 +00:00
|
|
|
#include <Poco/URI.h>
|
2017-12-09 06:32:22 +00:00
|
|
|
#include <common/LocalDateTime.h>
|
2018-12-10 15:25:45 +00:00
|
|
|
#include "DictionaryStructure.h"
|
|
|
|
#include "IDictionarySource.h"
|
2017-01-21 04:24:28 +00:00
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
class Logger;
|
|
|
|
}
|
2017-01-21 04:24:28 +00:00
|
|
|
|
|
|
|
|
2016-11-15 19:51:06 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2017-09-05 01:08:26 +00:00
|
|
|
/// Allows loading dictionaries from http[s] source
|
2016-11-15 19:51:06 +00:00
|
|
|
class HTTPDictionarySource final : public IDictionarySource
|
|
|
|
{
|
|
|
|
public:
|
2018-12-10 15:25:45 +00:00
|
|
|
HTTPDictionarySource(
|
|
|
|
const DictionaryStructure & dict_struct_,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Poco::Util::AbstractConfiguration & config,
|
|
|
|
const std::string & config_prefix,
|
|
|
|
Block & sample_block,
|
|
|
|
const Context & context);
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
HTTPDictionarySource(const HTTPDictionarySource & other);
|
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
|
|
|
|
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:
|
2018-05-16 13:22:27 +00:00
|
|
|
void getUpdateFieldAndDate(Poco::URI & uri);
|
2018-02-15 13:08:23 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Poco::Logger * log;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
LocalDateTime getLastModification() const;
|
2016-11-15 19:51:06 +00:00
|
|
|
|
2018-01-15 12:44:39 +00:00
|
|
|
std::chrono::time_point<std::chrono::system_clock> update_time;
|
2017-04-01 07:20:54 +00:00
|
|
|
const DictionaryStructure dict_struct;
|
|
|
|
const std::string url;
|
2018-02-15 13:08:23 +00:00
|
|
|
std::string update_field;
|
2017-04-01 07:20:54 +00:00
|
|
|
const std::string format;
|
|
|
|
Block sample_block;
|
|
|
|
const Context & context;
|
2017-12-27 17:58:52 +00:00
|
|
|
ConnectionTimeouts timeouts;
|
2016-11-15 19:51:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|