mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
small fix
This commit is contained in:
parent
c913155d95
commit
31cb69269b
@ -384,32 +384,36 @@ void registerInputFormatProcessorTabSeparated(FormatFactory & factory)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveUpToPosition(ReadBuffer & in, DB::Memory<> & memory, char * ptr)
|
void saveUpToPosition(ReadBuffer & in, DB::Memory<> & memory, char * current)
|
||||||
{
|
{
|
||||||
assert(ptr >= in.position());
|
assert(ptr >= in.position());
|
||||||
assert(ptr <= in.buffer().end());
|
assert(ptr <= in.buffer().end());
|
||||||
|
|
||||||
const int old_bytes = memory.size();
|
const int old_bytes = memory.size();
|
||||||
const int additional_bytes = ptr - in.position();
|
const int additional_bytes = current - in.position();
|
||||||
const int new_bytes = old_bytes + additional_bytes;
|
const int new_bytes = old_bytes + additional_bytes;
|
||||||
|
/// There are no new bytes to add to memory.
|
||||||
|
/// No need to do extra stuff.
|
||||||
|
if (new_bytes == 0)
|
||||||
|
return;
|
||||||
memory.resize(new_bytes);
|
memory.resize(new_bytes);
|
||||||
memcpy(memory.data() + old_bytes, in.position(), additional_bytes);
|
memcpy(memory.data() + old_bytes, in.position(), additional_bytes);
|
||||||
in.position() = ptr;
|
in.position() = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadAtPosition(ReadBuffer & in, DB::Memory<> & memory, char * & ptr)
|
bool loadAtPosition(ReadBuffer & in, DB::Memory<> & memory, char * & current)
|
||||||
{
|
{
|
||||||
assert(ptr <= in.buffer().end());
|
assert(ptr <= in.buffer().end());
|
||||||
|
|
||||||
if (ptr < in.buffer().end())
|
if (current < in.buffer().end())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveUpToPosition(in, memory, in.buffer().end());
|
saveUpToPosition(in, memory, current);
|
||||||
bool loaded_more = !in.eof();
|
bool loaded_more = !in.eof();
|
||||||
assert(in.position() == in.buffer().begin());
|
assert(in.position() == in.buffer().begin());
|
||||||
ptr = in.position();
|
current = in.position();
|
||||||
return loaded_more;
|
return loaded_more;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user