zxealous commented on code in PR #12165:
URL: https://github.com/apache/doris/pull/12165#discussion_r958029282


##########
be/src/io/cache/sub_file_cache.cpp:
##########
@@ -153,27 +153,41 @@ Status SubFileCache::_generate_cache_reader(size_t 
offset, size_t req_size) {
                     LOG(INFO) << "Download cache file from remote file: "
                               << _remote_file_reader->path().native() << " -> "
                               << cache_file.native();
-                    std::unique_ptr<char[]> file_buf(new char[req_size]);
-                    Slice file_slice(file_buf.get(), req_size);
-                    size_t bytes_read = 0;
-                    RETURN_NOT_OK_STATUS_WITH_WARN(
-                            _remote_file_reader->read_at(offset, file_slice, 
&bytes_read),
-                            fmt::format("read remote file failed. {}. offset: 
{}, size: {}",
-                                        _remote_file_reader->path().native(), 
offset, req_size));
-                    if (bytes_read != req_size) {
-                        LOG(ERROR) << "read remote file failed: "
-                                   << _remote_file_reader->path().native()
-                                   << ", bytes read: " << bytes_read
-                                   << " vs file size: " << 
_remote_file_reader->size();
-                        return Status::OLAPInternalError(OLAP_ERR_OS_ERROR);
-                    }
                     io::FileWriterPtr file_writer;
                     RETURN_NOT_OK_STATUS_WITH_WARN(
                             
io::global_local_filesystem()->create_file(cache_file, &file_writer),
                             fmt::format("Create local cache file failed: {}", 
cache_file.native()));
-                    RETURN_NOT_OK_STATUS_WITH_WARN(
-                            file_writer->append(file_slice),
-                            fmt::format("Write local cache file failed: {}", 
cache_file.native()));
+                    char* file_buf = 
ExecEnv::GetInstance()->get_download_cache_buf(
+                            
ExecEnv::GetInstance()->get_serial_download_cache_thread_token());
+                    size_t count_bytes_read = 0;
+                    size_t sub_req_size = config::download_cache_buffer_size;
+                    while (count_bytes_read < req_size) {
+                        if (req_size - count_bytes_read < 
config::download_cache_buffer_size) {

Review Comment:
   done



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