From e2470dd670f741f80ae26683275d021ecbcdf862 Mon Sep 17 00:00:00 2001 From: avogar Date: Fri, 13 Jan 2023 17:03:53 +0000 Subject: [PATCH] Fix tests --- .../Formats/Impl/CSVRowInputFormat.cpp | 6 +++--- src/Processors/Formats/Impl/CSVRowInputFormat.h | 6 +++--- .../Formats/Impl/HiveTextRowInputFormat.cpp | 4 ++-- .../Formats/Impl/HiveTextRowInputFormat.h | 2 +- src/Storages/StorageS3.h | 17 +++++++++++++++++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/Processors/Formats/Impl/CSVRowInputFormat.cpp b/src/Processors/Formats/Impl/CSVRowInputFormat.cpp index 2b93a3f56cf..df55f03a15c 100644 --- a/src/Processors/Formats/Impl/CSVRowInputFormat.cpp +++ b/src/Processors/Formats/Impl/CSVRowInputFormat.cpp @@ -43,13 +43,13 @@ CSVRowInputFormat::CSVRowInputFormat( bool with_types_, const FormatSettings & format_settings_) : CSVRowInputFormat( - header_, std::make_unique(in_), params_, with_names_, with_types_, format_settings_) + header_, std::make_shared(in_), params_, with_names_, with_types_, format_settings_) { } CSVRowInputFormat::CSVRowInputFormat( const Block & header_, - std::unique_ptr in_, + std::shared_ptr in_, const Params & params_, bool with_names_, bool with_types_, @@ -72,7 +72,7 @@ CSVRowInputFormat::CSVRowInputFormat( CSVRowInputFormat::CSVRowInputFormat( const Block & header_, - std::unique_ptr in_, + std::shared_ptr in_, const Params & params_, bool with_names_, bool with_types_, diff --git a/src/Processors/Formats/Impl/CSVRowInputFormat.h b/src/Processors/Formats/Impl/CSVRowInputFormat.h index 558fdc83cb9..86f7fe3466c 100644 --- a/src/Processors/Formats/Impl/CSVRowInputFormat.h +++ b/src/Processors/Formats/Impl/CSVRowInputFormat.h @@ -29,10 +29,10 @@ public: void setReadBuffer(ReadBuffer & in_) override; protected: - CSVRowInputFormat(const Block & header_, std::unique_ptr in_, const Params & params_, + CSVRowInputFormat(const Block & header_, std::shared_ptr in_, const Params & params_, bool with_names_, bool with_types_, const FormatSettings & format_settings_, std::unique_ptr format_reader_); - CSVRowInputFormat(const Block & header_, std::unique_ptr in_buf_, const Params & params_, + CSVRowInputFormat(const Block & header_, std::shared_ptr in_buf_, const Params & params_, bool with_names_, bool with_types_, const FormatSettings & format_settings_); private: @@ -40,7 +40,7 @@ private: void syncAfterError() override; protected: - std::unique_ptr buf; + std::shared_ptr buf; }; class CSVFormatReader : public FormatWithNamesAndTypesReader diff --git a/src/Processors/Formats/Impl/HiveTextRowInputFormat.cpp b/src/Processors/Formats/Impl/HiveTextRowInputFormat.cpp index 2b4afffdc15..1b73e0131f6 100644 --- a/src/Processors/Formats/Impl/HiveTextRowInputFormat.cpp +++ b/src/Processors/Formats/Impl/HiveTextRowInputFormat.cpp @@ -30,9 +30,9 @@ HiveTextRowInputFormat::HiveTextRowInputFormat( } HiveTextRowInputFormat::HiveTextRowInputFormat( - const Block & header_, std::unique_ptr buf_, const Params & params_, const FormatSettings & format_settings_) + const Block & header_, std::shared_ptr buf_, const Params & params_, const FormatSettings & format_settings_) : CSVRowInputFormat( - header_, std::move(buf_), params_, true, false, format_settings_, std::make_unique(*buf_, format_settings_)) + header_, buf_, params_, true, false, format_settings_, std::make_unique(*buf_, format_settings_)) { } diff --git a/src/Processors/Formats/Impl/HiveTextRowInputFormat.h b/src/Processors/Formats/Impl/HiveTextRowInputFormat.h index 5a30e4da9be..313aad0d40d 100644 --- a/src/Processors/Formats/Impl/HiveTextRowInputFormat.h +++ b/src/Processors/Formats/Impl/HiveTextRowInputFormat.h @@ -20,7 +20,7 @@ public: private: HiveTextRowInputFormat( - const Block & header_, std::unique_ptr buf_, const Params & params_, const FormatSettings & format_settings_); + const Block & header_, std::shared_ptr buf_, const Params & params_, const FormatSettings & format_settings_); }; class HiveTextFormatReader final : public CSVFormatReader diff --git a/src/Storages/StorageS3.h b/src/Storages/StorageS3.h index 0f6fc013d51..a5e1ed4e0b5 100644 --- a/src/Storages/StorageS3.h +++ b/src/Storages/StorageS3.h @@ -176,6 +176,23 @@ private: } ReaderHolder() = default; + ReaderHolder(const ReaderHolder & other) = delete; + ReaderHolder & operator=(const ReaderHolder & other) = delete; + + ReaderHolder(ReaderHolder && other) noexcept + { + *this = std::move(other); + } + + ReaderHolder & operator=(ReaderHolder && other) noexcept + { + /// The order of destruction is important. + /// reader uses pipeline, pipeline uses read_buf. + reader = std::move(other.reader); + pipeline = std::move(other.pipeline); + read_buf = std::move(other.read_buf); + return *this; + } explicit operator bool() const { return reader != nullptr; } PullingPipelineExecutor * operator->() { return reader.get(); }