support supportsRightBoundedReads for ReadBufferFromHDFS and AsynchronousReadBufferFromHDFS

This commit is contained in:
taiyang-li 2024-11-11 16:19:52 +08:00
parent 0cbf3c3b2f
commit 42c7383a12
4 changed files with 55 additions and 0 deletions

View File

@ -270,6 +270,21 @@ size_t AsynchronousReadBufferFromHDFS::getFileOffsetOfBufferEnd() const
return file_offset_of_buffer_end;
}
bool AsynchronousReadBufferFromHDFS::supportsRightBoundedReads() const
{
return true;
}
void AsynchronousReadBufferFromHDFS::setReadUntilPosition(size_t position)
{
read_until_position = position;
}
void AsynchronousReadBufferFromHDFS::setReadUntilEnd()
{
read_until_position = impl->getFileSize();
}
}
#endif

View File

@ -31,6 +31,12 @@ public:
~AsynchronousReadBufferFromHDFS() override;
bool supportsRightBoundedReads() const override;
void setReadUntilPosition(size_t position) override;
void setReadUntilEnd() override;
off_t seek(off_t offset_, int whence) override;
void prefetch(Priority priority) override;

View File

@ -165,6 +165,19 @@ struct ReadBufferFromHDFS::ReadBufferFromHDFSImpl : public BufferWithOwnMemory<S
return file_offset;
}
bool supportsRightBoundedReads() const override { return true; }
void setReadUntilPosition(size_t position) override
{
read_until_position = position;
}
void setReadUntilEnd() override
{
read_until_position = 0;
}
size_t pread(char * buffer, size_t size, size_t offset)
{
ResourceGuard rlock(ResourceGuard::Metrics::getIORead(), read_settings.io_scheduling.read_resource_link, size);
@ -284,6 +297,21 @@ bool ReadBufferFromHDFS::supportsReadAt()
return true;
}
bool ReadBufferFromHDFS::supportsRightBoundedReads() const
{
return impl->supportsRightBoundedReads();
}
void ReadBufferFromHDFS::setReadUntilPosition(size_t position)
{
impl->setReadUntilPosition(position);
}
void ReadBufferFromHDFS::setReadUntilEnd()
{
impl->setReadUntilEnd();
}
}
#endif

View File

@ -34,6 +34,12 @@ public:
~ReadBufferFromHDFS() override;
bool supportsRightBoundedReads() const override;
void setReadUntilPosition(size_t position) override;
void setReadUntilEnd() override;
bool nextImpl() override;
off_t seek(off_t offset_, int whence) override;