mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
dbms: Server: feature development. [#METR-15090]
This commit is contained in:
parent
b458241ae5
commit
cdfb096f8f
@ -46,6 +46,7 @@ private:
|
||||
std::vector<iocb *> request_ptrs;
|
||||
std::vector<io_event> events;
|
||||
size_t max_bytes_read = std::numeric_limits<size_t>::max();
|
||||
size_t total_bytes_read = 0;
|
||||
int fd = -1; // file descriptor
|
||||
off_t pos_in_file = 0;
|
||||
bool is_pending_read = false;
|
||||
|
@ -118,7 +118,7 @@ bool ReadBufferAIO::nextImpl()
|
||||
cb.aio_lio_opcode = IOCB_CMD_PREAD;
|
||||
cb.aio_fildes = fd;
|
||||
cb.aio_buf = reinterpret_cast<UInt64>(fill_buffer.internalBuffer().begin());
|
||||
cb.aio_nbytes = fill_buffer.internalBuffer().size();
|
||||
cb.aio_nbytes = std::min(fill_buffer.internalBuffer().size(), max_bytes_read);
|
||||
cb.aio_offset = 0;
|
||||
cb.aio_reqprio = 0;
|
||||
|
||||
@ -154,11 +154,18 @@ void ReadBufferAIO::waitForCompletion()
|
||||
is_pending_read = false;
|
||||
|
||||
size_t bytes_read = (events[0].res > 0) ? static_cast<size_t>(events[0].res) : 0;
|
||||
if ((bytes_read % BLOCK_SIZE) != 0)
|
||||
{
|
||||
got_exception = true;
|
||||
throw Exception("Received unaligned number of bytes from file " + filename, ErrorCodes::AIO_UNALIGNED_BUFFER_ERROR);
|
||||
}
|
||||
|
||||
pos_in_file += bytes_read;
|
||||
total_bytes_read += bytes_read;
|
||||
|
||||
if (bytes_read > 0)
|
||||
fill_buffer.buffer().resize(bytes_read);
|
||||
if (bytes_read < fill_buffer.internalBuffer().size())
|
||||
if ((bytes_read < fill_buffer.internalBuffer().size()) || (total_bytes_read == max_bytes_read))
|
||||
is_eof = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user