mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-24 10:40:49 +00:00
PeekableReadBufferCheckpoint
This commit is contained in:
parent
456a8c4b17
commit
7e9c3f2022
@ -268,7 +268,7 @@ bool PeekableReadBuffer::checkpointInOwnMemory() const
|
||||
return checkpoint_in_own_memory;
|
||||
}
|
||||
|
||||
void PeekableReadBuffer::assertCanBeDistructed() const
|
||||
void PeekableReadBuffer::assertCanBeDestructed() const
|
||||
{
|
||||
if (peeked_size && pos != memory.data() + peeked_size)
|
||||
throw DB::Exception("There are data, which were extracted from sub-buffer, but not from peekable buffer: "
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
/// but not from this buffer, so the data will not be lost after destruction of this buffer.
|
||||
/// If position is in sub-buffer, returns empty buffer.
|
||||
std::shared_ptr<BufferWithOwnMemory<ReadBuffer>> takeUnreadData();
|
||||
void assertCanBeDistructed() const;
|
||||
void assertCanBeDestructed() const;
|
||||
|
||||
private:
|
||||
|
||||
@ -59,6 +59,7 @@ private:
|
||||
inline bool currentlyReadFromOwnMemory() const;
|
||||
inline bool checkpointInOwnMemory() const;
|
||||
|
||||
// TODO add unit test for PeekableReadBuffer and remove this method
|
||||
void checkStateCorrect() const;
|
||||
|
||||
/// Makes possible to append `bytes_to_append` bytes to data in own memory.
|
||||
@ -74,4 +75,14 @@ private:
|
||||
bool checkpoint_in_own_memory = false;
|
||||
};
|
||||
|
||||
|
||||
class PeekableReadBufferCheckpoint : boost::noncopyable
|
||||
{
|
||||
PeekableReadBuffer & buf;
|
||||
public:
|
||||
explicit PeekableReadBufferCheckpoint(PeekableReadBuffer & buf_) : buf(buf_) { buf.setCheckpoint(); }
|
||||
~PeekableReadBufferCheckpoint() { buf.dropCheckpoint(); }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user