mirror of https://github.com/milvus-io/milvus.git
parent
0a77b4547f
commit
0af6d85ea9
|
@ -899,35 +899,35 @@ DBImpl::BackgroundBuildIndex() {
|
|||
Status status;
|
||||
|
||||
// step 2: put build index task to scheduler
|
||||
// for (auto &file : to_index_files) {
|
||||
// scheduler::BuildIndexJobPtr
|
||||
// job = std::make_shared<scheduler::BuildIndexJob>(0, meta_ptr_, options_);
|
||||
//
|
||||
// scheduler::TableFileSchemaPtr file_ptr = std::make_shared<meta::TableFileSchema>(file);
|
||||
//
|
||||
// job->AddToIndexFiles(file_ptr);
|
||||
// scheduler::JobMgrInst::GetInstance()->Put(job);
|
||||
// job->WaitBuildIndexFinish();
|
||||
// if (!job->GetStatus().ok()) {
|
||||
// Status status = job->GetStatus();
|
||||
// ENGINE_LOG_ERROR << "Building index for " << file.id_ << " failed: " << status.ToString();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
for (auto &file : to_index_files) {
|
||||
std::cout << "get to index file" << std::endl;
|
||||
status = BuildIndex(file);
|
||||
if (!status.ok()) {
|
||||
scheduler::BuildIndexJobPtr
|
||||
job = std::make_shared<scheduler::BuildIndexJob>(0, meta_ptr_, options_);
|
||||
|
||||
scheduler::TableFileSchemaPtr file_ptr = std::make_shared<meta::TableFileSchema>(file);
|
||||
|
||||
job->AddToIndexFiles(file_ptr);
|
||||
scheduler::JobMgrInst::GetInstance()->Put(job);
|
||||
job->WaitBuildIndexFinish();
|
||||
if (!job->GetStatus().ok()) {
|
||||
Status status = job->GetStatus();
|
||||
ENGINE_LOG_ERROR << "Building index for " << file.id_ << " failed: " << status.ToString();
|
||||
}
|
||||
|
||||
if (shutting_down_.load(std::memory_order_acquire)) {
|
||||
ENGINE_LOG_DEBUG << "Server will shutdown, skip build index action";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// for (auto &file : to_index_files) {
|
||||
// std::cout << "get to index file" << std::endl;
|
||||
// status = BuildIndex(file);
|
||||
// if (!status.ok()) {
|
||||
// ENGINE_LOG_ERROR << "Building index for " << file.id_ << " failed: " << status.ToString();
|
||||
// }
|
||||
//
|
||||
// if (shutting_down_.load(std::memory_order_acquire)) {
|
||||
// ENGINE_LOG_DEBUG << "Server will shutdown, skip build index action";
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
ENGINE_LOG_TRACE << "Background build index thread exit";
|
||||
}
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ TaskCreator::Create(const BuildIndexJobPtr &job) {
|
|||
ResourcePtr res_ptr = ResMgrInst::GetInstance()->GetResource("disk");
|
||||
|
||||
for (auto &to_index_file : job->to_index_files()) {
|
||||
auto task = std::make_shared<XBuildIndexTask>(to_index_file.second);
|
||||
task->label() = std::make_shared<SpecResLabel>(std::weak_ptr<Resource>(res_ptr));
|
||||
auto label = std::make_shared<SpecResLabel>(std::weak_ptr<Resource>(res_ptr));
|
||||
auto task = std::make_shared<XBuildIndexTask>(to_index_file.second, label);
|
||||
task->job_ = job;
|
||||
tasks.emplace_back(task);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
namespace milvus {
|
||||
namespace scheduler {
|
||||
|
||||
XBuildIndexTask::XBuildIndexTask(TableFileSchemaPtr file)
|
||||
: Task(TaskType::BuildIndexTask), file_(file) {
|
||||
XBuildIndexTask::XBuildIndexTask(TableFileSchemaPtr file, TaskLabelPtr label)
|
||||
: Task(TaskType::BuildIndexTask, std::move(label)), file_(file) {
|
||||
if (file_) {
|
||||
to_index_engine_ = EngineFactory::Build(file_->dimension_, file_->location_, (EngineType) file_->engine_type_,
|
||||
(MetricType) file_->metric_type_, file_->nlist_);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace scheduler {
|
|||
|
||||
class XBuildIndexTask : public Task {
|
||||
public:
|
||||
explicit XBuildIndexTask(TableFileSchemaPtr file);
|
||||
explicit XBuildIndexTask(TableFileSchemaPtr file, TaskLabelPtr label);
|
||||
|
||||
void
|
||||
Load(LoadType type, uint8_t device_id) override;
|
||||
|
|
Loading…
Reference in New Issue