ClickHouse/src/Dictionaries/HTTPDictionarySource.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.1 KiB
C++
Raw Normal View History

2016-11-15 19:51:06 +00:00
#pragma once
#include <IO/ConnectionTimeouts.h>
#include <IO/ReadWriteBufferFromHTTP.h>
2019-09-25 04:33:54 +00:00
#include <Poco/Net/HTTPBasicCredentials.h>
#include <Poco/URI.h>
#include <Common/LocalDateTime.h>
#include "DictionaryStructure.h"
#include "IDictionarySource.h"
2021-05-09 11:27:11 +00:00
#include <Interpreters/Context.h>
#include <IO/CompressionMethod.h>
namespace Poco
{
class Logger;
}
2016-11-15 19:51:06 +00:00
namespace DB
{
/// Allows loading dictionaries from http[s] source
2016-11-15 19:51:06 +00:00
class HTTPDictionarySource final : public IDictionarySource
{
public:
struct Configuration
{
const std::string url;
const std::string format;
const std::string update_field;
const UInt64 update_lag;
const HTTPHeaderEntries header_entries;
};
HTTPDictionarySource(
const DictionaryStructure & dict_struct_,
const Configuration & configuration,
const Poco::Net::HTTPBasicCredentials & credentials_,
2019-08-03 11:02:40 +00:00
Block & sample_block_,
2022-07-13 15:33:18 +00:00
ContextPtr context_);
2016-11-15 19:51:06 +00:00
HTTPDictionarySource(const HTTPDictionarySource & other);
2019-07-08 00:51:43 +00:00
HTTPDictionarySource & operator=(const HTTPDictionarySource &) = delete;
2016-11-15 19:51:06 +00:00
2022-05-20 19:49:31 +00:00
QueryPipeline loadAll() override;
2016-11-15 19:51:06 +00:00
2022-05-20 19:49:31 +00:00
QueryPipeline loadUpdatedAll() override;
2022-05-20 19:49:31 +00:00
QueryPipeline loadIds(const std::vector<UInt64> & ids) override;
2016-11-15 19:51:06 +00:00
2022-05-20 19:49:31 +00:00
QueryPipeline loadKeys(const Columns & key_columns, const std::vector<size_t> & requested_rows) override;
2016-11-15 19:51:06 +00:00
bool isModified() const override;
bool supportsSelectiveLoad() const override;
bool hasUpdateField() const override;
2016-11-15 19:51:06 +00:00
DictionarySourcePtr clone() const override;
std::string toString() const override;
private:
void getUpdateFieldAndDate(Poco::URI & uri);
// wrap buffer using encoding from made request
2022-05-20 19:49:31 +00:00
QueryPipeline createWrappedBuffer(std::unique_ptr<ReadWriteBufferFromHTTP> http_buffer);
Poco::Logger * log;
2016-11-15 19:51:06 +00:00
LocalDateTime getLastModification() const;
std::chrono::time_point<std::chrono::system_clock> update_time;
2016-11-18 01:48:13 +00:00
const DictionaryStructure dict_struct;
const Configuration configuration;
2019-09-25 04:33:54 +00:00
Poco::Net::HTTPBasicCredentials credentials;
2016-11-15 19:51:06 +00:00
Block sample_block;
2021-06-01 12:20:52 +00:00
ContextPtr context;
ConnectionTimeouts timeouts;
2016-11-15 19:51:06 +00:00
};
}