From f5b426df557d5922a9259a03d437d5cbfb105b42 Mon Sep 17 00:00:00 2001 From: wxyu Date: Fri, 23 Aug 2019 11:34:31 +0800 Subject: [PATCH] MS-405 Add delete task support Former-commit-id: a47592ffd6463d4e5a2addf4df1438cc57937b93 --- cpp/CHANGELOG.md | 1 + cpp/src/scheduler/task/DeleteTask.cpp | 9 +++++++-- cpp/src/scheduler/task/DeleteTask.h | 7 +++++++ cpp/src/scheduler/task/Task.h | 1 + cpp/src/scheduler/task/TaskConvert.cpp | 5 +++-- cpp/src/scheduler/task/TaskConvert.h | 4 +++- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 025af08e..0346e061 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -41,6 +41,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-400 - Add timestamp record in task state change function - MS-402 - Add dump implementation for TaskTableItem - MS-404 - Release index after search task done avoid memory increment continues +- MS-405 - Add delete task support ## New Feature - MS-343 - Implement ResourceMgr diff --git a/cpp/src/scheduler/task/DeleteTask.cpp b/cpp/src/scheduler/task/DeleteTask.cpp index ee6b63b7..9f76de50 100644 --- a/cpp/src/scheduler/task/DeleteTask.cpp +++ b/cpp/src/scheduler/task/DeleteTask.cpp @@ -6,10 +6,14 @@ #include "DeleteTask.h" + namespace zilliz { namespace milvus { namespace engine { +XDeleteTask::XDeleteTask(DeleteContextPtr &delete_context) + : delete_context_ptr_(delete_context) {} + void XDeleteTask::Load(LoadType type, uint8_t device_id) { @@ -17,12 +21,13 @@ XDeleteTask::Load(LoadType type, uint8_t device_id) { void XDeleteTask::Execute() { - + delete_context_ptr_->ResourceDone(); } TaskPtr XDeleteTask::Clone() { - return nullptr; + auto task = std::make_shared(delete_context_ptr_); + return task; } } diff --git a/cpp/src/scheduler/task/DeleteTask.h b/cpp/src/scheduler/task/DeleteTask.h index 9ca4e8b5..2b266243 100644 --- a/cpp/src/scheduler/task/DeleteTask.h +++ b/cpp/src/scheduler/task/DeleteTask.h @@ -5,6 +5,7 @@ ******************************************************************************/ #pragma once +#include #include "Task.h" @@ -14,6 +15,9 @@ namespace engine { class XDeleteTask : public Task { public: + explicit + XDeleteTask(DeleteContextPtr &delete_context); + void Load(LoadType type, uint8_t device_id) override; @@ -22,6 +26,9 @@ public: TaskPtr Clone() override; + +public: + DeleteContextPtr delete_context_ptr_; }; } diff --git a/cpp/src/scheduler/task/Task.h b/cpp/src/scheduler/task/Task.h index 56716480..4d78894d 100644 --- a/cpp/src/scheduler/task/Task.h +++ b/cpp/src/scheduler/task/Task.h @@ -35,6 +35,7 @@ public: virtual void Execute() = 0; + // TODO: dont use this method to support task move virtual TaskPtr Clone() = 0; diff --git a/cpp/src/scheduler/task/TaskConvert.cpp b/cpp/src/scheduler/task/TaskConvert.cpp index f29fd296..43f70903 100644 --- a/cpp/src/scheduler/task/TaskConvert.cpp +++ b/cpp/src/scheduler/task/TaskConvert.cpp @@ -22,8 +22,9 @@ TaskConvert(const ScheduleTaskPtr &schedule_task) { return task; } case ScheduleTaskType::kDelete: { - // TODO: convert to delete task - return nullptr; + auto delete_task = std::static_pointer_cast(schedule_task); + auto task = std::make_shared(delete_task->context_); + return task; } default: { // TODO: unexpected !!! diff --git a/cpp/src/scheduler/task/TaskConvert.h b/cpp/src/scheduler/task/TaskConvert.h index 471592f9..bfc2df76 100644 --- a/cpp/src/scheduler/task/TaskConvert.h +++ b/cpp/src/scheduler/task/TaskConvert.h @@ -4,9 +4,11 @@ * Proprietary and confidential. ******************************************************************************/ -#include "src/db/scheduler/task/IndexLoadTask.h" +#include "db/scheduler/task/DeleteTask.h" +#include "db/scheduler/task/IndexLoadTask.h" #include "Task.h" #include "SearchTask.h" +#include "DeleteTask.h" namespace zilliz { namespace milvus { -- GitLab