mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 18:02:24 +00:00
minor improve read buffer of hdfs
This commit is contained in:
parent
da8590a26c
commit
e6d6d41f22
@ -41,6 +41,7 @@ struct ReadBufferFromHDFS::ReadBufferFromHDFSImpl : public BufferWithOwnMemory<S
|
|||||||
|
|
||||||
off_t file_offset = 0;
|
off_t file_offset = 0;
|
||||||
off_t read_until_position = 0;
|
off_t read_until_position = 0;
|
||||||
|
off_t file_size;
|
||||||
|
|
||||||
explicit ReadBufferFromHDFSImpl(
|
explicit ReadBufferFromHDFSImpl(
|
||||||
const std::string & hdfs_uri_,
|
const std::string & hdfs_uri_,
|
||||||
@ -63,6 +64,7 @@ struct ReadBufferFromHDFS::ReadBufferFromHDFSImpl : public BufferWithOwnMemory<S
|
|||||||
throw Exception(ErrorCodes::CANNOT_OPEN_FILE,
|
throw Exception(ErrorCodes::CANNOT_OPEN_FILE,
|
||||||
"Unable to open HDFS file: {}. Error: {}",
|
"Unable to open HDFS file: {}. Error: {}",
|
||||||
hdfs_uri + hdfs_file_path, std::string(hdfsGetLastError()));
|
hdfs_uri + hdfs_file_path, std::string(hdfsGetLastError()));
|
||||||
|
file_size = getFileSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
~ReadBufferFromHDFSImpl() override
|
~ReadBufferFromHDFSImpl() override
|
||||||
@ -95,6 +97,10 @@ struct ReadBufferFromHDFS::ReadBufferFromHDFSImpl : public BufferWithOwnMemory<S
|
|||||||
{
|
{
|
||||||
num_bytes_to_read = internal_buffer.size();
|
num_bytes_to_read = internal_buffer.size();
|
||||||
}
|
}
|
||||||
|
if (file_size != 0 && file_offset >= file_size)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ResourceGuard rlock(read_settings.resource_link, num_bytes_to_read);
|
ResourceGuard rlock(read_settings.resource_link, num_bytes_to_read);
|
||||||
int bytes_read;
|
int bytes_read;
|
||||||
|
Loading…
Reference in New Issue
Block a user