Fix tests

This commit is contained in:
avogar 2023-01-13 17:03:53 +00:00
parent adadfdcbce
commit e2470dd670
5 changed files with 26 additions and 9 deletions

View File

@ -43,13 +43,13 @@ CSVRowInputFormat::CSVRowInputFormat(
bool with_types_,
const FormatSettings & format_settings_)
: CSVRowInputFormat(
header_, std::make_unique<PeekableReadBuffer>(in_), params_, with_names_, with_types_, format_settings_)
header_, std::make_shared<PeekableReadBuffer>(in_), params_, with_names_, with_types_, format_settings_)
{
}
CSVRowInputFormat::CSVRowInputFormat(
const Block & header_,
std::unique_ptr<PeekableReadBuffer> in_,
std::shared_ptr<PeekableReadBuffer> in_,
const Params & params_,
bool with_names_,
bool with_types_,
@ -72,7 +72,7 @@ CSVRowInputFormat::CSVRowInputFormat(
CSVRowInputFormat::CSVRowInputFormat(
const Block & header_,
std::unique_ptr<PeekableReadBuffer> in_,
std::shared_ptr<PeekableReadBuffer> in_,
const Params & params_,
bool with_names_,
bool with_types_,

View File

@ -29,10 +29,10 @@ public:
void setReadBuffer(ReadBuffer & in_) override;
protected:
CSVRowInputFormat(const Block & header_, std::unique_ptr<PeekableReadBuffer> in_, const Params & params_,
CSVRowInputFormat(const Block & header_, std::shared_ptr<PeekableReadBuffer> in_, const Params & params_,
bool with_names_, bool with_types_, const FormatSettings & format_settings_, std::unique_ptr<FormatWithNamesAndTypesReader> format_reader_);
CSVRowInputFormat(const Block & header_, std::unique_ptr<PeekableReadBuffer> in_buf_, const Params & params_,
CSVRowInputFormat(const Block & header_, std::shared_ptr<PeekableReadBuffer> 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<PeekableReadBuffer> buf;
std::shared_ptr<PeekableReadBuffer> buf;
};
class CSVFormatReader : public FormatWithNamesAndTypesReader

View File

@ -30,9 +30,9 @@ HiveTextRowInputFormat::HiveTextRowInputFormat(
}
HiveTextRowInputFormat::HiveTextRowInputFormat(
const Block & header_, std::unique_ptr<PeekableReadBuffer> buf_, const Params & params_, const FormatSettings & format_settings_)
const Block & header_, std::shared_ptr<PeekableReadBuffer> buf_, const Params & params_, const FormatSettings & format_settings_)
: CSVRowInputFormat(
header_, std::move(buf_), params_, true, false, format_settings_, std::make_unique<HiveTextFormatReader>(*buf_, format_settings_))
header_, buf_, params_, true, false, format_settings_, std::make_unique<HiveTextFormatReader>(*buf_, format_settings_))
{
}

View File

@ -20,7 +20,7 @@ public:
private:
HiveTextRowInputFormat(
const Block & header_, std::unique_ptr<PeekableReadBuffer> buf_, const Params & params_, const FormatSettings & format_settings_);
const Block & header_, std::shared_ptr<PeekableReadBuffer> buf_, const Params & params_, const FormatSettings & format_settings_);
};
class HiveTextFormatReader final : public CSVFormatReader

View File

@ -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(); }