small fixes of review remarks

This commit is contained in:
Gleb Novikov 2020-05-16 23:31:17 +03:00
parent d255bb998a
commit 45b84d491e
7 changed files with 12 additions and 56 deletions

View File

@ -24,7 +24,7 @@ class IDiskDirectoryIterator;
using DiskDirectoryIteratorPtr = std::unique_ptr<IDiskDirectoryIterator>;
class IReservation;
using ReservationPtr = std::shared_ptr<IReservation>;
using ReservationPtr = std::unique_ptr<IReservation>;
class ReadBufferFromFileBase;
class WriteBufferFromFileBase;

View File

@ -13,29 +13,6 @@ namespace ErrorCodes
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(
String name_, const Poco::Util::AbstractConfiguration & config, const String & config_prefix, DiskSelectorPtr disk_selector)
: name(std::move(name_))

View File

@ -8,33 +8,11 @@
namespace DB
{
class VolumeType
enum 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;
JBOD,
SINGLE_DISK,
UNKNOWN
};
class IVolume;
@ -55,7 +33,7 @@ using Volumes = std::vector<VolumePtr>;
class IVolume : public Space
{
public:
IVolume(const String & name_, Disks disks_): disks(std::move(disks_)), name(name_)
IVolume(String name_, Disks disks_): disks(std::move(disks_)), name(name_)
{
}

View File

@ -3,7 +3,7 @@
namespace DB
{
VolumePtr createVolumeFromReservation(ReservationPtr reservation, VolumePtr other_volume)
VolumePtr createVolumeFromReservation(const ReservationPtr & reservation, VolumePtr other_volume)
{
if (other_volume->getType() == VolumeType::JBOD || other_volume->getType() == VolumeType::SINGLE_DISK)
{

View File

@ -7,6 +7,6 @@
namespace DB
{
VolumePtr createVolumeFromReservation(ReservationPtr reservation, VolumePtr other_volume);
VolumePtr createVolumeFromReservation(const ReservationPtr & reservation, VolumePtr other_volume);
}

View File

@ -29,7 +29,7 @@ struct ColumnSize;
class MergeTreeData;
struct FutureMergedMutatedPart;
class IReservation;
using ReservationPtr = std::shared_ptr<IReservation>;
using ReservationPtr = std::unique_ptr<IReservation>;
class IVolume;
using VolumePtr = std::shared_ptr<IVolume>;

View File

@ -85,8 +85,9 @@ IMergeTreeDataPartWriter::IMergeTreeDataPartWriter(
if (settings.blocks_are_granules_size && !index_granularity.empty())
throw Exception("Can't take information about index granularity from blocks, when non empty index_granularity array specified", ErrorCodes::LOGICAL_ERROR);
if (!data_part->volume->getDisk()->exists(part_path))
data_part->volume->getDisk()->createDirectories(part_path);
auto disk = data_part->volume->getDisk();
if (!disk->exists(part_path))
disk->createDirectories(part_path);
}
IMergeTreeDataPartWriter::~IMergeTreeDataPartWriter() = default;