ClickHouse/src/IO/WriteBufferFromFileDecorator.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.0 KiB
C++
Raw Normal View History

2021-04-20 18:29:03 +00:00
#include "WriteBufferFromFileDecorator.h"
#include <IO/WriteBuffer.h>
namespace DB
{
2021-04-20 18:52:58 +00:00
WriteBufferFromFileDecorator::WriteBufferFromFileDecorator(std::unique_ptr<WriteBuffer> impl_)
2021-04-20 18:29:03 +00:00
: WriteBufferFromFileBase(0, nullptr, 0), impl(std::move(impl_))
{
swap(*impl);
}
2021-11-10 22:58:56 +00:00
void WriteBufferFromFileDecorator::finalizeImpl()
2021-04-20 18:29:03 +00:00
{
next();
if (!is_prefinalized)
WriteBufferFromFileDecorator::preFinalize();
2021-04-20 18:29:03 +00:00
impl->finalize();
}
2021-04-20 18:52:58 +00:00
WriteBufferFromFileDecorator::~WriteBufferFromFileDecorator()
2021-04-20 18:29:03 +00:00
{
try
{
2021-11-10 22:58:56 +00:00
finalize();
2021-04-20 18:29:03 +00:00
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
}
2021-04-20 18:52:58 +00:00
void WriteBufferFromFileDecorator::sync()
2021-04-20 18:29:03 +00:00
{
impl->sync();
}
2021-04-20 18:52:58 +00:00
std::string WriteBufferFromFileDecorator::getFileName() const
2021-04-20 18:29:03 +00:00
{
2021-04-20 18:52:58 +00:00
if (WriteBufferFromFileBase * buffer = dynamic_cast<WriteBufferFromFileBase*>(impl.get()))
return buffer->getFileName();
2021-04-20 18:29:03 +00:00
return std::string();
}
2021-04-20 18:52:58 +00:00
void WriteBufferFromFileDecorator::nextImpl()
2021-04-20 18:29:03 +00:00
{
swap(*impl);
impl->next();
swap(*impl);
}
}