未验证 提交 013a1f0e 编写于 作者: C chen qingxiang 提交者: GitHub

fix issue #3286 (#3494)

* fix issue #3286
Signed-off-by: Ngodchen0212 <qingxiang.chen@zilliz.com>

* format code
Signed-off-by: Ngodchen0212 <qingxiang.chen@zilliz.com>
上级 3f818106
...@@ -58,7 +58,10 @@ ParseGPUDevices(const std::string& str) { ...@@ -58,7 +58,10 @@ ParseGPUDevices(const std::string& str) {
device_set.insert(std::stoll(device.substr(3))); device_set.insert(std::stoll(device.substr(3)));
} }
for (auto dev : device_set) devices.push_back(dev); devices.reserve(device_set.size());
for (auto dev : device_set) {
devices.push_back(dev);
}
return devices; return devices;
} }
......
...@@ -699,7 +699,7 @@ DBImpl::ListIDInSegment(const std::string& collection_name, int64_t segment_id, ...@@ -699,7 +699,7 @@ DBImpl::ListIDInSegment(const std::string& collection_name, int64_t segment_id,
std::vector<offset_t> temp_ids; std::vector<offset_t> temp_ids;
temp_ids.reserve(delete_ids.size()); temp_ids.reserve(delete_ids.size());
std::copy(delete_ids.begin(), delete_ids.end(), std::back_inserter(temp_ids)); std::copy(delete_ids.begin(), delete_ids.end(), std::back_inserter(temp_ids));
std::sort(temp_ids.begin(), temp_ids.end(), std::greater<offset_t>()); std::sort(temp_ids.begin(), temp_ids.end(), std::greater<>());
for (auto offset : temp_ids) { for (auto offset : temp_ids) {
entity_ids.erase(entity_ids.begin() + offset, entity_ids.begin() + offset + 1); entity_ids.erase(entity_ids.begin() + offset, entity_ids.begin() + offset + 1);
} }
...@@ -979,7 +979,7 @@ DBImpl::BackgroundBuildIndexTask(std::vector<std::string> collection_names) { ...@@ -979,7 +979,7 @@ DBImpl::BackgroundBuildIndexTask(std::vector<std::string> collection_names) {
std::unique_lock<std::mutex> lock(build_index_mutex_); std::unique_lock<std::mutex> lock(build_index_mutex_);
for (auto collection_name : collection_names) { for (const auto& collection_name : collection_names) {
snapshot::ScopedSnapshotT latest_ss; snapshot::ScopedSnapshotT latest_ss;
auto status = snapshot::Snapshots::GetInstance().GetSnapshot(latest_ss, collection_name); auto status = snapshot::Snapshots::GetInstance().GetSnapshot(latest_ss, collection_name);
if (!status.ok()) { if (!status.ok()) {
......
...@@ -105,7 +105,7 @@ GetEntityByIdSegmentHandler::Handle(const snapshot::SegmentPtr& segment) { ...@@ -105,7 +105,7 @@ GetEntityByIdSegmentHandler::Handle(const snapshot::SegmentPtr& segment) {
std::vector<idx_t> ids_in_this_segment; std::vector<idx_t> ids_in_this_segment;
std::vector<int64_t> offsets; std::vector<int64_t> offsets;
for (IDNumbers::iterator it = ids_left_.begin(); it != ids_left_.end();) { for (auto it = ids_left_.begin(); it != ids_left_.end();) {
idx_t id = *it; idx_t id = *it;
// fast check using bloom filter // fast check using bloom filter
if (!id_bloom_filter_ptr->Check(id)) { if (!id_bloom_filter_ptr->Check(id)) {
......
...@@ -210,7 +210,7 @@ GetSnapshotInfo(const std::string& collection_name, milvus::json& json_info) { ...@@ -210,7 +210,7 @@ GetSnapshotInfo(const std::string& collection_name, milvus::json& json_info) {
const engine::snapshot::FieldPtr& field = iter.second->GetField(); const engine::snapshot::FieldPtr& field = iter.second->GetField();
auto& elements = iter.second->GetElementVistors(); auto& elements = iter.second->GetElementVistors();
for (auto pair : elements) { for (const auto& pair : elements) {
if (pair.second == nullptr || pair.second->GetElement() == nullptr) { if (pair.second == nullptr || pair.second->GetElement() == nullptr) {
continue; continue;
} }
......
...@@ -228,7 +228,7 @@ MemSegment::ApplyDeleteToMem() { ...@@ -228,7 +228,7 @@ MemSegment::ApplyDeleteToMem() {
if (uid_data->data_.size() / sizeof(idx_t) != chunk->count_) { if (uid_data->data_.size() / sizeof(idx_t) != chunk->count_) {
continue; // invalid uid data? continue; // invalid uid data?
} }
idx_t* uid = (idx_t*)(uid_data->data_.data()); auto uid = reinterpret_cast<idx_t*>(uid_data->data_.data());
// calculte delete offsets // calculte delete offsets
std::vector<offset_t> offsets; std::vector<offset_t> offsets;
......
...@@ -416,7 +416,7 @@ DropAllIndexOperation::PreCheck() { ...@@ -416,7 +416,7 @@ DropAllIndexOperation::PreCheck() {
return Status(SS_INVALID_CONTEX_ERROR, emsg.str()); return Status(SS_INVALID_CONTEX_ERROR, emsg.str());
} }
for (auto stale_fe : context_.stale_field_elements) { for (const auto& stale_fe : context_.stale_field_elements) {
if (!GetStartedSS()->GetResource<FieldElement>(stale_fe->GetID())) { if (!GetStartedSS()->GetResource<FieldElement>(stale_fe->GetID())) {
std::stringstream emsg; std::stringstream emsg;
emsg << GetRepr() << ". Specified field element " << stale_fe->GetName(); emsg << GetRepr() << ". Specified field element " << stale_fe->GetName();
......
...@@ -190,6 +190,8 @@ TaskTable::PickToLoad(uint64_t limit) { ...@@ -190,6 +190,8 @@ TaskTable::PickToLoad(uint64_t limit) {
cross = true; cross = true;
indexes.push_back(index); indexes.push_back(index);
++pick_count; ++pick_count;
} else {
cross = true;
} }
} }
// rc.ElapseFromBegin("PickToLoad "); // rc.ElapseFromBegin("PickToLoad ");
...@@ -262,6 +264,8 @@ TaskTable::PickToExecute(uint64_t limit) { ...@@ -262,6 +264,8 @@ TaskTable::PickToExecute(uint64_t limit) {
cross = true; cross = true;
indexes.push_back(index); indexes.push_back(index);
++pick_count; ++pick_count;
} else {
cross = true;
} }
} }
// rc.ElapseFromBegin("PickToExecute "); // rc.ElapseFromBegin("PickToExecute ");
......
...@@ -50,7 +50,7 @@ LoadCollectionReq::OnExecute() { ...@@ -50,7 +50,7 @@ LoadCollectionReq::OnExecute() {
// TODO(yukun): if PreloadCollection interface needs to add field names as params // TODO(yukun): if PreloadCollection interface needs to add field names as params
std::vector<std::string> field_names; std::vector<std::string> field_names;
for (auto field_it : fields_schema) { for (const auto& field_it : fields_schema) {
field_names.emplace_back(field_it.first->GetName()); field_names.emplace_back(field_it.first->GetName());
} }
......
...@@ -367,7 +367,7 @@ ConstructEntityResults(const std::vector<engine::AttrsData>& attrs, const std::v ...@@ -367,7 +367,7 @@ ConstructEntityResults(const std::vector<engine::AttrsData>& attrs, const std::v
std::string vector_field_name; std::string vector_field_name;
bool set_valid_row = false; bool set_valid_row = false;
for (auto field_name : field_names) { for (const auto& field_name : field_names) {
if (!attrs.empty()) { if (!attrs.empty()) {
if (attrs[0].attr_type_.find(field_name) != attrs[0].attr_type_.end()) { if (attrs[0].attr_type_.find(field_name) != attrs[0].attr_type_.end()) {
auto grpc_field = response->add_fields(); auto grpc_field = response->add_fields();
...@@ -1252,6 +1252,7 @@ GrpcRequestHandler::Flush(::grpc::ServerContext* context, const ::milvus::grpc:: ...@@ -1252,6 +1252,7 @@ GrpcRequestHandler::Flush(::grpc::ServerContext* context, const ::milvus::grpc::
LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->ReqID().c_str(), __func__); LOG_SERVER_INFO_ << LogOut("Request [%s] %s begin.", GetContext(context)->ReqID().c_str(), __func__);
std::vector<std::string> collection_names; std::vector<std::string> collection_names;
collection_names.reserve(collection_names.size());
for (int32_t i = 0; i < request->collection_name_array().size(); i++) { for (int32_t i = 0; i < request->collection_name_array().size(); i++) {
collection_names.push_back(request->collection_name_array(i)); collection_names.push_back(request->collection_name_array(i));
} }
......
...@@ -90,7 +90,7 @@ CopyStructuredData(const nlohmann::json& json, std::vector<uint8_t>& raw) { ...@@ -90,7 +90,7 @@ CopyStructuredData(const nlohmann::json& json, std::vector<uint8_t>& raw) {
values.resize(size); values.resize(size);
raw.resize(size * sizeof(T)); raw.resize(size * sizeof(T));
size_t offset = 0; size_t offset = 0;
for (auto data : json) { for (const auto& data : json) {
values[offset] = data.get<T>(); values[offset] = data.get<T>();
++offset; ++offset;
} }
...@@ -1770,6 +1770,8 @@ WebRequestHandler::GetEntity(const milvus::server::web::OString& collection_name ...@@ -1770,6 +1770,8 @@ WebRequestHandler::GetEntity(const milvus::server::web::OString& collection_name
std::vector<std::string> ids; std::vector<std::string> ids;
StringHelpFunctions::SplitStringByDelimeter(query_ids->c_str(), ",", ids); StringHelpFunctions::SplitStringByDelimeter(query_ids->c_str(), ",", ids);
std::vector<int64_t> entity_ids; std::vector<int64_t> entity_ids;
entity_ids.reserve(ids.size());
for (auto& id : ids) { for (auto& id : ids) {
entity_ids.push_back(std::stol(id)); entity_ids.push_back(std::stol(id));
} }
......
...@@ -84,7 +84,7 @@ RemoveDirectory(const std::string& path) { ...@@ -84,7 +84,7 @@ RemoveDirectory(const std::string& path) {
if (strcmp(dmsg->d_name, ".") != 0 && strcmp(dmsg->d_name, "..") != 0) { if (strcmp(dmsg->d_name, ".") != 0 && strcmp(dmsg->d_name, "..") != 0) {
snprintf(file_name, buf_size, folder_name.c_str(), dmsg->d_name); snprintf(file_name, buf_size, folder_name.c_str(), dmsg->d_name);
std::string tmp = file_name; std::string tmp = file_name;
if (tmp.find(".") == std::string::npos) { if (tmp.find('.') == std::string::npos) {
RemoveDirectory(file_name); RemoveDirectory(file_name);
} }
remove(file_name); remove(file_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册