yiguolei commented on a change in pull request #1576: Change cumulative 
compaction for decoupling storage from compution
URL: https://github.com/apache/incubator-doris/pull/1576#discussion_r310458254
 
 

 ##########
 File path: be/src/olap/cumulative_compaction.cpp
 ##########
 @@ -32,356 +32,121 @@ using std::vector;
 
 namespace doris {
 
-OLAPStatus CumulativeCompaction::init(TabletSharedPtr tablet) {
-    LOG(INFO) << "init cumulative compaction handler. tablet=" << 
tablet->full_name();
+static bool rowset_comparator(const RowsetSharedPtr& left, const 
RowsetSharedPtr& right) {
+    return left->end_version() < right->end_version();
+}
+
+CumulativeCompaction::CumulativeCompaction(TabletSharedPtr tablet)
+    : _tablet(tablet),
+      
_cumulative_rowset_size_threshold(config::cumulative_compaction_budgeted_bytes),
+      _input_rowsets_size(0),
+      _input_row_num(0),
+      _cumulative_state(CumulativeState::FAILED)
+    { }
 
-    if (_is_init) {
-        LOG(WARNING) << "cumulative handler has been inited. tablet=" << 
tablet->full_name();
-        return OLAP_ERR_CUMULATIVE_REPEAT_INIT;
+CumulativeCompaction::~CumulativeCompaction() {
+    if (_cumulative_locked) {
+        _tablet->release_cumulative_lock();
     }
+}
 
-    if (!tablet->init_succeeded()) {
+OLAPStatus CumulativeCompaction::compact() {
+    if (!_tablet->init_succeeded()) {
         return OLAP_ERR_CUMULATIVE_INVALID_PARAMETERS;
     }
 
-    _tablet = tablet;
-    _max_delta_file_size = config::cumulative_compaction_budgeted_bytes;
-
     if (!_tablet->try_cumulative_lock()) {
-        LOG(INFO) << "skip compaction, because another cumulative is running. 
tablet=" << _tablet->full_name();
+        LOG(INFO) << "The tablet is under cumulative compaction. tablet=" << 
_tablet->full_name();
         return OLAP_ERR_CE_TRY_CE_LOCK_ERROR;
     }
 
-    _tablet->obtain_header_rdlock();
-    _old_cumulative_layer_point = _tablet->cumulative_layer_point();
-    _tablet->release_header_lock();
-    // 如果为-1,则该table之前没有设置过cumulative layer point
-    // 我们在这里设置一下
-    if (_old_cumulative_layer_point == -1) {
-        LOG(INFO) << "tablet has an unreasonable cumulative layer point. 
tablet=" << _tablet->full_name()
-                  << ", cumulative_layer_point=" << 
_old_cumulative_layer_point;
-        _tablet->release_cumulative_lock();
-        return OLAP_ERR_CUMULATIVE_INVALID_PARAMETERS;
-    }
+    _cumulative_locked = true;
 
 Review comment:
   Use scoped lock here

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org
For additional commands, e-mail: dev-h...@doris.apache.org

Reply via email to