Merge pull request #40482 from ClickHouse/Avogar-patch-1

Fix bug in HadoopSnappyReadBuffer
This commit is contained in:
Kruglov Pavel 2022-08-23 11:47:59 +02:00 committed by GitHub
commit 54ed9029b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 15 deletions

View File

@ -183,6 +183,8 @@ bool HadoopSnappyReadBuffer::nextImpl()
if (eof)
return false;
do
{
if (!in_available)
{
in->nextIfAtEnd();
@ -200,6 +202,9 @@ bool HadoopSnappyReadBuffer::nextImpl()
decoder->result = decoder->readBlock(&in_available, &in_data, &out_capacity, &out_data);
in->position() = in->buffer().end() - in_available;
}
while (decoder->result == Status::NEEDS_MORE_INPUT);
working_buffer.resize(internal_buffer.size() - out_capacity);
if (decoder->result == Status::OK)

View File

@ -60,7 +60,8 @@ TEST(HadoopSnappyDecoder, repeatNeedMoreInput)
String output;
WriteBufferFromString out(output);
copyData(read_buffer, out);
out.finalize();
UInt128 hashcode = sipHash128(output.c_str(), output.size());
String hashcode_str = getHexUIntLowercase(hashcode);
ASSERT_EQ(hashcode_str, "593afe14f61866915cc00b8c7bd86046");
ASSERT_EQ(hashcode_str, "673e5b065186cec146789451c2a8f703");
}