Code cleanup + comments.

This commit is contained in:
Pavel Kovalenko 2021-06-07 13:49:34 +03:00
parent bf5190cd34
commit 6ba40c475a
3 changed files with 8 additions and 9 deletions

View File

@ -87,10 +87,7 @@ bool ReadIndirectBufferFromRemoteFS<T>::nextImpl()
{
/// Find first available buffer that fits to given offset.
if (!current_buf)
{
current_buf = initialize();
pos = working_buffer.begin();
}
/// If current buffer has remaining data - use it.
if (current_buf)
@ -115,10 +112,14 @@ bool ReadIndirectBufferFromRemoteFS<T>::nextImpl()
template <typename T>
bool ReadIndirectBufferFromRemoteFS<T>::nextAndShiftPosition()
{
/// Transfer current position and working_buffer to actual ReadBuffer
swap(*current_buf);
/// Position and working_buffer will be updated in next() call
auto result = current_buf->next();
/// and assigned to current buffer.
swap(*current_buf);
/// absolute position is shifted by a data size that was read in next() call above.
if (result)
absolute_position += working_buffer.size();

View File

@ -320,6 +320,7 @@ void DiskS3::startup()
{
auto settings = current_settings.get();
/// Need to be enabled if it was disabled during shutdown() call.
settings->client->EnableRequestProcessing();
if (!settings->send_metadata)

View File

@ -91,18 +91,15 @@ bool ReadBufferFromS3::nextImpl()
off_t ReadBufferFromS3::seek(off_t offset_, int whence)
{
if (impl)
throw Exception("Seek is allowed only before first read attempt from the buffer.", ErrorCodes::CANNOT_SEEK_THROUGH_FILE);
if (whence != SEEK_SET)
throw Exception("Only SEEK_SET mode is allowed.", ErrorCodes::CANNOT_SEEK_THROUGH_FILE);
if (offset_ < 0)
throw Exception("Seek position is out of bounds. Offset: " + std::to_string(offset_), ErrorCodes::SEEK_POSITION_OUT_OF_BOUND);
if (impl)
{
impl.reset();
pos = working_buffer.end();
}
offset = offset_;
return offset;