Revert "Fix tidy"

This reverts commit 73ef1233ef.
This commit is contained in:
alesapin 2021-09-06 10:52:20 +03:00
parent d6244bcd7b
commit 2e5e017d6d
6 changed files with 27 additions and 35 deletions

View File

@ -203,5 +203,3 @@ CheckOptions:
value: CamelCase value: CamelCase
- key: readability-identifier-naming.UsingCase - key: readability-identifier-naming.UsingCase
value: CamelCase value: CamelCase
- key: modernize-loop-convert.UseCxx20ReverseRanges
value: false

View File

@ -113,7 +113,7 @@ namespace DB
std::string CompressionCodecEncrypted::deriveKey(const std::string_view & master_key) std::string CompressionCodecEncrypted::deriveKey(const std::string_view & master_key)
{ {
std::string_view salt; // No salt: derive keys in a deterministic manner. std::string_view salt(""); // No salt: derive keys in a deterministic manner.
std::string_view info("Codec Encrypted('AES-128-GCM-SIV') key generation key"); std::string_view info("Codec Encrypted('AES-128-GCM-SIV') key generation key");
std::array<char, 32> result; std::array<char, 32> result;

View File

@ -32,7 +32,7 @@ WriteBufferFromFile::WriteBufferFromFile(
mode_t mode, mode_t mode,
char * existing_memory, char * existing_memory,
size_t alignment) size_t alignment)
: WriteBufferFromFileDescriptor(-1, buf_size, existing_memory, alignment, file_name_) : WriteBufferFromFileDescriptor(-1, buf_size, existing_memory, alignment), file_name(file_name_)
{ {
ProfileEvents::increment(ProfileEvents::FileOpen); ProfileEvents::increment(ProfileEvents::FileOpen);
@ -65,7 +65,9 @@ WriteBufferFromFile::WriteBufferFromFile(
size_t buf_size, size_t buf_size,
char * existing_memory, char * existing_memory,
size_t alignment) size_t alignment)
: WriteBufferFromFileDescriptor(fd_, buf_size, existing_memory, alignment, original_file_name) :
WriteBufferFromFileDescriptor(fd_, buf_size, existing_memory, alignment),
file_name(original_file_name.empty() ? "(fd = " + toString(fd_) + ")" : original_file_name)
{ {
fd_ = -1; fd_ = -1;
} }

View File

@ -25,6 +25,7 @@ namespace DB
class WriteBufferFromFile : public WriteBufferFromFileDescriptor class WriteBufferFromFile : public WriteBufferFromFileDescriptor
{ {
protected: protected:
std::string file_name;
CurrentMetrics::Increment metric_increment{CurrentMetrics::OpenFileForWrite}; CurrentMetrics::Increment metric_increment{CurrentMetrics::OpenFileForWrite};
public: public:

View File

@ -61,9 +61,7 @@ void WriteBufferFromFileDescriptor::nextImpl()
if ((-1 == res || 0 == res) && errno != EINTR) if ((-1 == res || 0 == res) && errno != EINTR)
{ {
ProfileEvents::increment(ProfileEvents::WriteBufferFromFileDescriptorWriteFailed); ProfileEvents::increment(ProfileEvents::WriteBufferFromFileDescriptorWriteFailed);
throwFromErrnoWithPath("Cannot write to file " + getFileName(), getFileName(),
/// Don't use getFileName() here because this method can be called from destructor
throwFromErrnoWithPath("Cannot write to file " + file_name, file_name,
ErrorCodes::CANNOT_WRITE_TO_FILE_DESCRIPTOR); ErrorCodes::CANNOT_WRITE_TO_FILE_DESCRIPTOR);
} }
@ -76,17 +74,19 @@ void WriteBufferFromFileDescriptor::nextImpl()
} }
/// Name or some description of file.
std::string WriteBufferFromFileDescriptor::getFileName() const
{
return "(fd = " + toString(fd) + ")";
}
WriteBufferFromFileDescriptor::WriteBufferFromFileDescriptor( WriteBufferFromFileDescriptor::WriteBufferFromFileDescriptor(
int fd_, int fd_,
size_t buf_size, size_t buf_size,
char * existing_memory, char * existing_memory,
size_t alignment, size_t alignment)
const std::string & file_name_) : WriteBufferFromFileBase(buf_size, existing_memory, alignment), fd(fd_) {}
: WriteBufferFromFileBase(buf_size, existing_memory, alignment)
, fd(fd_)
, file_name(file_name_.empty() ? "(fd = " + toString(fd) + ")" : file_name_)
{
}
WriteBufferFromFileDescriptor::~WriteBufferFromFileDescriptor() WriteBufferFromFileDescriptor::~WriteBufferFromFileDescriptor()
@ -115,7 +115,7 @@ void WriteBufferFromFileDescriptor::sync()
} }
off_t WriteBufferFromFileDescriptor::seek(off_t offset, int whence) // NOLINT off_t WriteBufferFromFileDescriptor::seek(off_t offset, int whence)
{ {
off_t res = lseek(fd, offset, whence); off_t res = lseek(fd, offset, whence);
if (-1 == res) if (-1 == res)
@ -125,7 +125,7 @@ off_t WriteBufferFromFileDescriptor::seek(off_t offset, int whence) // NOLINT
} }
void WriteBufferFromFileDescriptor::truncate(off_t length) // NOLINT void WriteBufferFromFileDescriptor::truncate(off_t length)
{ {
int res = ftruncate(fd, length); int res = ftruncate(fd, length);
if (-1 == res) if (-1 == res)
@ -133,7 +133,7 @@ void WriteBufferFromFileDescriptor::truncate(off_t length) // NOLINT
} }
off_t WriteBufferFromFileDescriptor::size() const off_t WriteBufferFromFileDescriptor::size()
{ {
struct stat buf; struct stat buf;
int res = fstat(fd, &buf); int res = fstat(fd, &buf);

View File

@ -13,17 +13,17 @@ class WriteBufferFromFileDescriptor : public WriteBufferFromFileBase
protected: protected:
int fd; int fd;
/// If file has name contains filename, otherwise contains string "(fd=...)"
std::string file_name;
void nextImpl() override; void nextImpl() override;
/// Name or some description of file.
std::string getFileName() const override;
public: public:
WriteBufferFromFileDescriptor( WriteBufferFromFileDescriptor(
int fd_ = -1, int fd_ = -1,
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
char * existing_memory = nullptr, char * existing_memory = nullptr,
size_t alignment = 0, size_t alignment = 0);
const std::string & file_name_ = "");
/** Could be used before initialization if needed 'fd' was not passed to constructor. /** Could be used before initialization if needed 'fd' was not passed to constructor.
* It's not possible to change 'fd' during work. * It's not possible to change 'fd' during work.
@ -42,19 +42,10 @@ public:
void sync() override; void sync() override;
/// clang-tidy wants these methods to be const, but off_t seek(off_t offset, int whence);
/// they are not const semantically void truncate(off_t length);
off_t seek(off_t offset, int whence); // NOLINT
void truncate(off_t length); // NOLINT
/// Name or some description of file. off_t size();
std::string getFileName() const override
{
return file_name;
}
off_t size() const;
}; };
} }