ClickHouse/src/Dictionaries/HTTPDictionarySource.h

78 lines
2.0 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:
HTTPDictionarySource(
const DictionaryStructure & dict_struct_,
const Poco::Util::AbstractConfiguration & config,
const std::string & config_prefix,
2019-08-03 11:02:40 +00:00
Block & sample_block_,
ContextPtr context_,
bool check_config);
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
BlockInputStreamPtr loadAll() override;
2016-11-15 19:51:06 +00:00
BlockInputStreamPtr loadUpdatedAll() override;
BlockInputStreamPtr loadIds(const std::vector<UInt64> & ids) override;
2016-11-15 19:51:06 +00:00
BlockInputStreamPtr 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;
2016-11-15 19:51:06 +00:00
bool supportsSelectiveLoad() const override;
2016-11-15 19:51:06 +00:00
bool hasUpdateField() const override;
DictionarySourcePtr clone() const override;
2016-11-15 19:51:06 +00:00
std::string toString() const override;
2016-11-15 19:51:06 +00:00
private:
void getUpdateFieldAndDate(Poco::URI & uri);
// wrap buffer using encoding from made request
BlockInputStreamPtr createWrappedBuffer(std::unique_ptr<ReadWriteBufferFromHTTP> http_buffer);
Poco::Logger * log;
2016-11-15 19:51:06 +00:00
LocalDateTime getLastModification() const;
2016-11-15 19:51:06 +00:00
std::chrono::time_point<std::chrono::system_clock> update_time;
const DictionaryStructure dict_struct;
const std::string url;
2019-09-25 04:33:54 +00:00
Poco::Net::HTTPBasicCredentials credentials;
2019-09-26 03:34:22 +00:00
ReadWriteBufferFromHTTP::HTTPHeaderEntries header_entries;
std::string update_field;
const std::string format;
Block sample_block;
ContextPtr context;
ConnectionTimeouts timeouts;
2016-11-15 19:51:06 +00:00
};
}
2021-05-09 11:27:11 +00:00