morningman commented on a change in pull request #2558: [Compaction] Support 
compact only one rowset
URL: https://github.com/apache/incubator-doris/pull/2558#discussion_r361415178
 
 

 ##########
 File path: be/src/olap/rowset/rowset_meta.h
 ##########
 @@ -309,6 +309,49 @@ class RowsetMeta {
         return _is_removed_from_rowset_meta;
     }
 
+    SegmentsOverlapPB segments_overlap() const {
+        return _rowset_meta_pb.segments_overlap_pb();
+    }
+
+    void set_segments_overlap(SegmentsOverlapPB segments_overlap) {
+        _rowset_meta_pb.set_segments_overlap_pb(segments_overlap);
+    }
+
+    // return if segments in this rowset has overlapping data.
+    // this is not same as `segments_overlap()` method.
+    // `segments_overlap()` only return the value of "segments_overlap" field 
in rowset meta,
+    // but "segments_overlap" may be UNKNOWN.
+    // so segments overlapping is defined as
+    // 1. if end version > start version, which means this rowset is generated 
by compaction process,
+    //    so the segments in it are non overlapping.
+    // 2. the segments_overlap() flag in rowset meta is set to NONOVERLAPPING, 
explicitly.
+    bool is_segments_overlapping() const {
+        if (num_segments() == 0) {
+            // specially for delete version
+            return false;
+        }
+        if (end_version() > start_version() || segments_overlap() == 
NONOVERLAPPING) {
+            return false;
+        }
+        return true;
+    }
+
+    // get the compaction score of this rowset.
+    // if segments are overlapping, the score equals to the number of segments,
+    // otherwise, score is 1.
+    uint32_t get_compaction_score() const {
+        uint32_t score = 0;
+        if (!is_segments_overlapping()) {
+            score = 1;
+        } else {
+            // if this is a delete version, num_segments() will be 0.
+            // so set at least 1 to avoid return 0.
+            score = num_segments() == 0 ? 1 : num_segments();
 
 Review comment:
   ok

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