acelyc111 commented on code in PR #2077:
URL: 
https://github.com/apache/incubator-pegasus/pull/2077#discussion_r1773068160


##########
src/replica/bulk_load/replica_bulk_loader.cpp:
##########
@@ -585,22 +599,17 @@ void replica_bulk_loader::download_sst_file(const 
std::string &remote_dir,
         return;
     }
     // download file succeed, update progress
+    download_file_metas.pop_back();
     update_bulk_load_download_progress(f_size, f_meta.name);
     METRIC_VAR_INCREMENT(bulk_load_download_file_successful_count);
     METRIC_VAR_INCREMENT_BY(bulk_load_download_file_bytes, f_size);
 
     // download next file
-    if (file_index + 1 < _metadata.files.size()) {
-        const file_meta &next_f_meta = _metadata.files[file_index + 1];
-        _download_files_task[next_f_meta.name] =
-            tasking::enqueue(LPC_BACKGROUND_BULK_LOAD,
-                             tracker(),
-                             std::bind(&replica_bulk_loader::download_sst_file,
-                                       this,
-                                       remote_dir,
-                                       local_dir,
-                                       file_index + 1,
-                                       fs));
+    if (!download_file_metas.empty()) {
+        _download_files_task[download_file_metas.back().name] = 
tasking::enqueue(
+            LPC_BACKGROUND_BULK_LOAD, tracker(), [=, file_metas = 
download_file_metas]() mutable {

Review Comment:
   Why introduce `file_metas`?



##########
src/replica/bulk_load/replica_bulk_loader.cpp:
##########
@@ -519,22 +521,34 @@ void replica_bulk_loader::download_files(const 
std::string &provider_name,
     }
 
     // download sst files asynchronously
-    if (!_metadata.files.empty()) {
-        const file_meta &f_meta = _metadata.files[0];
-        _download_files_task[f_meta.name] = tasking::enqueue(
-            LPC_BACKGROUND_BULK_LOAD,
-            tracker(),
-            std::bind(&replica_bulk_loader::download_sst_file, this, 
remote_dir, local_dir, 0, fs));
+    std::vector<::dsn::replication::file_meta> download_file_metas;
+    {
+        zauto_read_lock l(_lock);
+        std::copy(_metadata.files.begin(),
+                  _metadata.files.end(),
+                  std::back_inserter(download_file_metas));

Review Comment:
   Why do it like this, doesn't it equal to `download_file_metas = 
_metadata.files` ?



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