2021-03-05 09:38:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Common/SharedLibrary.h>
|
2022-04-27 15:05:45 +00:00
|
|
|
#include <Common/logger_useful.h>
|
2022-08-03 11:19:13 +00:00
|
|
|
#include "ExternalDictionaryLibraryUtils.h"
|
2021-03-05 09:38:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-03-22 14:39:17 +00:00
|
|
|
/// A class that manages all operations with library dictionary.
|
|
|
|
/// Every library dictionary source has its own object of this class, accessed by UUID.
|
2022-08-03 11:19:13 +00:00
|
|
|
class ExternalDictionaryLibraryHandler
|
2021-03-05 09:38:00 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2022-08-03 11:19:13 +00:00
|
|
|
ExternalDictionaryLibraryHandler(
|
2021-03-24 09:23:29 +00:00
|
|
|
const std::string & library_path_,
|
|
|
|
const std::vector<std::string> & library_settings,
|
2021-03-24 19:32:31 +00:00
|
|
|
const Block & sample_block_,
|
|
|
|
const std::vector<std::string> & attributes_names_);
|
2021-03-05 09:38:00 +00:00
|
|
|
|
2022-08-03 11:19:13 +00:00
|
|
|
ExternalDictionaryLibraryHandler(const ExternalDictionaryLibraryHandler & other);
|
2021-03-05 09:38:00 +00:00
|
|
|
|
2022-08-03 11:19:13 +00:00
|
|
|
ExternalDictionaryLibraryHandler & operator=(const ExternalDictionaryLibraryHandler & other) = delete;
|
2021-05-08 15:20:40 +00:00
|
|
|
|
2022-08-03 11:19:13 +00:00
|
|
|
~ExternalDictionaryLibraryHandler();
|
2021-03-05 09:38:00 +00:00
|
|
|
|
2021-10-11 16:11:50 +00:00
|
|
|
Block loadAll();
|
2021-03-05 09:38:00 +00:00
|
|
|
|
2021-10-11 16:11:50 +00:00
|
|
|
Block loadIds(const std::vector<uint64_t> & ids);
|
2021-03-05 09:38:00 +00:00
|
|
|
|
2021-10-11 16:11:50 +00:00
|
|
|
Block loadKeys(const Columns & key_columns);
|
2021-03-07 15:23:20 +00:00
|
|
|
|
2021-03-05 10:43:47 +00:00
|
|
|
bool isModified();
|
|
|
|
|
|
|
|
bool supportsSelectiveLoad();
|
|
|
|
|
2021-03-24 08:41:42 +00:00
|
|
|
const Block & getSampleBlock() { return sample_block; }
|
|
|
|
|
2021-03-05 09:38:00 +00:00
|
|
|
private:
|
2022-08-03 11:19:13 +00:00
|
|
|
Block dataToBlock(ExternalDictionaryLibraryAPI::RawClickHouseLibraryTable data);
|
2021-03-05 09:38:00 +00:00
|
|
|
|
|
|
|
std::string library_path;
|
2021-03-24 08:41:42 +00:00
|
|
|
const Block sample_block;
|
2021-03-24 09:23:29 +00:00
|
|
|
std::vector<std::string> attributes_names;
|
|
|
|
|
|
|
|
SharedLibraryPtr library;
|
2021-03-05 09:38:00 +00:00
|
|
|
std::shared_ptr<CStringsHolder> settings_holder;
|
|
|
|
void * lib_data;
|
|
|
|
};
|
|
|
|
|
2022-08-31 18:54:43 +00:00
|
|
|
using SharedLibraryHandlerPtr = std::shared_ptr<ExternalDictionaryLibraryHandler>;
|
2021-03-05 09:38:00 +00:00
|
|
|
|
|
|
|
}
|