milvus/core/src/server/delivery/request/ReLoadSegmentsRequest.cpp
BossZou 167743c993
read_only node detect delete vector operation using mishards #2368 (#2473)
* Add new request ReLoadSegments

Signed-off-by: yhz <413554850@qq.com>

* Finish load segments functionality

Signed-off-by: yhz <413554850@qq.com>

* Add api in grpc

Signed-off-by: yhz <413554850@qq.com>

* update Reloadsegments

Signed-off-by: yhz <413554850@qq.com>

* .

Signed-off-by: yhz <413554850@qq.com>

* create new blacklist if not exists

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* update api names

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* Finish mishard for support api reloadsegments

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* update changlog

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* Add more details when failed in search task

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* Fix compile issue

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* update mishards requirements

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* Code format

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* modify docker images in mysql all_in_one

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* update shards code

Signed-off-by: Yhz <yinghao.zou@zilliz.com>

* Move updatedeldocs function to dbimpl

Signed-off-by: yhz <413554850@qq.com>

* Move reload segment del docs function to dbimpl

Signed-off-by: yhz <413554850@qq.com>

* [skip ci] correct shards requirements

Signed-off-by: yhz <413554850@qq.com>
2020-06-02 14:34:19 +08:00

75 lines
2.7 KiB
C++

// Copyright (C) 2019-2020 Zilliz. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under the License.
#include "server/delivery/request/ReLoadSegmentsRequest.h"
#include "config/Config.h"
#include "server/DBWrapper.h"
#include "utils/TimeRecorder.h"
#include "utils/ValidationUtil.h"
namespace milvus {
namespace server {
ReLoadSegmentsRequest::ReLoadSegmentsRequest(const std::shared_ptr<milvus::server::Context>& context,
const std::string& collection_name,
const std::vector<std::string>& segment_ids)
: BaseRequest(context, BaseRequest::kReloadSegments), collection_name_(collection_name), segment_ids_(segment_ids) {
}
BaseRequestPtr
ReLoadSegmentsRequest::Create(const std::shared_ptr<milvus::server::Context>& context,
const std::string& collection_name, const std::vector<std::string>& segment_ids) {
return std::shared_ptr<BaseRequest>(new ReLoadSegmentsRequest(context, collection_name, segment_ids));
}
Status
ReLoadSegmentsRequest::OnExecute() {
auto& config = Config::GetInstance();
std::string deploy_mode;
auto status = config.GetServerConfigDeployMode(deploy_mode);
if (!status.ok()) {
return status;
}
if (deploy_mode == "single" || deploy_mode == "cluster_writable") {
// TODO: No need to reload segment files
return Status(SERVER_SUCCESS, "");
}
try {
std::string hdr = "ReloadSegmentsRequest(collection=" + collection_name_ + ")";
TimeRecorderAuto rc(hdr);
// step 1: check arguments
auto status = ValidationUtil::ValidateCollectionName(collection_name_);
if (!status.ok()) {
return status;
}
std::vector<int64_t> segment_ids;
for (auto& id : segment_ids_) {
std::string::size_type sz;
segment_ids.push_back(std::stoul(id, &sz));
}
return DBWrapper::DB()->ReLoadSegmentsDeletedDocs(collection_name_, segment_ids);
} catch (std::exception& exp) {
return Status(SERVER_UNEXPECTED_ERROR, exp.what());
}
return Status::OK();
}
} // namespace server
} // namespace milvus