提交 2ea773b9 编写于 作者: W wxyu

MS-368 Implement cost.cpp


Former-commit-id: 554f06b109662bb381bb06aa73ddab956fb8c47c
上级 484f255f
......@@ -22,6 +22,7 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-364 - Modify tasktableitem in tasktable
- MS-365 - Use tasktableitemptr instead in event
- MS-366 - Implement TaskTable
- MS-368 - Implement cost.cpp
## New Feature
- MS-343 - Implement ResourceMgr
......
......@@ -12,22 +12,40 @@ namespace milvus {
namespace engine {
std::vector<uint64_t>
PickToMove(const TaskTable &task_table, const CacheMgr &cache_mgr, uint64_t limit) {
PickToMove(TaskTable &task_table, const CacheMgr &cache_mgr, uint64_t limit) {
std::vector<uint64_t> indexes;
for (uint64_t i = 0, count = 0; i < task_table.Size() && count < limit; ++i) {
if (task_table[i]->state == TaskTableItemState::LOADED) {
indexes.push_back(i);
++count;
}
}
return indexes;
}
std::vector<uint64_t>
PickToLoad(const TaskTable &task_table, uint64_t limit) {
PickToLoad(TaskTable &task_table, uint64_t limit) {
std::vector<uint64_t> indexes;
for (uint64_t i = 0, count = 0; i < task_table.Size() && count < limit; ++i) {
if (task_table[i]->state == TaskTableItemState::START) {
indexes.push_back(i);
++count;
}
}
return indexes;
}
std::vector<uint64_t>
PickToExecute(const TaskTable &task_table, uint64_t limit) {
PickToExecute(TaskTable &task_table, uint64_t limit) {
std::vector<uint64_t> indexes;
for (uint64_t i = 0, count = 0; i < task_table.Size() && count < limit; ++i) {
if (task_table[i]->state == TaskTableItemState::LOADED) {
indexes.push_back(i);
++count;
}
}
return indexes;
}
......
......@@ -23,7 +23,7 @@ namespace engine {
* call from scheduler;
*/
std::vector<uint64_t>
PickToMove(const TaskTable &task_table, const CacheMgr &cache_mgr, uint64_t limit);
PickToMove(TaskTable &task_table, const CacheMgr &cache_mgr, uint64_t limit);
/*
......@@ -32,7 +32,7 @@ PickToMove(const TaskTable &task_table, const CacheMgr &cache_mgr, uint64_t limi
* I DONT SURE NEED THIS;
*/
std::vector<uint64_t>
PickToLoad(const TaskTable &task_table, uint64_t limit);
PickToLoad(TaskTable &task_table, uint64_t limit);
/*
* select task to execute;
......@@ -40,7 +40,7 @@ PickToLoad(const TaskTable &task_table, uint64_t limit);
* I DONT SURE NEED THIS;
*/
std::vector<uint64_t>
PickToExecute(const TaskTable &task_table, uint64_t limit);
PickToExecute(TaskTable &task_table, uint64_t limit);
}
......
......@@ -90,6 +90,14 @@ public:
Size() {
return table_.size();
}
public:
TaskTableItemPtr &
operator[](uint64_t index) {
return table_[index];
}
std::deque<TaskTableItemPtr>::iterator begin() { return table_.begin(); }
std::deque<TaskTableItemPtr>::iterator end() { return table_.end(); }
public:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册