mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Reset internal buffer position on next()
This commit is contained in:
parent
3b52b04008
commit
b0f400ca1b
@ -40,6 +40,7 @@ public:
|
||||
inline Position end() const { return end_pos; }
|
||||
inline size_t size() const { return size_t(end_pos - begin_pos); }
|
||||
inline void resize(size_t size) { end_pos = begin_pos + size; }
|
||||
inline bool empty() const { return size() == 0; }
|
||||
|
||||
inline void swap(Buffer & other)
|
||||
{
|
||||
|
@ -25,11 +25,16 @@ protected:
|
||||
return false;
|
||||
|
||||
/// First reading
|
||||
if (working_buffer.size() == 0 && (*current)->hasPendingData())
|
||||
if (working_buffer.empty())
|
||||
{
|
||||
if ((*current)->hasPendingData())
|
||||
{
|
||||
working_buffer = Buffer((*current)->position(), (*current)->buffer().end());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
(*current)->position() = position();
|
||||
|
||||
if (!(*current)->next())
|
||||
{
|
||||
@ -51,14 +56,12 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
ConcatReadBuffer(const ReadBuffers & buffers_) : ReadBuffer(nullptr, 0), buffers(buffers_), current(buffers.begin()) {}
|
||||
|
||||
ConcatReadBuffer(ReadBuffer & buf1, ReadBuffer & buf2) : ReadBuffer(nullptr, 0)
|
||||
explicit ConcatReadBuffer(const ReadBuffers & buffers_) : ReadBuffer(nullptr, 0), buffers(buffers_), current(buffers.begin())
|
||||
{
|
||||
buffers.push_back(&buf1);
|
||||
buffers.push_back(&buf2);
|
||||
current = buffers.begin();
|
||||
assert(!buffers.empty());
|
||||
}
|
||||
|
||||
ConcatReadBuffer(ReadBuffer & buf1, ReadBuffer & buf2) : ConcatReadBuffer({&buf1, &buf2}) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user