gavinchou commented on code in PR #31214: URL: https://github.com/apache/doris/pull/31214#discussion_r1497119056
########## be/src/io/fs/file_system.h: ########## @@ -64,6 +65,43 @@ struct FileInfo { bool is_file; }; +struct FsListGenerator { + FsListGenerator() = default; + virtual ~FsListGenerator() = default; + + virtual Status init() = 0; + + Result<FileInfo> next() { + generateNext(); + if (st.ok()) { + return std::move(file_info); + } + return ResultError(std::move(st)); + } + + Status files(std::vector<FileInfo>* files) { + while (has_next()) { + auto result = next(); + if (!result.has_value()) { + return std::move(result.error()); + } + files->emplace_back(result.value()); + } + return Status::OK(); + } + + virtual bool has_next() const = 0; + +private: + virtual void generateNext() = 0; + +protected: + FileInfo file_info; Review Comment: what's this for ? cache? ########## be/src/io/fs/file_system.h: ########## @@ -64,6 +65,43 @@ struct FileInfo { bool is_file; }; +struct FsListGenerator { + FsListGenerator() = default; + virtual ~FsListGenerator() = default; + + virtual Status init() = 0; + + Result<FileInfo> next() { Review Comment: just make it pure virtual and eliminate `generageNext()`, calling it here is not a good design. ########## be/src/io/fs/file_system.h: ########## @@ -64,6 +65,43 @@ struct FileInfo { bool is_file; }; +struct FsListGenerator { Review Comment: class? and, an interface/base class should always have sufficient and clear comments for all the functions. consider naming FsListGenerator -> FileListIterator ? ########## be/src/io/fs/file_system.h: ########## @@ -64,6 +65,43 @@ struct FileInfo { bool is_file; }; +struct FsListGenerator { + FsListGenerator() = default; + virtual ~FsListGenerator() = default; + + virtual Status init() = 0; Review Comment: what is init() for? subclass should be initialized when it is created, we dont need to call baseclass.init(). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org