chaoyli closed pull request #508: Compile cancel delete task
URL: https://github.com/apache/incubator-doris/pull/508
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/be/src/olap/delete_handler.cpp b/be/src/olap/delete_handler.cpp
index d930fbb1..0e33726c 100644
--- a/be/src/olap/delete_handler.cpp
+++ b/be/src/olap/delete_handler.cpp
@@ -63,7 +63,7 @@ string DeleteConditionHandler::construct_sub_conditions(const 
TCondition& condit
 
 // 删除指定版本号的删除条件;需要注意的是,如果table上没有任何删除条件,或者
 // 指定版本号的删除条件不存在,也会返回OLAP_SUCCESS。
-OLAPStatus DeleteConditionHandler::delete_cond(del_cond_array* 
delete_conditions,
+OLAPStatus DeleteConditionHandler::delete_cond(DelPredicateArray* 
delete_conditions,
         const int32_t version,
         bool delete_smaller_version_conditions) {
     if (version < 0) {
@@ -110,7 +110,7 @@ OLAPStatus 
DeleteConditionHandler::delete_cond(del_cond_array* delete_conditions
 }
 
 OLAPStatus DeleteConditionHandler::log_conds(std::string tablet_full_name,
-        const del_cond_array& delete_conditions) {
+        const DelPredicateArray& delete_conditions) {
     LOG(INFO) << "display all delete condition. tablet=" << tablet_full_name;
 
     for (int index = 0; index != delete_conditions.size(); ++index) {
@@ -227,7 +227,7 @@ OLAPStatus 
DeleteConditionHandler::_check_version_valid(std::vector<Version>* al
     }
 }
 
-int DeleteConditionHandler::_check_whether_condition_exist(const 
del_cond_array& delete_conditions, int cond_version) {
+int DeleteConditionHandler::_check_whether_condition_exist(const 
DelPredicateArray& delete_conditions, int cond_version) {
     if (delete_conditions.size() == 0) {
         return -1;
     }
@@ -280,7 +280,7 @@ bool DeleteHandler::_parse_condition(const std::string& 
condition_str, TConditio
 }
 
 OLAPStatus DeleteHandler::init(const RowFields& tablet_schema,
-        const del_cond_array& delete_conditions, int32_t version) {
+        const DelPredicateArray& delete_conditions, int32_t version) {
     if (_is_inited) {
         OLAP_LOG_WARNING("reintialize delete handler.");
         return OLAP_ERR_INIT_FAILED;
@@ -292,7 +292,7 @@ OLAPStatus DeleteHandler::init(const RowFields& 
tablet_schema,
         return OLAP_ERR_DELETE_INVALID_PARAMETERS;
     }
 
-    del_cond_array::const_iterator it = delete_conditions.begin();
+    DelPredicateArray::const_iterator it = delete_conditions.begin();
 
     for (; it != delete_conditions.end(); ++it) {
         // 跳过版本号大于version的过滤条件
diff --git a/be/src/olap/delete_handler.h b/be/src/olap/delete_handler.h
index 33abc1fb..ef2a0267 100644
--- a/be/src/olap/delete_handler.h
+++ b/be/src/olap/delete_handler.h
@@ -30,6 +30,8 @@
 
 namespace doris {
 
+typedef google::protobuf::RepeatedPtrField<DeletePredicatePB> 
DelPredicateArray;
+
 // 实现了删除条件的存储,移除和显示功能
 // *  存储删除条件:
 //    OLAPStatus res;
@@ -47,7 +49,6 @@ namespace doris {
 //    *  在调用log_conds()的时候,只需要加读锁
 class DeleteConditionHandler {
 public:
-    typedef google::protobuf::RepeatedPtrField<DeletePredicatePB> 
del_cond_array;
 
     DeleteConditionHandler() {}
     ~DeleteConditionHandler() {}
@@ -74,7 +75,7 @@ class DeleteConditionHandler {
     //         * 这个表没有指定版本号的删除条件
     //     * OLAP_ERR_DELETE_INVALID_PARAMETERS:函数参数不符合要求
     OLAPStatus delete_cond(
-            del_cond_array* delete_condition, const int32_t version, bool 
delete_smaller_version_conditions);
+            DelPredicateArray* delete_condition, const int32_t version, bool 
delete_smaller_version_conditions);
 
     // 将一个olap engine的表上存有的所有删除条件打印到log中。调用前只需要给Header文件加读锁
     //
@@ -83,7 +84,7 @@ class DeleteConditionHandler {
     // 返回值:
     //     OLAP_SUCCESS:调用成功
     OLAPStatus log_conds(std::string tablet_full_name,
-        const del_cond_array& delete_conditions);
+        const DelPredicateArray& delete_conditions);
 private:
 
     // 检查指定的删除条件版本是否符合要求;
@@ -91,7 +92,7 @@ class DeleteConditionHandler {
     OLAPStatus _check_version_valid(std::vector<Version>* all_file_versions, 
const int32_t filter_version);
 
     // 检查指定版本的删除条件是否已经存在。如果存在,返回指定版本删除条件的数组下标;不存在返回-1
-    int _check_whether_condition_exist(const del_cond_array& 
delete_conditions, int cond_version);
+    int _check_whether_condition_exist(const DelPredicateArray& 
delete_conditions, int cond_version);
 
     int32_t _get_field_index(const RowFields& tablet_schema, const 
std::string& field_name) const {
         for (int i = 0; i < tablet_schema.size(); i++) {
@@ -130,7 +131,6 @@ struct DeleteConditions {
 class DeleteHandler {
 public:
     typedef std::vector<DeleteConditions>::size_type cond_num_t;
-    typedef google::protobuf::RepeatedPtrField<DeletePredicatePB> 
del_cond_array;
 
     DeleteHandler() : _is_inited(false) {}
     ~DeleteHandler() {}
@@ -150,7 +150,7 @@ class DeleteHandler {
     //     * OLAP_ERR_DELETE_INVALID_PARAMETERS: 参数不符合要求
     //     * OLAP_ERR_MALLOC_ERROR: 在填充_del_conds时,分配内存失败
     OLAPStatus init(const RowFields& tablet_schema,
-        const del_cond_array& delete_conditions, int32_t version);
+        const DelPredicateArray& delete_conditions, int32_t version);
 
     // 判定一条数据是否符合删除条件
     //
diff --git a/be/src/olap/task/engine_cancel_delete_task.cpp 
b/be/src/olap/task/engine_cancel_delete_task.cpp
index a48012af..82502bc5 100644
--- a/be/src/olap/task/engine_cancel_delete_task.cpp
+++ b/be/src/olap/task/engine_cancel_delete_task.cpp
@@ -53,7 +53,8 @@ OLAPStatus EngineCancelDeleteTask::_cancel_delete() {
     DeleteConditionHandler cond_handler;
     for (TabletSharedPtr temp_tablet : table_list) {
         temp_tablet->obtain_header_wrlock();
-        res = cond_handler.delete_cond(temp_tablet, _request.version, false);
+        DelPredicateArray* delete_conditions = 
temp_tablet->mutable_delete_predicate();
+        res = cond_handler.delete_cond(delete_conditions, _request.version, 
false);
         if (res != OLAP_SUCCESS) {
             temp_tablet->release_header_lock();
             OLAP_LOG_WARNING("cancel delete failed. [res=%d tablet=%s]",
@@ -73,7 +74,10 @@ OLAPStatus EngineCancelDeleteTask::_cancel_delete() {
 
     // Show delete conditions in tablet header.
     for (TabletSharedPtr tablet : table_list) {
-        cond_handler.log_conds(tablet);
+        tablet->obtain_header_rdlock();
+        const DelPredicateArray& delete_conditions = 
tablet->delete_data_conditions();
+        cond_handler.log_conds(tablet->full_name(), delete_conditions);
+        tablet->release_header_lock();
     }
 
     LOG(INFO) << "finish to process cancel delete. res=" << res;
diff --git a/be/test/olap/delete_handler_test.cpp 
b/be/test/olap/delete_handler_test.cpp
index 481a1eca..818ae03d 100644
--- a/be/test/olap/delete_handler_test.cpp
+++ b/be/test/olap/delete_handler_test.cpp
@@ -200,8 +200,6 @@ class TestDeleteConditionHandler : public testing::Test {
         ASSERT_EQ(OLAP_SUCCESS, remove_all_dir(config::storage_root_path));
     }
 
-    typedef RepeatedPtrField<DeleteConditionMessage> del_cond_array;
-
     std::string _tablet_path;
     TabletSharedPtr tablet;
     TCreateTabletReq _create_tablet;
@@ -236,7 +234,7 @@ TEST_F(TestDeleteConditionHandler, StoreCondSucceed) {
     ASSERT_EQ(OLAP_SUCCESS, push_empty_delta(3));
 
     // 验证存储在header中的过滤条件正确
-    const del_cond_array& delete_conditions = tablet->delete_data_conditions();
+    const DelPredicateArray& delete_conditions = 
tablet->delete_data_conditions();
     ASSERT_EQ(size_t(1), delete_conditions.size());
     EXPECT_EQ(3, delete_conditions.Get(0).version());
     ASSERT_EQ(size_t(3), delete_conditions.Get(0).sub_conditions_size());
@@ -256,7 +254,7 @@ TEST_F(TestDeleteConditionHandler, StoreCondSucceed) {
     ASSERT_EQ(OLAP_SUCCESS, success_res);
 
     // 验证存储相同版本号的过滤条件情况下,新的过滤条件替换掉旧的过滤条件
-    const del_cond_array& new_delete_conditions = 
tablet->delete_data_conditions();
+    const DelPredicateArray& new_delete_conditions = 
tablet->delete_data_conditions();
     ASSERT_EQ(size_t(1), new_delete_conditions.size());
     EXPECT_EQ(3, new_delete_conditions.Get(0).version());
     ASSERT_EQ(size_t(1), new_delete_conditions.Get(0).sub_conditions_size());
@@ -280,7 +278,7 @@ TEST_F(TestDeleteConditionHandler, StoreCondSucceed) {
     ASSERT_EQ(OLAP_SUCCESS, success_res);
     ASSERT_EQ(OLAP_SUCCESS, push_empty_delta(4));
 
-    const del_cond_array& all_delete_conditions = 
tablet->delete_data_conditions();
+    const DelPredicateArray& all_delete_conditions = 
tablet->delete_data_conditions();
     ASSERT_EQ(size_t(2), all_delete_conditions.size());
     EXPECT_EQ(3, all_delete_conditions.Get(0).version());
     ASSERT_EQ(size_t(1), all_delete_conditions.Get(0).sub_conditions_size());
@@ -389,7 +387,7 @@ TEST_F(TestDeleteConditionHandler, 
DeleteCondRemoveOneCondition) {
     res = _delete_condition_handler.delete_cond(tablet, 5, false);
     ASSERT_EQ(OLAP_SUCCESS, res);
 
-    const del_cond_array& all_delete_conditions = 
tablet->delete_data_conditions();
+    const DelPredicateArray& all_delete_conditions = 
tablet->delete_data_conditions();
     ASSERT_EQ(size_t(2), all_delete_conditions.size());
 
     EXPECT_EQ(3, all_delete_conditions.Get(0).version());
@@ -456,7 +454,7 @@ TEST_F(TestDeleteConditionHandler, 
DeleteCondRemovBelowCondition) {
     res = _delete_condition_handler.delete_cond(tablet, 4, true);
     ASSERT_EQ(OLAP_SUCCESS, res);
 
-    const del_cond_array& all_delete_conditions = 
tablet->delete_data_conditions();
+    const DelPredicateArray& all_delete_conditions = 
tablet->delete_data_conditions();
     ASSERT_EQ(size_t(1), all_delete_conditions.size());
 
     EXPECT_EQ(5, all_delete_conditions.Get(0).version());
@@ -498,8 +496,6 @@ class TestDeleteConditionHandler2 : public testing::Test {
         ASSERT_EQ(OLAP_SUCCESS, remove_all_dir(config::storage_root_path));
     }
 
-    typedef RepeatedPtrField<DeleteConditionMessage> del_cond_array;
-
     std::string _tablet_path;
     TabletSharedPtr tablet;
     TCreateTabletReq _create_tablet;
@@ -818,8 +814,6 @@ class TestDeleteHandler : public testing::Test {
         ASSERT_EQ(OLAP_SUCCESS, remove_all_dir(config::storage_root_path));
     }
 
-    typedef RepeatedPtrField<DeleteConditionMessage> del_cond_array;
-
     std::string _tablet_path;
     RowCursor _data_row_cursor;
     TabletSharedPtr tablet;


 

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