Merge pull request #29276 from kssenii/hdfs-fix-assertion

Fix !hasPendingData() failed assertion in hdfs read buffer
This commit is contained in:
Kseniia Sumarokova 2021-09-27 15:47:17 +03:00 committed by GitHub
commit beda6bee2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,10 +85,15 @@ struct ReadBufferFromHDFS::ReadBufferFromHDFSImpl : public BufferWithOwnMemory<S
"Fail to read from HDFS: {}, file path: {}. Error: {}",
hdfs_uri, hdfs_file_path, std::string(hdfsGetLastError()));
working_buffer.resize(bytes_read);
offset += bytes_read;
if (bytes_read)
{
working_buffer = internal_buffer;
working_buffer.resize(bytes_read);
offset += bytes_read;
return true;
}
return bytes_read;
return false;
}
off_t seek(off_t offset_, int whence) override
@ -129,16 +134,13 @@ ReadBufferFromHDFS::ReadBufferFromHDFS(
bool ReadBufferFromHDFS::nextImpl()
{
impl->position() = impl->buffer().begin() + offset();
auto result = impl->next();
if (result)
{
working_buffer = internal_buffer = impl->buffer();
pos = working_buffer.begin();
}
else
return false;
return true;
BufferBase::set(impl->buffer().begin(), impl->buffer().size(), impl->offset); /// use the buffer returned by `impl`
return result;
}