2021-03-06 18:21:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-08-03 11:19:13 +00:00
|
|
|
#include "ExternalDictionaryLibraryHandler.h"
|
2022-06-14 22:35:55 +00:00
|
|
|
#include <base/defines.h>
|
|
|
|
|
2021-03-06 18:21:40 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-03-22 15:58:20 +00:00
|
|
|
/// Each library dictionary source has unique UUID. When clone() method is called, a new UUID is generated.
|
2022-08-03 11:19:13 +00:00
|
|
|
/// There is a unique mapping from dictionary UUID to sharedLibraryHandler.
|
|
|
|
class ExternalDictionaryLibraryHandlerFactory final : private boost::noncopyable
|
2021-03-06 18:21:40 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-08-03 11:19:13 +00:00
|
|
|
static ExternalDictionaryLibraryHandlerFactory & instance();
|
2021-03-06 18:21:40 +00:00
|
|
|
|
|
|
|
SharedLibraryHandlerPtr get(const std::string & dictionary_id);
|
|
|
|
|
2021-03-24 08:41:42 +00:00
|
|
|
void create(
|
|
|
|
const std::string & dictionary_id,
|
|
|
|
const std::string & library_path,
|
|
|
|
const std::vector<std::string> & library_settings,
|
2021-03-24 09:23:29 +00:00
|
|
|
const Block & sample_block,
|
2021-03-24 19:32:31 +00:00
|
|
|
const std::vector<std::string> & attributes_names);
|
2021-03-06 18:21:40 +00:00
|
|
|
|
2021-07-30 14:20:57 +00:00
|
|
|
bool clone(const std::string & from_dictionary_id, const std::string & to_dictionary_id);
|
2021-03-06 18:21:40 +00:00
|
|
|
|
2021-07-30 14:20:57 +00:00
|
|
|
bool remove(const std::string & dictionary_id);
|
2021-03-06 18:21:40 +00:00
|
|
|
|
|
|
|
private:
|
2021-03-22 15:58:20 +00:00
|
|
|
/// map: dict_id -> sharedLibraryHandler
|
2022-06-14 22:35:55 +00:00
|
|
|
std::unordered_map<std::string, SharedLibraryHandlerPtr> library_handlers TSA_GUARDED_BY(mutex);
|
2021-03-06 18:21:40 +00:00
|
|
|
std::mutex mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|