未验证 提交 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) {
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;
}
......
......@@ -699,7 +699,7 @@ DBImpl::ListIDInSegment(const std::string& collection_name, int64_t segment_id,
std::vector<offset_t> temp_ids;
temp_ids.reserve(delete_ids.size());
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) {
entity_ids.erase(entity_ids.begin() + offset, entity_ids.begin() + offset + 1);
}
......@@ -979,7 +979,7 @@ DBImpl::BackgroundBuildIndexTask(std::vector<std::string> collection_names) {
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;
auto status = snapshot::Snapshots::GetInstance().GetSnapshot(latest_ss, collection_name);
if (!status.ok()) {
......
......@@ -105,7 +105,7 @@ GetEntityByIdSegmentHandler::Handle(const snapshot::SegmentPtr& segment) {
std::vector<idx_t> ids_in_this_segment;
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;
// fast check using bloom filter
if (!id_bloom_filter_ptr->Check(id)) {
......
......@@ -210,7 +210,7 @@ GetSnapshotInfo(const std::string& collection_name, milvus::json& json_info) {
const engine::snapshot::FieldPtr& field = iter.second->GetField();
auto& elements = iter.second->GetElementVistors();
for (auto pair : elements) {
for (const auto& pair : elements) {
if (pair.second == nullptr || pair.second->GetElement() == nullptr) {
continue;
}
......
......@@ -228,7 +228,7 @@ MemSegment::ApplyDeleteToMem() {
if (uid_data->data_.size() / sizeof(idx_t) != chunk->count_) {
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
std::vector<offset_t> offsets;
......
......@@ -416,7 +416,7 @@ DropAllIndexOperation::PreCheck() {
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())) {
std::stringstream emsg;
emsg << GetRepr() << ". Specified field element " << stale_fe->GetName();
......
......@@ -190,6 +190,8 @@ TaskTable::PickToLoad(uint64_t limit) {
cross = true;
indexes.push_back(index);
++pick_count;
} else {
cross = true;
}
}
// rc.ElapseFromBegin("PickToLoad ");
......@@ -262,6 +264,8 @@ TaskTable::PickToExecute(uint64_t limit) {
cross = true;
indexes.push_back(index);
++pick_count;
} else {
cross = true;
}
}
// rc.ElapseFromBegin("PickToExecute ");
......
......@@ -50,7 +50,7 @@ LoadCollectionReq::OnExecute() {
// TODO(yukun): if PreloadCollection interface needs to add field names as params
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());
}
......
......@@ -367,7 +367,7 @@ ConstructEntityResults(const std::vector<engine::AttrsData>& attrs, const std::v
std::string vector_field_name;
bool set_valid_row = false;
for (auto field_name : field_names) {
for (const auto& field_name : field_names) {
if (!attrs.empty()) {
if (attrs[0].attr_type_.find(field_name) != attrs[0].attr_type_.end()) {
auto grpc_field = response->add_fields();
......@@ -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__);
std::vector<std::string> collection_names;
collection_names.reserve(collection_names.size());
for (int32_t i = 0; i < request->collection_name_array().size(); i++) {
collection_names.push_back(request->collection_name_array(i));
}
......
......@@ -90,7 +90,7 @@ CopyStructuredData(const nlohmann::json& json, std::vector<uint8_t>& raw) {
values.resize(size);
raw.resize(size * sizeof(T));
size_t offset = 0;
for (auto data : json) {
for (const auto& data : json) {
values[offset] = data.get<T>();
++offset;
}
......@@ -1770,6 +1770,8 @@ WebRequestHandler::GetEntity(const milvus::server::web::OString& collection_name
std::vector<std::string> ids;
StringHelpFunctions::SplitStringByDelimeter(query_ids->c_str(), ",", ids);
std::vector<int64_t> entity_ids;
entity_ids.reserve(ids.size());
for (auto& id : ids) {
entity_ids.push_back(std::stol(id));
}
......
......@@ -84,7 +84,7 @@ RemoveDirectory(const std::string& path) {
if (strcmp(dmsg->d_name, ".") != 0 && strcmp(dmsg->d_name, "..") != 0) {
snprintf(file_name, buf_size, folder_name.c_str(), dmsg->d_name);
std::string tmp = file_name;
if (tmp.find(".") == std::string::npos) {
if (tmp.find('.') == std::string::npos) {
RemoveDirectory(file_name);
}
remove(file_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册