2021-10-17 07:41:11 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <IO/ReadBuffer.h>
|
2022-03-13 11:59:20 +00:00
|
|
|
#include <IO/ReadBufferFromFileBase.h>
|
2021-10-17 07:41:11 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// In case of empty file it does not make any sense to read it.
|
|
|
|
///
|
|
|
|
/// Plus regular readers from file has an assert that buffer is not empty, that will fail:
|
|
|
|
/// - ReadBufferFromFileDescriptor
|
|
|
|
/// - SynchronousReader
|
|
|
|
/// - ThreadPoolReader
|
|
|
|
class ReadBufferFromEmptyFile : public ReadBufferFromFileBase
|
|
|
|
{
|
2024-01-16 23:19:00 +00:00
|
|
|
public:
|
|
|
|
explicit ReadBufferFromEmptyFile(const String & file_name_) : file_name(file_name_) {}
|
|
|
|
|
2021-10-17 07:41:11 +00:00
|
|
|
private:
|
2024-01-16 23:19:00 +00:00
|
|
|
String file_name;
|
|
|
|
|
2021-10-17 07:41:11 +00:00
|
|
|
bool nextImpl() override { return false; }
|
2024-01-16 23:19:00 +00:00
|
|
|
std::string getFileName() const override { return file_name; }
|
2021-10-17 07:41:11 +00:00
|
|
|
off_t seek(off_t /*off*/, int /*whence*/) override { return 0; }
|
|
|
|
off_t getPosition() override { return 0; }
|
2022-05-25 14:49:40 +00:00
|
|
|
size_t getFileSize() override { return 0; }
|
2024-01-16 23:19:00 +00:00
|
|
|
size_t getFileOffsetOfBufferEnd() const override { return 0; }
|
2021-10-17 07:41:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|