github-actions[bot] commented on code in PR #31214: URL: https://github.com/apache/doris/pull/31214#discussion_r1502692302
########## be/src/io/fs/hdfs_file_system.cpp: ########## @@ -261,13 +266,42 @@ Status HdfsFileSystem::file_size_impl(const Path& path, int64_t* file_size) cons return Status::OK(); } -Status HdfsFileSystem::list_impl(const Path& path, bool only_file, std::vector<FileInfo>* files, - bool* exists) { - RETURN_IF_ERROR(exists_impl(path, exists)); - if (!(*exists)) { - return Status::OK(); +struct HdfsFileListIterator final : public FileListIterator { +public: + HdfsFileListIterator(int numEntries, hdfsFileInfo* hdfs_file_info, bool only_file) + : numEntries(numEntries), + hdfs_file_info(hdfs_file_info), + only_file(only_file), + idx(0) {} + ~HdfsFileListIterator() override { hdfsFreeFileInfo(hdfs_file_info, numEntries); } + + bool has_next() const override { return idx < numEntries; } + +private: + Result<FileInfo> next() override { + FileInfo file_info; + for (; idx < numEntries; idx++) { + auto& file = hdfs_file_info[idx]; + if (only_file && file.mKind == kObjectKindDirectory) { + continue; + } + file_info.file_name = file.mName; + file_info.file_size = file.mSize; + file_info.is_file = (file.mKind != kObjectKindDirectory); + break; + } + return file_info; } + int numEntries; + hdfsFileInfo* hdfs_file_info; + bool only_file; + size_t idx; Review Comment: warning: use default member initializer for 'idx' [modernize-use-default-member-init] be/src/io/fs/hdfs_file_system.cpp:274: ```diff - idx(0) {} + {} ``` ```suggestion size_t idx{0}; ``` -- 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