You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/07/16 12:33:57 UTC

[GitHub] [doris] platoneko commented on a diff in pull request #10896: [Enhancement] Use shared file reader when read a segment

platoneko commented on code in PR #10896:
URL: https://github.com/apache/doris/pull/10896#discussion_r922675498


##########
be/src/io/fs/local_file_system.cpp:
##########
@@ -56,28 +47,16 @@ Status LocalFileSystem::create_file(const Path& path, std::unique_ptr<FileWriter
     return Status::OK();
 }
 
-Status LocalFileSystem::open_file(const Path& path, std::unique_ptr<FileReader>* reader) {
+Status LocalFileSystem::open_file(const Path& path, FileReaderPtr* reader) {
     auto fs_path = absolute_path(path);
-    std::shared_ptr<OpenedFileHandle<int>> file_handle(new OpenedFileHandle<int>());
-    bool found = _file_cache->lookup(fs_path.native(), file_handle.get());
-    if (!found) {
-        int fd = -1;
-        RETRY_ON_EINTR(fd, open(fs_path.c_str(), O_RDONLY));
-        if (fd < 0) {
-            return Status::IOError(
-                    fmt::format("cannot open {}: {}", fs_path.native(), std::strerror(errno)));
-        }
-        int* p_fd = new int(fd);
-        _file_cache->insert(fs_path.native(), p_fd, file_handle.get(),
-                            [](const CacheKey& key, void* value) {
-                                auto fd = reinterpret_cast<int*>(value);
-                                ::close(*fd);
-                                delete fd;
-                            });
-    }
     size_t fsize = 0;
     RETURN_IF_ERROR(file_size(fs_path, &fsize));
-    *reader = std::make_unique<LocalFileReader>(std::move(fs_path), fsize, std::move(file_handle));
+    int fd = -1;
+    RETRY_ON_EINTR(fd, open(fs_path.c_str(), O_RDONLY));
+    if (fd < 0) {
+        return Status::IOError("cannot open {}: {}", fs_path.native(), std::strerror(errno));
+    }
+    *reader = std::make_unique<LocalFileReader>(std::move(fs_path), fsize, fd);

Review Comment:
   I will fix it soon.



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org