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