This commit is contained in:
kssenii 2021-11-08 13:32:32 +03:00
parent b4bebc5977
commit 83d64f1c2d
2 changed files with 7 additions and 7 deletions

View File

@ -70,12 +70,12 @@ bool AsynchronousReadIndirectBufferFromRemoteFS::hasPendingDataToRead()
if (read_until_position)
{
/// Everything is already read.
if (file_offset_of_buffer_end == read_until_position)
if (file_offset_of_buffer_end == *read_until_position)
return false;
if (file_offset_of_buffer_end > read_until_position)
if (file_offset_of_buffer_end > *read_until_position)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Read beyond last offset ({} > {})",
file_offset_of_buffer_end, read_until_position);
file_offset_of_buffer_end, *read_until_position);
}
else if (must_read_until_position)
throw Exception(ErrorCodes::LOGICAL_ERROR,
@ -124,7 +124,7 @@ void AsynchronousReadIndirectBufferFromRemoteFS::setReadUntilPosition(size_t pos
throw Exception(ErrorCodes::LOGICAL_ERROR, "Prefetch is valid in readUntilPosition");
read_until_position = position;
impl->setReadUntilPosition(read_until_position);
impl->setReadUntilPosition(*read_until_position);
}
@ -134,7 +134,7 @@ void AsynchronousReadIndirectBufferFromRemoteFS::setReadUntilEnd()
throw Exception(ErrorCodes::LOGICAL_ERROR, "Prefetch is valid in readUntilEnd");
read_until_position = impl->getFileSize();
impl->setReadUntilPosition(read_until_position);
impl->setReadUntilPosition(*read_until_position);
}
@ -232,7 +232,7 @@ off_t AsynchronousReadIndirectBufferFromRemoteFS::seek(off_t offset_, int whence
pos = working_buffer.end();
/// Note: we read in range [file_offset_of_buffer_end, read_until_position).
if (file_offset_of_buffer_end < read_until_position
if (read_until_position && file_offset_of_buffer_end < *read_until_position
&& static_cast<off_t>(file_offset_of_buffer_end) >= getPosition()
&& static_cast<off_t>(file_offset_of_buffer_end) < getPosition() + static_cast<off_t>(min_bytes_for_seek))
{

View File

@ -76,7 +76,7 @@ private:
size_t bytes_to_ignore = 0;
size_t read_until_position = 0;
std::optional<size_t> read_until_position = 0;
bool must_read_until_position;
};