mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Fix getting filename from read buffer wrappers
This commit is contained in:
parent
75edbdd39c
commit
00c140b7bb
@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
#include <IO/BufferWithOwnMemory.h>
|
||||
#include <IO/ReadBuffer.h>
|
||||
#include <IO/ReadBufferWrapperBase.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
class CompressedReadBufferWrapper : public BufferWithOwnMemory<ReadBuffer>
|
||||
class CompressedReadBufferWrapper : public BufferWithOwnMemory<ReadBuffer>, public ReadBufferWrapperBase
|
||||
{
|
||||
public:
|
||||
CompressedReadBufferWrapper(
|
||||
@ -16,7 +17,7 @@ public:
|
||||
: BufferWithOwnMemory<ReadBuffer>(buf_size, existing_memory, alignment)
|
||||
, in(std::move(in_)) {}
|
||||
|
||||
const ReadBuffer & getWrappedReadBuffer() const { return *in; }
|
||||
const ReadBuffer & getWrappedReadBuffer() const override { return *in; }
|
||||
ReadBuffer & getWrappedReadBuffer() { return *in; }
|
||||
|
||||
void prefetch(Priority priority) override { in->prefetch(priority); }
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <IO/ReadBuffer.h>
|
||||
#include <IO/ReadBufferWrapperBase.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -7,7 +8,7 @@ namespace DB
|
||||
namespace
|
||||
{
|
||||
template <typename CustomData>
|
||||
class ReadBufferWrapper : public ReadBuffer
|
||||
class ReadBufferWrapper : public ReadBuffer, public ReadBufferWrapperBase
|
||||
{
|
||||
public:
|
||||
ReadBufferWrapper(ReadBuffer & in_, CustomData && custom_data_)
|
||||
@ -15,6 +16,8 @@ namespace
|
||||
{
|
||||
}
|
||||
|
||||
const ReadBuffer & getWrappedReadBuffer() const override { return in; }
|
||||
|
||||
private:
|
||||
ReadBuffer & in;
|
||||
CustomData custom_data;
|
||||
|
15
src/IO/ReadBufferWrapperBase.h
Normal file
15
src/IO/ReadBufferWrapperBase.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <IO/ReadBuffer.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
class ReadBufferWrapperBase
|
||||
{
|
||||
public:
|
||||
virtual const ReadBuffer & getWrappedReadBuffer() const = 0;
|
||||
virtual ~ReadBufferWrapperBase() = default;
|
||||
};
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#include <IO/WithFileName.h>
|
||||
#include <IO/CompressedReadBufferWrapper.h>
|
||||
#include <IO/ReadBufferWrapperBase.h>
|
||||
#include <IO/ParallelReadBuffer.h>
|
||||
#include <IO/PeekableReadBuffer.h>
|
||||
|
||||
@ -16,10 +16,10 @@ static String getFileName(const T & entry)
|
||||
|
||||
String getFileNameFromReadBuffer(const ReadBuffer & in)
|
||||
{
|
||||
if (const auto * compressed = dynamic_cast<const CompressedReadBufferWrapper *>(&in))
|
||||
return getFileName(compressed->getWrappedReadBuffer());
|
||||
if (const auto * wrapper = dynamic_cast<const ReadBufferWrapperBase *>(&in))
|
||||
return getFileNameFromReadBuffer(wrapper->getWrappedReadBuffer());
|
||||
else if (const auto * parallel = dynamic_cast<const ParallelReadBuffer *>(&in))
|
||||
return getFileName(parallel->getReadBuffer());
|
||||
return getFileNameFromReadBuffer(parallel->getReadBuffer());
|
||||
else if (const auto * peekable = dynamic_cast<const PeekableReadBuffer *>(&in))
|
||||
return getFileNameFromReadBuffer(peekable->getSubBuffer());
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user