yiguolei commented on a change in pull request #1976: And multi-path in 
RowsetGraph
URL: https://github.com/apache/incubator-doris/pull/1976#discussion_r334338106
 
 

 ##########
 File path: be/src/olap/tablet.cpp
 ##########
 @@ -1134,4 +950,42 @@ OLAPStatus 
Tablet::generate_tablet_meta_copy(TabletMetaSharedPtr new_tablet_meta
     return OLAP_SUCCESS;
 }
 
+OLAPStatus Tablet::capture_unused_rowsets() {
+    Version max_version_before_hole;
+    VersionHash v_hash;
+
+    WriteLock wrlock(&_meta_lock);
+    
RETURN_NOT_OK(max_continuous_version_from_begining_unlock(&max_version_before_hole,
 &v_hash));
+
+    std::vector<Version> shortest_version_path;
+    RETURN_NOT_OK(_rs_graph.capture_consistent_versions(Version(0, 
max_version_before_hole.second), &shortest_version_path));
+
+    std::vector<std::pair<Version, RowsetSharedPtr>> rowsets_to_remove;
+    for (auto& it : _rs_version_map) {
+        if (it.second->start_version() > max_version_before_hole.second) {
+            // There are only one path after hole in versions.
+            continue;
+        }
+        bool in_path = false;
+        for (auto& version : shortest_version_path) {
+            if (it.second->start_version() == version.first
+                && it.second->end_version() == version.second) {
+                in_path = true;
+                break;
+            }
+        }
+        if (!in_path) {
+            rowsets_to_remove.emplace_back(std::make_pair(it.first, 
it.second));
+        }
+    }
+
+    for (auto& pair : rowsets_to_remove) {
+        _rs_version_map.erase(pair.first);
+        _tablet_meta->delete_rs_meta_by_version(pair.first, nullptr);
+        StorageEngine::instance()->add_unused_rowset(pair.second);
+    }
+    RETURN_NOT_OK(save_meta());
 
 Review comment:
   should clone a new tablet meta and using this meta to delete rs metas. If 
save successfully, then change cur tablet meta.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to