yiguolei commented on code in PR #52879:
URL: https://github.com/apache/doris/pull/52879#discussion_r2194357151


##########
be/src/pipeline/exec/olap_scan_operator.cpp:
##########
@@ -450,55 +449,72 @@ Status 
OlapScanLocalState::_init_scanners(std::list<vectorized::ScannerSPtr>* sc
     return Status::OK();
 }
 
-Status OlapScanLocalState::hold_tablets() {
-    if (!_tablets.empty()) {
+Status OlapScanLocalState::sync_cloud_tablets(RuntimeState* state) {
+    if (config::is_cloud_mode() && !_sync_tablet) {
+        _cloud_tablet_dependencies.resize(_scan_ranges.size());
+        for (size_t i = 0; i < _scan_ranges.size(); i++) {
+            _cloud_tablet_dependencies[i] =
+                    Dependency::create_shared(_parent->operator_id(), 
_parent->node_id(),
+                                              "CLOUD_TABLET_DEP_" + 
std::to_string(i));
+        }
+
+        _tablets.resize(_scan_ranges.size());
+        _tasks.reserve(_scan_ranges.size());
+        _sync_statistics.resize(_scan_ranges.size());
+        SCOPED_RAW_TIMER(&_duration_ns);
+        for (size_t i = 0; i < _scan_ranges.size(); i++) {
+            auto* sync_stats = &_sync_statistics[i];
+            int64_t version = 0;
+            std::from_chars(_scan_ranges[i]->version.data(),
+                            _scan_ranges[i]->version.data() + 
_scan_ranges[i]->version.size(),
+                            version);
+            auto task_ctx = state->get_task_execution_context();
+            _tasks.emplace_back([this, sync_stats, version, i, task_ctx]() {
+                auto task_lock = task_ctx.lock();
+                if (task_lock == nullptr) {
+                    return Status::OK();
+                }
+                Defer defer([&] { 
this->_cloud_tablet_dependencies[i]->set_ready(); });

Review Comment:
   用一个atomic 记录一下总数,如果都结束了,再设置一下depdency ready



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