blob: a123d67088b55265ccb64585c5ed43217d6d569d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <Storages/Cache/RemoteFileMetadataFactory.h>
#include <Common/Exception.h>
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
extern const int BAD_ARGUMENTS;
}
RemoteFileMetadataFactory & RemoteFileMetadataFactory::instance()
{
static RemoteFileMetadataFactory g_factory;
return g_factory;
}
IRemoteFileMetadataPtr RemoteFileMetadataFactory::get(const String & name)
{
auto it = remote_file_metadatas.find(name);
if (it == remote_file_metadatas.end())
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Not found metadata class:{}", name);
return (it->second)();
}
void RemoteFileMetadataFactory::registerRemoteFileMatadata(const String & name, MetadataCreator creator)
{
auto it = remote_file_metadatas.find(name);
if (it != remote_file_metadatas.end())
{
throw Exception(ErrorCodes::LOGICAL_ERROR, "Metadata class ({}) has already been registered.", name);
}
remote_file_metadatas[name] = creator;
}
}
|