chaoyli commented on a change in pull request #596: Add implementation to tablet
URL: https://github.com/apache/incubator-doris/pull/596#discussion_r252130543
 
 

 ##########
 File path: be/src/olap/tablet.cpp
 ##########
 @@ -638,45 +744,213 @@ OLAPStatus Tablet::register_tablet_into_dir() {
     return _data_dir->register_tablet(this);
 }
 
-OLAPStatus Tablet::clear_schema_change_info(
-        AlterTabletType* type,
-        bool only_one,
-        bool check_only) {
-    if (!check_only) {
-        WriteLock w(&_meta_lock);
-        _unprotect_clear_schema_change_info(type, only_one, check_only);
-    } else {
-        ReadLock r(&_meta_lock);
-        _unprotect_clear_schema_change_info(type, only_one, check_only);
+bool Tablet::version_for_delete_predicate(const Version& version) {
+    return _tablet_meta->version_for_delete_predicate(version);
+}
+
+bool Tablet::version_for_load_deletion(const Version& version) {
+    RowsetSharedPtr rowset = _rs_version_map.at(version);
+    return rowset->delete_flag();
+}
+
+const RowsetSharedPtr Tablet::get_rowset_by_version(const Version& version) 
const {
+    RowsetSharedPtr rowset = _rs_version_map.at(version);
+    return rowset;
+}
+
+const RowsetSharedPtr Tablet::rowset_with_max_version() const {
+    Version max_version = _tablet_meta->max_version();
+    RowsetSharedPtr rowset = _rs_version_map.at(max_version);
+    return rowset;
+}
+
+std::string Tablet::storage_root_path_name() const {
+    return _data_dir->path();
+}
+
+std::string Tablet::tablet_path() const {
+    return _tablet_path;
+}
+
+const uint32_t Tablet::calc_cumulative_compaction_score() const {
+    uint32_t score = 0;
+    bool base_rowset_exist = false;
+    const int32_t point = cumulative_layer_point();
+    for (auto& rs_meta : _tablet_meta->all_rs_metas()) {
+        if (rs_meta->start_version() >= point) {
+            score++;
+        }
+        if (rs_meta->start_version() == 0) {
+            base_rowset_exist = true;
+        }
     }
-    return OLAP_SUCCESS;
+
+    // base不存在可能是tablet正在做alter table,先不选它,设score=0
+    return base_rowset_exist ? score : 0;
 }
 
-OLAPStatus Tablet::_unprotect_clear_schema_change_info(
-        AlterTabletType* type,
-        bool only_one,
-        bool check_only) {
-    OLAPStatus res = OLAP_SUCCESS;
+const uint32_t Tablet::calc_base_compaction_score() const {
+    uint32_t score = 0;
+    const int32_t point = cumulative_layer_point();
+    bool base_rowset_exist = false;
+    for (auto& rs_meta : _tablet_meta->all_rs_metas()) {
+        if (rs_meta->start_version() < point) {
+            score++;
+        }
+        if (rs_meta->start_version() == 0) {
+            base_rowset_exist = true;
+        }
+    }
+    score = score < config::base_compaction_num_cumulative_deltas ? 0 : score;
 
-    vector<Version> versions_to_be_changed;
-    if (this->get_schema_change_request(NULL,
-                                              NULL,
-                                              &versions_to_be_changed,
-                                              NULL)) {
-        if (versions_to_be_changed.size() != 0) {
-            OLAP_LOG_WARNING("schema change is not allowed now, "
-                             "until previous schema change is done. 
[tablet='%s']",
-                             full_name().c_str());
-            return OLAP_ERR_PREVIOUS_SCHEMA_CHANGE_NOT_FINISHED;
+    // base不存在可能是tablet正在做alter table,先不选它,设score=0
+    return base_rowset_exist ? score : 0;
+}
+
+bool Tablet::has_expired_incremental_rowset() {
+    bool exist = false;
+    time_t now = time(NULL);
+    ReadLock rdlock(&_meta_lock);
+    for (auto& rs_meta : _tablet_meta->all_inc_rs_metas()) {
+        double diff = difftime(now, rs_meta->creation_time());
 
 Review comment:
   Order by creation_time will lose the order property of version 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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