mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-01 20:12:02 +00:00
VolumeType as class with enum member class
This commit is contained in:
parent
390b39b272
commit
a961e049a2
@ -494,6 +494,7 @@ namespace ErrorCodes
|
||||
extern const int CANNOT_DETACH_DICTIONARY_AS_TABLE = 520;
|
||||
extern const int ATOMIC_RENAME_FAIL = 521;
|
||||
extern const int INCORRECT_DISK_INDEX = 522;
|
||||
extern const int UNKNOWN_VOLUME_TYPE = 523;
|
||||
|
||||
extern const int KEEPER_EXCEPTION = 999;
|
||||
extern const int POCO_EXCEPTION = 1000;
|
||||
|
@ -10,6 +10,30 @@ namespace DB
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int EXCESSIVE_ELEMENT_IN_CONFIG;
|
||||
extern const int UNKNOWN_VOLUME_TYPE;
|
||||
}
|
||||
|
||||
void VolumeType::fromString(const String & str)
|
||||
{
|
||||
if (str == "JBOD")
|
||||
value = JBOD;
|
||||
else if (str == "SINGLE_DISK")
|
||||
value = SINGLE_DISK;
|
||||
else
|
||||
throw DB::Exception("Unexpected string for volume type: " + str, ErrorCodes::UNKNOWN_VOLUME_TYPE);
|
||||
}
|
||||
|
||||
String VolumeType::toString() const
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case JBOD:
|
||||
return "JBOD";
|
||||
case SINGLE_DISK:
|
||||
return "SINGLE_DISK";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
IVolume::IVolume(
|
||||
|
@ -8,11 +8,33 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
enum VolumeType
|
||||
class VolumeType
|
||||
{
|
||||
public:
|
||||
enum Value
|
||||
{
|
||||
JBOD,
|
||||
SINGLE_DISK,
|
||||
UNKNOWN
|
||||
};
|
||||
VolumeType() : value(UNKNOWN) {}
|
||||
VolumeType(Value value_) : value(value_) {}
|
||||
|
||||
bool operator==(const VolumeType & other) const
|
||||
{
|
||||
return value == other.value;
|
||||
}
|
||||
|
||||
bool operator!=(const VolumeType & other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
void fromString(const String & str);
|
||||
String toString() const;
|
||||
|
||||
private:
|
||||
Value value;
|
||||
};
|
||||
|
||||
class IVolume;
|
||||
|
Loading…
Reference in New Issue
Block a user