mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Do not try to read empty files.
CI report [1]. [1]: https://clickhouse-test-reports.s3.yandex.net/30190/fe534553b2a0ac543795956b3fbde673cf5a342b/functional_stateless_tests_(debug).html#fail1 Fixes: 01560_ttl_remove_empty_parts in debug build (and some other tests) v0: fix MergeTreeDataPartCompact::loadIndexGranularity()/MergeTreeDataPartWide::loadIndexGranularity() v2: use EmptyReadBuffer in DiskLocal::readFile() v3: introduce ReadBufferFromEmptyFile v4: rebase against readbuffer-real-size branch
This commit is contained in:
parent
b0f9112696
commit
a630821f60
23
src/IO/ReadBufferFromEmptyFile.h
Normal file
23
src/IO/ReadBufferFromEmptyFile.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <IO/ReadBuffer.h>
|
||||
|
||||
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
|
||||
{
|
||||
private:
|
||||
bool nextImpl() override { return false; }
|
||||
std::string getFileName() const override { return "<empty>"; }
|
||||
off_t seek(off_t /*off*/, int /*whence*/) override { return 0; }
|
||||
off_t getPosition() override { return 0; }
|
||||
};
|
||||
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include <IO/createReadBufferFromFileBase.h>
|
||||
#include <IO/ReadBufferFromEmptyFile.h>
|
||||
#include <IO/ReadBufferFromFile.h>
|
||||
#include <IO/MMapReadBufferFromFileWithCache.h>
|
||||
#include <IO/AsynchronousReadBufferFromFile.h>
|
||||
@ -33,6 +34,8 @@ std::unique_ptr<ReadBufferFromFileBase> createReadBufferFromFileBase(
|
||||
char * existing_memory,
|
||||
size_t alignment)
|
||||
{
|
||||
if (size.has_value() && !*size)
|
||||
return std::make_unique<ReadBufferFromEmptyFile>();
|
||||
size_t estimated_size = size.has_value() ? *size : 0;
|
||||
|
||||
if (!existing_memory
|
||||
|
Loading…
Reference in New Issue
Block a user