From 42c7383a126bd6293d7b09584d859eae1ea25435 Mon Sep 17 00:00:00 2001 From: taiyang-li <654010905@qq.com> Date: Mon, 11 Nov 2024 16:19:52 +0800 Subject: [PATCH] support supportsRightBoundedReads for ReadBufferFromHDFS and AsynchronousReadBufferFromHDFS --- .../HDFS/AsynchronousReadBufferFromHDFS.cpp | 15 ++++++++++ .../HDFS/AsynchronousReadBufferFromHDFS.h | 6 ++++ .../ObjectStorage/HDFS/ReadBufferFromHDFS.cpp | 28 +++++++++++++++++++ .../ObjectStorage/HDFS/ReadBufferFromHDFS.h | 6 ++++ 4 files changed, 55 insertions(+) diff --git a/src/Storages/ObjectStorage/HDFS/AsynchronousReadBufferFromHDFS.cpp b/src/Storages/ObjectStorage/HDFS/AsynchronousReadBufferFromHDFS.cpp index 5f57a4714f1..792c9384e10 100644 --- a/src/Storages/ObjectStorage/HDFS/AsynchronousReadBufferFromHDFS.cpp +++ b/src/Storages/ObjectStorage/HDFS/AsynchronousReadBufferFromHDFS.cpp @@ -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 diff --git a/src/Storages/ObjectStorage/HDFS/AsynchronousReadBufferFromHDFS.h b/src/Storages/ObjectStorage/HDFS/AsynchronousReadBufferFromHDFS.h index 9846d74453b..c1112157985 100644 --- a/src/Storages/ObjectStorage/HDFS/AsynchronousReadBufferFromHDFS.h +++ b/src/Storages/ObjectStorage/HDFS/AsynchronousReadBufferFromHDFS.h @@ -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; diff --git a/src/Storages/ObjectStorage/HDFS/ReadBufferFromHDFS.cpp b/src/Storages/ObjectStorage/HDFS/ReadBufferFromHDFS.cpp index 91cee553d33..e597c84359d 100644 --- a/src/Storages/ObjectStorage/HDFS/ReadBufferFromHDFS.cpp +++ b/src/Storages/ObjectStorage/HDFS/ReadBufferFromHDFS.cpp @@ -165,6 +165,19 @@ struct ReadBufferFromHDFS::ReadBufferFromHDFSImpl : public BufferWithOwnMemorysupportsRightBoundedReads(); +} + +void ReadBufferFromHDFS::setReadUntilPosition(size_t position) +{ + impl->setReadUntilPosition(position); +} + +void ReadBufferFromHDFS::setReadUntilEnd() +{ + impl->setReadUntilEnd(); +} + } #endif diff --git a/src/Storages/ObjectStorage/HDFS/ReadBufferFromHDFS.h b/src/Storages/ObjectStorage/HDFS/ReadBufferFromHDFS.h index 5c9b5d73d58..4a1d74cd628 100644 --- a/src/Storages/ObjectStorage/HDFS/ReadBufferFromHDFS.h +++ b/src/Storages/ObjectStorage/HDFS/ReadBufferFromHDFS.h @@ -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;