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


##########
be/src/vec/sink/delta_writer_v2_pool.cpp:
##########
@@ -32,10 +32,15 @@ DeltaWriterV2Map::~DeltaWriterV2Map() = default;
 
 DeltaWriterV2* DeltaWriterV2Map::get_or_create(
         int64_t tablet_id, std::function<std::unique_ptr<DeltaWriterV2>()> 
creator) {
-    _map.lazy_emplace(tablet_id, [&](const 
TabletToDeltaWriterV2Map::constructor& ctor) {
-        ctor(tablet_id, creator());
-    });
-    return _map.at(tablet_id).get();
+    DeltaWriterV2* delta_writer = nullptr;
+    _map.lazy_emplace_l(
+            tablet_id, [&](auto& entry) { delta_writer = entry.second.get(); },
+            [&](const TabletToDeltaWriterV2Map::constructor& ctor) {
+                auto writer = creator();
+                delta_writer = writer.get();
+                ctor(tablet_id, std::move(writer));
+            });
+    return delta_writer;

Review Comment:
   save a shared ptr in the map, not use unique ptr since it is shared among 
writers.



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