2021-06-03 02:20:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <common/types.h>
|
|
|
|
#include <Poco/Util/Application.h>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ISynonymsExtension
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using Synset = std::vector<String>;
|
2021-06-19 18:52:09 +00:00
|
|
|
|
2021-06-03 19:28:12 +00:00
|
|
|
virtual const Synset * getSynonyms(const std::string_view & token) const = 0;
|
2021-06-03 02:20:42 +00:00
|
|
|
|
|
|
|
virtual ~ISynonymsExtension() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SynonymsExtensions
|
|
|
|
{
|
2021-06-19 18:52:09 +00:00
|
|
|
public:
|
2021-06-03 02:20:42 +00:00
|
|
|
using ExtPtr = std::shared_ptr<ISynonymsExtension>;
|
2021-06-19 18:52:09 +00:00
|
|
|
|
2021-06-03 02:20:42 +00:00
|
|
|
SynonymsExtensions(const Poco::Util::AbstractConfiguration & config);
|
|
|
|
|
|
|
|
ExtPtr getExtension(const String & name);
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Info
|
|
|
|
{
|
|
|
|
String path;
|
|
|
|
String type;
|
|
|
|
};
|
2021-06-19 18:52:09 +00:00
|
|
|
|
2021-06-03 02:20:42 +00:00
|
|
|
using ExtContainer = std::unordered_map<String, ExtPtr>;
|
|
|
|
using InfoContainer = std::unordered_map<String, Info>;
|
|
|
|
|
|
|
|
std::mutex mutex;
|
2021-06-19 18:52:09 +00:00
|
|
|
ExtContainer extensions;
|
2021-06-03 02:20:42 +00:00
|
|
|
InfoContainer info;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|