github-actions[bot] commented on code in PR #26050:
URL: https://github.com/apache/doris/pull/26050#discussion_r1375184248


##########
be/src/io/fs/broker_file_system.cpp:
##########
@@ -465,10 +465,74 @@ Status BrokerFileSystem::direct_download_impl(const Path& 
remote_file, std::stri
     return Status::OK();
 }
 
-Status BrokerFileSystem::get_client(std::shared_ptr<BrokerServiceConnection>* 
client) const {
-    CHECK_BROKER_CLIENT(_client);
-    *client = _client;
-    return Status::OK();
+Status BrokerFileSystem::read_file(const TBrokerFD& fd, size_t offset, size_t 
bytes_req,
+                                   std::string* data) const {
+    if (data == nullptr) {
+        return Status::InvalidArgument("data should be not null");
+    }
+    CHECK_BROKER_CLIENT(_connection);
+    TBrokerPReadRequest request;
+    request.__set_version(TBrokerVersion::VERSION_ONE);
+    request.__set_fd(fd);
+    request.__set_offset(offset);
+    request.__set_length(bytes_req);
+
+    TBrokerReadResponse response;
+    try {
+        VLOG_RPC << "send pread request to broker:" << _broker_addr << " 
position:" << offset
+                 << ", read bytes length:" << bytes_req;
+        try {
+            (*_connection)->pread(response, request);
+        } catch (apache::thrift::transport::TTransportException& e) {
+            std::this_thread::sleep_for(std::chrono::seconds(1));
+            RETURN_IF_ERROR((*_connection).reopen());
+            LOG(INFO) << "retry reading from broker: " << _broker_addr << ". 
reason: " << e.what();
+            (*_connection)->pread(response, request);
+        }
+    } catch (apache::thrift::TException& e) {
+        std::stringstream ss;
+        ss << "read broker file failed, broker:" << _broker_addr << " failed:" 
<< e.what();
+        return Status::RpcError(ss.str());
+    }
+
+    if (response.opStatus.statusCode == 
TBrokerOperationStatusCode::END_OF_FILE) {
+        // read the end of broker's file
+        return Status::OK();
+    } else if (response.opStatus.statusCode != TBrokerOperationStatusCode::OK) 
{
+        std::stringstream ss;
+        ss << "Open broker reader failed, broker:" << _broker_addr
+           << " failed:" << response.opStatus.message;
+        return Status::InternalError(ss.str());
+    }

Review Comment:
   warning: do not use 'else' after 'return' [readability-else-after-return]
   
   ```suggestion
       } if (response.opStatus.statusCode != TBrokerOperationStatusCode::OK) {
           std::stringstream ss;
           ss << "Open broker reader failed, broker:" << _broker_addr
              << " failed:" << response.opStatus.message;
           return Status::InternalError(ss.str());
       }
   ```
   



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