blob: 539825e3a8525e838b6bda2b902cab52b9f6ffed (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#pragma once
#include <memory>
#include <IO/ReadBuffer.h>
namespace DB
{
struct IReadableWriteBuffer
{
/// At the first time returns getReadBufferImpl(). Next calls return nullptr.
inline std::shared_ptr<ReadBuffer> tryGetReadBuffer()
{
if (!can_reread)
return nullptr;
can_reread = false;
return getReadBufferImpl();
}
virtual ~IReadableWriteBuffer() = default;
protected:
/// Creates read buffer from current write buffer.
/// Returned buffer points to the first byte of original buffer.
/// Original stream becomes invalid.
virtual std::shared_ptr<ReadBuffer> getReadBufferImpl() = 0;
bool can_reread = true;
};
}
|