dataroaring commented on code in PR #53908:
URL: https://github.com/apache/doris/pull/53908#discussion_r2285512790


##########
be/src/cloud/cloud_meta_mgr.cpp:
##########
@@ -1384,15 +1690,108 @@ Status CloudMetaMgr::update_delete_bitmap(const 
CloudTablet& tablet, int64_t loc
     if (next_visible_version > 0) {
         req.set_next_visible_version(next_visible_version);
     }
-    for (auto& [key, bitmap] : delete_bitmap->delete_bitmap) {
-        req.add_rowset_ids(std::get<0>(key).to_string());
-        req.add_segment_ids(std::get<1>(key));
-        req.add_versions(std::get<2>(key));
-        // To save space, convert array and bitmap containers to run containers
-        bitmap.runOptimize();
-        std::string bitmap_data(bitmap.getSizeInBytes(), '\0');
-        bitmap.write(bitmap_data.data());
-        *(req.add_segment_delete_bitmaps()) = std::move(bitmap_data);
+
+    bool write_v1 =
+            config::delete_bitmap_store_version == 1 || 
config::delete_bitmap_store_version == 3;
+    bool write_v2 = config::delete_bitmap_store_version >= 2;
+    // write v1 kvs
+    if (write_v1) {
+        for (auto& [key, bitmap] : delete_bitmap->delete_bitmap) {
+            req.add_rowset_ids(std::get<0>(key).to_string());
+            req.add_segment_ids(std::get<1>(key));
+            req.add_versions(std::get<2>(key));
+            // To save space, convert array and bitmap containers to run 
containers
+            bitmap.runOptimize();
+            std::string bitmap_data(bitmap.getSizeInBytes(), '\0');
+            bitmap.write(bitmap_data.data());
+            *(req.add_segment_delete_bitmaps()) = std::move(bitmap_data);
+        }
+    }
+
+    // write v2 kvs
+    if (write_v2) {
+        // TODO skip update if delete bitmap is empty
+        //  it's ok for compaction and schema change, but for load, ms check 
partition version
+        auto add_delete_bitmap = [](DeleteBitmapPB& delete_bitmap_pb,
+                                    const DeleteBitmap::BitmapKey& key, 
roaring::Roaring& bitmap) {
+            delete_bitmap_pb.add_rowset_ids(std::get<0>(key).to_string());
+            delete_bitmap_pb.add_segment_ids(std::get<1>(key));
+            delete_bitmap_pb.add_versions(std::get<2>(key));
+            // To save space, convert array and bitmap containers to run 
containers
+            bitmap.runOptimize();
+            std::string bitmap_data(bitmap.getSizeInBytes(), '\0');
+            bitmap.write(bitmap_data.data());
+            *(delete_bitmap_pb.add_segment_delete_bitmaps()) = 
std::move(bitmap_data);
+        };

Review Comment:
   duplicated code as 1700-1707.



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