adonis0147 commented on code in PR #9505:
URL: https://github.com/apache/incubator-doris/pull/9505#discussion_r870921127


##########
be/src/exec/file/file_factory.h:
##########
@@ -0,0 +1,74 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+#pragma once
+
+#include "gen_cpp/Types_types.h"
+#include "gen_cpp/PlanNodes_types.h"
+#include "file_reader.h"
+#include "file_writer.h"
+
+namespace doris {
+class ExecEnv;
+class TNetworkAddress;
+
+class FileFactory {
+public:
+    static Status create_file_writer(TFileType::type type, ExecEnv* env,
+                                     const std::vector<TNetworkAddress>& 
broker_addresses,
+                                     const std::map<std::string, std::string>& 
properties,
+                                     const std::string& path, int64_t 
start_offset,
+                                     std::unique_ptr<FileWriter>& file_writer);
+
+    // Because StreamLoadPipe use std::shared_ptr, here we have to support 
both unique_ptr
+    // and shared_ptr create_file_reader
+    static Status create_file_reader(TFileType::type type, ExecEnv* env,
+                                     const std::vector<TNetworkAddress>& 
broker_addresses,
+                                     const std::map<std::string, std::string>& 
properties,
+                                     const TBrokerRangeDesc& range, int64_t 
start_offset,
+                                     std::unique_ptr<FileReader>& file_reader);
+
+    static Status create_file_reader(TFileType::type type, ExecEnv* env,
+                                     const std::vector<TNetworkAddress>& 
broker_addresses,
+                                     const std::map<std::string, std::string>& 
properties,
+                                     const TBrokerRangeDesc& range, int64_t 
start_offset,
+                                     std::shared_ptr<FileReader>& file_reader);
+
+    static TFileType::type convert_storage_type(TStorageBackendType::type 
type) {
+        switch (type) {
+        case TStorageBackendType::LOCAL:
+            return TFileType::FILE_LOCAL;
+        case TStorageBackendType::S3:
+            return TFileType::FILE_S3;
+        case TStorageBackendType::BROKER:
+            return TFileType::FILE_BROKER;
+        case TStorageBackendType::HDFS:
+            return TFileType::FILE_HDFS;
+        default:
+            LOG(FATAL) << "not match type to convert, from type:" << type;
+        }
+        __builtin_unreachable();
+    }
+
+private:
+    static Status _new_file_reader(TFileType::type type, ExecEnv* env,
+                                   const std::vector<TNetworkAddress>& 
broker_addresses,
+                                   const std::map<std::string, std::string>& 
properties,
+                                   const TBrokerRangeDesc& range, int64_t 
start_offset,
+                                   FileReader*& file_reader);

Review Comment:
   I think there are two roles of users:
   1. Ones who use the class.
   2. Ones who develop the class.
   
   It's ok for the users who using the class here due to the accessibility. 
However, for the ones who will modify the class, they should jump into the 
definition detail to figure the ownership out. That is inconvenient.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to