ClickHouse/programs/library-bridge/SharedLibraryHandlerFactory.h

38 lines
1.0 KiB
C++
Raw Normal View History

2021-03-06 18:21:40 +00:00
#pragma once
#include "SharedLibraryHandler.h"
#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.
/// There is a unique mapping from diciotnary UUID to sharedLibraryHandler.
2021-03-06 18:21:40 +00:00
class SharedLibraryHandlerFactory final : private boost::noncopyable
{
public:
static SharedLibraryHandlerFactory & instance();
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-03-22 15:58:20 +00:00
void clone(const std::string & from_dictionary_id, const std::string & to_dictionary_id);
2021-03-06 18:21:40 +00:00
2021-03-22 15:58:20 +00:00
void 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
2021-03-06 18:21:40 +00:00
std::unordered_map<std::string, SharedLibraryHandlerPtr> library_handlers;
std::mutex mutex;
};
}