fixed code style

This commit is contained in:
lgbo-ustc 2021-12-06 19:59:15 +08:00 committed by liangjiabiao
parent dd70209623
commit d4dcbd59fb
3 changed files with 7 additions and 6 deletions

View File

@ -5,6 +5,7 @@ namespace DB
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
extern const int BAD_ARGUMENTS;
}
IRemoteFileMetadata::~IRemoteFileMetadata() {}
@ -15,11 +16,11 @@ RemoteFileMetadataFactory & RemoteFileMetadataFactory::instance()
return g_factory;
}
IRemoteFileMetadataPtr RemoteFileMetadataFactory::createClass(const String & class_name)
IRemoteFileMetadataPtr RemoteFileMetadataFactory::get(const String & class_name)
{
auto it = class_creators.find(class_name);
if (it == class_creators.end())
return nullptr;
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Not found metadata class:{}", class_name);
return (it->second)();
}

View File

@ -27,7 +27,7 @@ public:
inline UInt64 getLastModificationTimestamp() const { return last_modification_timestamp; }
// deserialize
virtual bool fromString(const String &buf) = 0;
virtual bool fromString(const String & buf) = 0;
// serialize
virtual String toString() const = 0;
@ -43,7 +43,7 @@ using IRemoteFileMetadataPtr = std::shared_ptr<IRemoteFileMetadata>;
/*
* How to register a subclass into the factory and use it ?
* 1) define your own subclass derive from IRemoteFileMetadata. Notice! the getClassName() must be the same
* 1) define your own subclass derive from IRemoteFileMetadata. Notice! the getName() must be the same
* as your subclass name.
* 2) in a .cpp file, call REGISTTER_REMOTE_FILE_META_DATA_CLASS(subclass),
* 3) call RemoteFileMetadataFactory::instance().createClass(subclass_name) where you want to make a new object
@ -56,7 +56,7 @@ public:
~RemoteFileMetadataFactory() = default;
static RemoteFileMetadataFactory & instance();
IRemoteFileMetadataPtr createClass(const String & class_name);
IRemoteFileMetadataPtr get(const String & class_name);
void registerClass(const String &class_name, ClassCreator creator);
protected:
RemoteFileMetadataFactory() = default;

View File

@ -57,7 +57,7 @@ std::shared_ptr<RemoteCacheController> RemoteCacheController::recover(const std:
return nullptr;
}
cache_controller->file_metadata_ptr = RemoteFileMetadataFactory::instance().createClass(cache_controller->metadata_class);
cache_controller->file_metadata_ptr = RemoteFileMetadataFactory::instance().get(cache_controller->metadata_class);
if (!cache_controller->file_metadata_ptr)
{
// do not load this invalid cached file and clear it. the clear action is in