Loading cpp/src/scheduler/Algorithm.cpp +9 −7 Original line number Diff line number Diff line Loading @@ -16,7 +16,11 @@ // under the License. #include "Algorithm.h" #include "scheduler/Algorithm.h" #include <limits> #include <unordered_map> #include <utility> namespace zilliz { namespace milvus { Loading @@ -29,7 +33,6 @@ ShortestPath(const ResourcePtr &src, const ResourcePtr &dest, const ResourceMgrPtr &res_mgr, std::vector<std::string> &path) { std::vector<std::vector<std::string>> paths; uint64_t num_of_resources = res_mgr->GetAllResources().size(); Loading @@ -53,7 +56,6 @@ ShortestPath(const ResourcePtr &src, std::vector<bool> vis(num_of_resources, false); std::vector<uint64_t> dis(num_of_resources, MAXINT); for (auto &res : res_mgr->GetAllResources()) { auto cur_node = std::static_pointer_cast<Node>(res); auto cur_neighbours = cur_node->GetNeighbours(); Loading Loading @@ -105,6 +107,6 @@ ShortestPath(const ResourcePtr &src, return dis[name_id_map.at(dest->name())]; } } } } No newline at end of file } // namespace scheduler } // namespace milvus } // namespace zilliz cpp/src/scheduler/Algorithm.h +4 −4 Original line number Diff line number Diff line Loading @@ -32,6 +32,6 @@ ShortestPath(const ResourcePtr &src, const ResourceMgrPtr &res_mgr, std::vector<std::string> &path); } } } No newline at end of file } // namespace scheduler } // namespace milvus } // namespace zilliz cpp/src/scheduler/Definition.h +3 −4 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ #include "db/engine/EngineFactory.h" #include "db/engine/ExecutionEngine.h" namespace zilliz { namespace milvus { namespace scheduler { Loading @@ -43,6 +42,6 @@ using EngineFactory = engine::EngineFactory; using EngineType = engine::EngineType; using MetricType = engine::MetricType; } } } } // namespace scheduler } // namespace milvus } // namespace zilliz cpp/src/scheduler/JobMgr.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -15,19 +15,19 @@ // specific language governing permissions and limitations // under the License. #include "JobMgr.h" #include "scheduler/JobMgr.h" #include "task/Task.h" #include "TaskCreator.h" #include <utility> namespace zilliz { namespace milvus { namespace scheduler { using namespace engine; JobMgr::JobMgr(ResourceMgrPtr res_mgr) : res_mgr_(std::move(res_mgr)) {} : res_mgr_(std::move(res_mgr)) { } void JobMgr::Start() { Loading Loading @@ -59,7 +59,9 @@ void JobMgr::worker_function() { while (running_) { std::unique_lock<std::mutex> lock(mutex_); cv_.wait(lock, [this] { return !queue_.empty(); }); cv_.wait(lock, [this] { return !queue_.empty(); }); auto job = queue_.front(); queue_.pop(); lock.unlock(); Loading @@ -84,6 +86,6 @@ JobMgr::build_task(const JobPtr &job) { return TaskCreator::Create(job); } } } } } // namespace scheduler } // namespace milvus } // namespace zilliz cpp/src/scheduler/JobMgr.h +8 −10 Original line number Diff line number Diff line Loading @@ -31,15 +31,13 @@ #include "task/Task.h" #include "ResourceMgr.h" namespace zilliz { namespace milvus { namespace scheduler { class JobMgr { public: explicit JobMgr(ResourceMgrPtr res_mgr); explicit JobMgr(ResourceMgrPtr res_mgr); void Start(); Loading Loading @@ -72,6 +70,6 @@ private: using JobMgrPtr = std::shared_ptr<JobMgr>; } } } } // namespace scheduler } // namespace milvus } // namespace zilliz Loading
cpp/src/scheduler/Algorithm.cpp +9 −7 Original line number Diff line number Diff line Loading @@ -16,7 +16,11 @@ // under the License. #include "Algorithm.h" #include "scheduler/Algorithm.h" #include <limits> #include <unordered_map> #include <utility> namespace zilliz { namespace milvus { Loading @@ -29,7 +33,6 @@ ShortestPath(const ResourcePtr &src, const ResourcePtr &dest, const ResourceMgrPtr &res_mgr, std::vector<std::string> &path) { std::vector<std::vector<std::string>> paths; uint64_t num_of_resources = res_mgr->GetAllResources().size(); Loading @@ -53,7 +56,6 @@ ShortestPath(const ResourcePtr &src, std::vector<bool> vis(num_of_resources, false); std::vector<uint64_t> dis(num_of_resources, MAXINT); for (auto &res : res_mgr->GetAllResources()) { auto cur_node = std::static_pointer_cast<Node>(res); auto cur_neighbours = cur_node->GetNeighbours(); Loading Loading @@ -105,6 +107,6 @@ ShortestPath(const ResourcePtr &src, return dis[name_id_map.at(dest->name())]; } } } } No newline at end of file } // namespace scheduler } // namespace milvus } // namespace zilliz
cpp/src/scheduler/Algorithm.h +4 −4 Original line number Diff line number Diff line Loading @@ -32,6 +32,6 @@ ShortestPath(const ResourcePtr &src, const ResourceMgrPtr &res_mgr, std::vector<std::string> &path); } } } No newline at end of file } // namespace scheduler } // namespace milvus } // namespace zilliz
cpp/src/scheduler/Definition.h +3 −4 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ #include "db/engine/EngineFactory.h" #include "db/engine/ExecutionEngine.h" namespace zilliz { namespace milvus { namespace scheduler { Loading @@ -43,6 +42,6 @@ using EngineFactory = engine::EngineFactory; using EngineType = engine::EngineType; using MetricType = engine::MetricType; } } } } // namespace scheduler } // namespace milvus } // namespace zilliz
cpp/src/scheduler/JobMgr.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -15,19 +15,19 @@ // specific language governing permissions and limitations // under the License. #include "JobMgr.h" #include "scheduler/JobMgr.h" #include "task/Task.h" #include "TaskCreator.h" #include <utility> namespace zilliz { namespace milvus { namespace scheduler { using namespace engine; JobMgr::JobMgr(ResourceMgrPtr res_mgr) : res_mgr_(std::move(res_mgr)) {} : res_mgr_(std::move(res_mgr)) { } void JobMgr::Start() { Loading Loading @@ -59,7 +59,9 @@ void JobMgr::worker_function() { while (running_) { std::unique_lock<std::mutex> lock(mutex_); cv_.wait(lock, [this] { return !queue_.empty(); }); cv_.wait(lock, [this] { return !queue_.empty(); }); auto job = queue_.front(); queue_.pop(); lock.unlock(); Loading @@ -84,6 +86,6 @@ JobMgr::build_task(const JobPtr &job) { return TaskCreator::Create(job); } } } } } // namespace scheduler } // namespace milvus } // namespace zilliz
cpp/src/scheduler/JobMgr.h +8 −10 Original line number Diff line number Diff line Loading @@ -31,15 +31,13 @@ #include "task/Task.h" #include "ResourceMgr.h" namespace zilliz { namespace milvus { namespace scheduler { class JobMgr { public: explicit JobMgr(ResourceMgrPtr res_mgr); explicit JobMgr(ResourceMgrPtr res_mgr); void Start(); Loading Loading @@ -72,6 +70,6 @@ private: using JobMgrPtr = std::shared_ptr<JobMgr>; } } } } // namespace scheduler } // namespace milvus } // namespace zilliz