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


##########
be/src/io/fs/hdfs_file_system.h:
##########
@@ -88,9 +88,7 @@ class HdfsFileSystem final : public RemoteFileSystem {
                    RuntimeProfile* profile, std::string root_path);
     const THdfsParams& _hdfs_params; // Only used in init, so we can use 
reference here
     std::string _fs_name;
-    // do not use std::shared_ptr or std::unique_ptr
-    // _fs_handle is managed by HdfsFileSystemCache
-    HdfsHandler* _fs_handle = nullptr;
+    std::shared_ptr<HdfsHandler> _fs_handle = nullptr;

Review Comment:
   
   ```suggestion
       std::shared_ptr<HdfsHandler> _fs_handle;
   ```
   可以不用显式写 = nullptr,智能指针默认初始化都是 nullptr



##########
be/src/io/fs/hdfs_file_writer.cpp:
##########
@@ -45,7 +45,7 @@ bvar::Adder<uint64_t> 
hdfs_file_being_written("hdfs_file_writer_file_being_writt
 
 static constexpr size_t MB = 1024 * 1024;
 
-HdfsFileWriter::HdfsFileWriter(Path path, HdfsHandler* handler, hdfsFile 
hdfs_file,
+HdfsFileWriter::HdfsFileWriter(Path path, std::shared_ptr<HdfsHandler> 
handler, hdfsFile hdfs_file,
                                std::string fs_name, const FileWriterOptions* 
opts)
         : _path(std::move(path)),
           _hdfs_handler(handler),

Review Comment:
       ditto:
       return std::make_unique<HdfsFileWriter>(std::move(path), 
std::move(handler), hdfs_file, fs_name, opts);
   



##########
be/src/io/hdfs_util.cpp:
##########
@@ -129,12 +129,12 @@ Status HdfsHandlerCache::get_connection(const 
THdfsParams& hdfs_params, const st
             _clean_oldest();
         }
         if (_cache.size() < MAX_CACHE_HANDLE) {
-            std::unique_ptr<HdfsHandler> handle = 
std::make_unique<HdfsHandler>(hdfs_fs, true);
+            std::shared_ptr<HdfsHandler> handle = 
std::make_shared<HdfsHandler>(hdfs_fs, true);

Review Comment:
   
   ```suggestion
               auto handle = std::make_shared<HdfsHandler>(hdfs_fs, true);
   ```



##########
be/src/io/fs/hdfs_file_writer.cpp:
##########
@@ -45,7 +45,7 @@ bvar::Adder<uint64_t> 
hdfs_file_being_written("hdfs_file_writer_file_being_writt
 
 static constexpr size_t MB = 1024 * 1024;
 
-HdfsFileWriter::HdfsFileWriter(Path path, HdfsHandler* handler, hdfsFile 
hdfs_file,
+HdfsFileWriter::HdfsFileWriter(Path path, std::shared_ptr<HdfsHandler> 
handler, hdfsFile hdfs_file,
                                std::string fs_name, const FileWriterOptions* 
opts)
         : _path(std::move(path)),
           _hdfs_handler(handler),

Review Comment:
   
   ```suggestion
             _hdfs_handler(std::move(handler)),
   ```



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