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


##########
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:
   reader is shared ptr? why call make unique here?



-- 
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

Reply via email to