2021-04-20 18:29:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <IO/WriteBufferFromFileBase.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Delegates all writes to underlying buffer. Doesn't have own memory.
|
|
|
|
class WriteBufferFromFileDecorator : public WriteBufferFromFileBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit WriteBufferFromFileDecorator(std::unique_ptr<WriteBuffer> impl_);
|
|
|
|
|
|
|
|
~WriteBufferFromFileDecorator() override;
|
|
|
|
|
|
|
|
void sync() override;
|
|
|
|
|
|
|
|
std::string getFileName() const override;
|
|
|
|
|
2022-02-01 10:36:51 +00:00
|
|
|
void preFinalize() override
|
|
|
|
{
|
|
|
|
next();
|
|
|
|
impl->preFinalize();
|
|
|
|
is_prefinalized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const WriteBuffer & getImpl() const { return *impl; }
|
|
|
|
|
2021-04-20 18:29:03 +00:00
|
|
|
protected:
|
2021-11-10 22:58:56 +00:00
|
|
|
void finalizeImpl() override;
|
|
|
|
|
2021-04-20 18:29:03 +00:00
|
|
|
std::unique_ptr<WriteBuffer> impl;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void nextImpl() override;
|
2022-02-01 10:36:51 +00:00
|
|
|
|
|
|
|
bool is_prefinalized = false;
|
2021-04-20 18:29:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|