2021-04-20 18:29:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <IO/ReadBufferFromFileBase.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Delegates all reads to underlying buffer. Doesn't have own memory.
|
|
|
|
class ReadBufferFromFileDecorator : public ReadBufferFromFileBase
|
|
|
|
{
|
|
|
|
public:
|
2021-06-02 15:03:25 +00:00
|
|
|
explicit ReadBufferFromFileDecorator(std::unique_ptr<SeekableReadBuffer> impl_);
|
2021-10-21 12:17:43 +00:00
|
|
|
ReadBufferFromFileDecorator(std::unique_ptr<SeekableReadBuffer> impl_, const String & file_name_);
|
2021-04-20 18:29:03 +00:00
|
|
|
|
|
|
|
std::string getFileName() const override;
|
|
|
|
|
|
|
|
off_t getPosition() override;
|
|
|
|
|
|
|
|
off_t seek(off_t off, int whence) override;
|
|
|
|
|
|
|
|
bool nextImpl() override;
|
|
|
|
|
2022-04-26 12:57:02 +00:00
|
|
|
bool isWithFileSize() const { return dynamic_cast<const WithFileSize *>(impl.get()) != nullptr; }
|
|
|
|
|
|
|
|
const ReadBuffer & getWrappedReadBuffer() const { return *impl; }
|
|
|
|
|
|
|
|
ReadBuffer & getWrappedReadBuffer() { return *impl; }
|
|
|
|
|
2022-05-21 22:21:40 +00:00
|
|
|
bool isIntegratedWithFilesystemCache() const override { return impl->isIntegratedWithFilesystemCache(); }
|
|
|
|
|
2022-05-25 14:49:40 +00:00
|
|
|
size_t getFileSize() override;
|
|
|
|
|
2021-04-20 18:29:03 +00:00
|
|
|
protected:
|
2021-06-02 15:03:25 +00:00
|
|
|
std::unique_ptr<SeekableReadBuffer> impl;
|
2021-10-21 12:17:43 +00:00
|
|
|
String file_name;
|
2021-04-20 18:29:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|