From 6e58ba0670cf8b5ab7a801a640a10133bfbdc816 Mon Sep 17 00:00:00 2001 From: Abdullah Ahmed Date: Mon, 30 Sep 2024 03:02:45 -0700 Subject: [PATCH] fix: Convert C-Style Casts to C++-Style Type Casts issue: #35900 Signed-off-by: Abdullah Ahmed --- internal/core/src/common/binary_set_c.cpp | 18 ++++++------ .../core/src/exec/expression/TermExpr.cpp | 8 +++--- internal/core/src/index/ScalarIndexSort.cpp | 10 +++++-- internal/core/src/index/StringIndexMarisa.cpp | 2 +- internal/core/src/index/VectorDiskIndex.cpp | 7 +++-- internal/core/src/index/VectorMemIndex.cpp | 2 +- internal/core/src/indexbuilder/index_c.cpp | 28 ++++++++++++------- internal/core/src/log/Log.cpp | 4 ++- internal/core/src/query/SearchOnGrowing.cpp | 4 +-- internal/core/src/segcore/FieldIndexing.cpp | 12 ++++---- .../core/src/segcore/IndexConfigGenerator.cpp | 8 ++++-- .../core/src/segcore/SegmentGrowingImpl.cpp | 6 ++-- .../core/src/segcore/SegmentInterface.cpp | 6 ++-- .../core/src/segcore/SegmentSealedImpl.cpp | 6 ++-- internal/core/src/segcore/collection_c.cpp | 6 ++-- internal/core/src/segcore/load_index_c.cpp | 28 ++++++++++--------- internal/core/src/segcore/plan_c.cpp | 14 ++++++---- internal/core/src/segcore/segment_c.cpp | 4 +-- .../boost_ext/dynamic_bitset_ext.cpp | 2 +- 19 files changed, 100 insertions(+), 75 deletions(-) diff --git a/internal/core/src/common/binary_set_c.cpp b/internal/core/src/common/binary_set_c.cpp index 5de5fa0f18bb2..01f49328c6542 100644 --- a/internal/core/src/common/binary_set_c.cpp +++ b/internal/core/src/common/binary_set_c.cpp @@ -37,7 +37,7 @@ NewBinarySet(CBinarySet* c_binary_set) { void DeleteBinarySet(CBinarySet c_binary_set) { - auto binary_set = (knowhere::BinarySet*)c_binary_set; + auto binary_set = static_cast(c_binary_set); delete binary_set; } @@ -48,9 +48,9 @@ AppendIndexBinary(CBinarySet c_binary_set, const char* c_index_key) { auto status = CStatus(); try { - auto binary_set = (knowhere::BinarySet*)c_binary_set; + auto binary_set = static_cast(c_binary_set); std::string index_key(c_index_key); - uint8_t* index = (uint8_t*)index_binary; + uint8_t* index = static_cast(index_binary); uint8_t* dup = new uint8_t[index_size](); memcpy(dup, index, index_size); std::shared_ptr data(dup); @@ -67,15 +67,15 @@ AppendIndexBinary(CBinarySet c_binary_set, int GetBinarySetSize(CBinarySet c_binary_set) { - auto binary_set = (knowhere::BinarySet*)c_binary_set; + auto binary_set = static_cast(c_binary_set); return binary_set->binary_map_.size(); } void GetBinarySetKeys(CBinarySet c_binary_set, void* data) { - auto binary_set = (knowhere::BinarySet*)c_binary_set; + auto binary_set = static_cast(c_binary_set); auto& map_ = binary_set->binary_map_; - const char** data_ = (const char**)data; + const char** data_ = static_cast(data); std::size_t i = 0; for (auto it = map_.begin(); it != map_.end(); ++it, i++) { data_[i] = it->first.c_str(); @@ -84,7 +84,7 @@ GetBinarySetKeys(CBinarySet c_binary_set, void* data) { int GetBinarySetValueSize(CBinarySet c_binary_set, const char* key) { - auto binary_set = (knowhere::BinarySet*)c_binary_set; + auto binary_set = static_cast(c_binary_set); int64_t ret_ = 0; try { std::string key_(key); @@ -98,12 +98,12 @@ GetBinarySetValueSize(CBinarySet c_binary_set, const char* key) { CStatus CopyBinarySetValue(void* data, const char* key, CBinarySet c_binary_set) { auto status = CStatus(); - auto binary_set = (knowhere::BinarySet*)c_binary_set; + auto binary_set = static_cast(c_binary_set); try { auto binary = binary_set->GetByName(key); status.error_code = milvus::ErrorCode::Success; status.error_msg = ""; - memcpy((uint8_t*)data, binary->data.get(), binary->size); + memcpy(static_cast(data), binary->data.get(), binary->size); } catch (std::exception& e) { status.error_code = milvus::ErrorCode::UnexpectedError; status.error_msg = strdup(e.what()); diff --git a/internal/core/src/exec/expression/TermExpr.cpp b/internal/core/src/exec/expression/TermExpr.cpp index c4fe5234f7202..a43275146f24c 100644 --- a/internal/core/src/exec/expression/TermExpr.cpp +++ b/internal/core/src/exec/expression/TermExpr.cpp @@ -178,7 +178,7 @@ PhyTermFilterExpr::InitPkCacheOffset() { segment_->search_ids(*id_array, query_timestamp_); cached_bits_.resize(active_count_, false); for (const auto& offset : seg_offsets) { - auto _offset = (int64_t)offset.get(); + auto _offset = static_cast(offset.get()); cached_bits_[_offset] = true; } cached_bits_inited_ = true; @@ -515,10 +515,10 @@ PhyTermFilterExpr::ExecVisitorImplForIndex() { for (auto& val : expr_->vals_) { vals.emplace_back(GetValueFromProto(val) ? 1 : 0); } - auto execute_sub_batch = [](Index* index_ptr, - const std::vector& vals) { + auto execute_sub_batch = [](Index* index_ptr, std::vector& vals) { TermIndexFunc func; - return std::move(func(index_ptr, vals.size(), (bool*)vals.data())); + return std::move( + func(index_ptr, vals.size(), reinterpret_cast(vals.data()))); }; auto res = ProcessIndexChunks(execute_sub_batch, vals); return std::make_shared(std::move(res)); diff --git a/internal/core/src/index/ScalarIndexSort.cpp b/internal/core/src/index/ScalarIndexSort.cpp index 56396d7d192f3..b6d4fc4fe8ad0 100644 --- a/internal/core/src/index/ScalarIndexSort.cpp +++ b/internal/core/src/index/ScalarIndexSort.cpp @@ -166,7 +166,9 @@ ScalarIndexSort::LoadWithoutAssemble(const BinarySet& index_binary, const Config& config) { size_t index_size; auto index_length = index_binary.GetByName("index_length"); - memcpy(&index_size, index_length->data.get(), (size_t)index_length->size); + memcpy(&index_size, + index_length->data.get(), + static_cast(index_length->size)); auto index_data = index_binary.GetByName("index_data"); data_.resize(index_size); @@ -176,7 +178,9 @@ ScalarIndexSort::LoadWithoutAssemble(const BinarySet& index_binary, (size_t)index_num_rows->size); idx_to_offsets_.resize(total_num_rows_); valid_bitset = TargetBitmap(total_num_rows_, false); - memcpy(data_.data(), index_data->data.get(), (size_t)index_data->size); + memcpy(data_.data(), + index_data->data.get(), + static_cast(index_data->size)); for (size_t i = 0; i < data_.size(); ++i) { idx_to_offsets_[data_[i].idx_] = i; valid_bitset.set(data_[i].idx_); @@ -207,7 +211,7 @@ ScalarIndexSort::Load(milvus::tracer::TraceContext ctx, auto size = data->DataSize(); auto deleter = [&](uint8_t*) {}; // avoid repeated deconstruction auto buf = std::shared_ptr( - (uint8_t*)const_cast(data->Data()), deleter); + static_cast(const_cast(data->Data())), deleter); binary_set.Append(key, buf, size); } diff --git a/internal/core/src/index/StringIndexMarisa.cpp b/internal/core/src/index/StringIndexMarisa.cpp index 7207b75694c5a..0cb55e940b893 100644 --- a/internal/core/src/index/StringIndexMarisa.cpp +++ b/internal/core/src/index/StringIndexMarisa.cpp @@ -239,7 +239,7 @@ StringIndexMarisa::Load(milvus::tracer::TraceContext ctx, auto size = data->DataSize(); auto deleter = [&](uint8_t*) {}; // avoid repeated deconstruction auto buf = std::shared_ptr( - (uint8_t*)const_cast(data->Data()), deleter); + static_cast(const_cast(data->Data())), deleter); binary_set.Append(key, buf, size); } diff --git a/internal/core/src/index/VectorDiskIndex.cpp b/internal/core/src/index/VectorDiskIndex.cpp index e6360eb199159..5a05999745106 100644 --- a/internal/core/src/index/VectorDiskIndex.cpp +++ b/internal/core/src/index/VectorDiskIndex.cpp @@ -213,11 +213,11 @@ VectorDiskAnnIndex::BuildWithDataset(const DatasetPtr& dataset, } int64_t offset = 0; - auto num = uint32_t(milvus::GetDatasetRows(dataset)); + auto num = static_cast(milvus::GetDatasetRows(dataset)); local_chunk_manager->Write(local_data_path, offset, &num, sizeof(num)); offset += sizeof(num); - auto dim = uint32_t(milvus::GetDatasetDim(dataset)); + auto dim = static_cast(milvus::GetDatasetDim(dataset)); local_chunk_manager->Write(local_data_path, offset, &dim, sizeof(dim)); offset += sizeof(dim); @@ -256,7 +256,8 @@ VectorDiskAnnIndex::Query(const DatasetPtr dataset, search_info.search_params_[DISK_ANN_QUERY_LIST]; } // set beamwidth - search_config[DISK_ANN_QUERY_BEAMWIDTH] = int(search_beamwidth_); + search_config[DISK_ANN_QUERY_BEAMWIDTH] = + static_cast(search_beamwidth_); // set json reset field, will be removed later search_config[DISK_ANN_PQ_CODE_BUDGET] = 0.0; } diff --git a/internal/core/src/index/VectorMemIndex.cpp b/internal/core/src/index/VectorMemIndex.cpp index 6d7767fcf4e3d..047898bc81f91 100644 --- a/internal/core/src/index/VectorMemIndex.cpp +++ b/internal/core/src/index/VectorMemIndex.cpp @@ -246,7 +246,7 @@ VectorMemIndex::Load(milvus::tracer::TraceContext ctx, auto size = data->Size(); auto deleter = [&](uint8_t*) {}; // avoid repeated deconstruction auto buf = std::shared_ptr( - (uint8_t*)const_cast(data->Data()), deleter); + static_cast(const_cast(data->Data())), deleter); binary_set.Append(key, buf, size); } diff --git a/internal/core/src/indexbuilder/index_c.cpp b/internal/core/src/indexbuilder/index_c.cpp index f4f4613c72259..c4029417f5f2a 100644 --- a/internal/core/src/indexbuilder/index_c.cpp +++ b/internal/core/src/indexbuilder/index_c.cpp @@ -583,7 +583,7 @@ NewBuildIndexInfo(CBuildIndexInfo* c_build_index_info, void DeleteBuildIndexInfo(CBuildIndexInfo c_build_index_info) { - auto info = (BuildIndexInfo*)c_build_index_info; + auto info = static_cast(c_build_index_info); delete info; } @@ -592,7 +592,8 @@ AppendBuildIndexParam(CBuildIndexInfo c_build_index_info, const uint8_t* serialized_index_params, const uint64_t len) { try { - auto build_index_info = (BuildIndexInfo*)c_build_index_info; + auto build_index_info = + static_cast(c_build_index_info); auto index_params = std::make_unique(); auto res = index_params->ParseFromArray(serialized_index_params, len); @@ -619,7 +620,8 @@ AppendBuildTypeParam(CBuildIndexInfo c_build_index_info, const uint8_t* serialized_type_params, const uint64_t len) { try { - auto build_index_info = (BuildIndexInfo*)c_build_index_info; + auto build_index_info = + static_cast(c_build_index_info); auto type_params = std::make_unique(); auto res = type_params->ParseFromArray(serialized_type_params, len); @@ -651,7 +653,8 @@ AppendFieldMetaInfoV2(CBuildIndexInfo c_build_index_info, enum CDataType field_type, int64_t dim) { try { - auto build_index_info = (BuildIndexInfo*)c_build_index_info; + auto build_index_info = + static_cast(c_build_index_info); build_index_info->collection_id = collection_id; build_index_info->partition_id = partition_id; build_index_info->segment_id = segment_id; @@ -674,7 +677,8 @@ AppendFieldMetaInfo(CBuildIndexInfo c_build_index_info, int64_t field_id, enum CDataType field_type) { try { - auto build_index_info = (BuildIndexInfo*)c_build_index_info; + auto build_index_info = + static_cast(c_build_index_info); build_index_info->collection_id = collection_id; build_index_info->partition_id = partition_id; build_index_info->segment_id = segment_id; @@ -700,7 +704,8 @@ AppendIndexMetaInfo(CBuildIndexInfo c_build_index_info, int64_t build_id, int64_t version) { try { - auto build_index_info = (BuildIndexInfo*)c_build_index_info; + auto build_index_info = + static_cast(c_build_index_info); build_index_info->index_id = index_id; build_index_info->index_build_id = build_id; build_index_info->index_version = version; @@ -721,7 +726,8 @@ CStatus AppendInsertFilePath(CBuildIndexInfo c_build_index_info, const char* c_file_path) { try { - auto build_index_info = (BuildIndexInfo*)c_build_index_info; + auto build_index_info = + static_cast(c_build_index_info); std::string insert_file_path(c_file_path); build_index_info->insert_files.emplace_back(insert_file_path); @@ -738,7 +744,7 @@ CStatus AppendIndexEngineVersionToBuildInfo(CBuildIndexInfo c_load_index_info, int32_t index_engine_version) { try { - auto build_index_info = (BuildIndexInfo*)c_load_index_info; + auto build_index_info = static_cast(c_load_index_info); build_index_info->index_engine_version = index_engine_version; auto status = CStatus(); @@ -756,7 +762,8 @@ AppendIndexStorageInfo(CBuildIndexInfo c_build_index_info, const char* c_index_store_path, int64_t data_store_version) { try { - auto build_index_info = (BuildIndexInfo*)c_build_index_info; + auto build_index_info = + static_cast(c_build_index_info); std::string data_store_path(c_data_store_path), index_store_path(c_index_store_path); build_index_info->data_store_path = data_store_path; @@ -803,7 +810,8 @@ AppendOptionalFieldDataPath(CBuildIndexInfo c_build_index_info, const int32_t field_type, const char* c_file_path) { try { - auto build_index_info = (BuildIndexInfo*)c_build_index_info; + auto build_index_info = + static_cast(c_build_index_info); std::string field_name_str(field_name); auto& opt_fields_map = build_index_info->opt_fields; if (opt_fields_map.find(field_id) == opt_fields_map.end()) { diff --git a/internal/core/src/log/Log.cpp b/internal/core/src/log/Log.cpp index 64192107e1328..929cc0a617dba 100644 --- a/internal/core/src/log/Log.cpp +++ b/internal/core/src/log/Log.cpp @@ -132,7 +132,9 @@ get_thread_starttime() { thread_stat, "%lld %s %s ", (long long*)&val, comm, &state); // NOLINT for (auto i = 4; i < 23; i++) { - ret = fscanf(thread_stat, "%lld ", (long long*)&val); // NOLINT + ret = fscanf(thread_stat, + "%lld ", + reinterpret_cast(&val)); // NOLINT if (i == 22) { break; } diff --git a/internal/core/src/query/SearchOnGrowing.cpp b/internal/core/src/query/SearchOnGrowing.cpp index 0b722c2fa8485..c3fe2cc86ccad 100644 --- a/internal/core/src/query/SearchOnGrowing.cpp +++ b/internal/core/src/query/SearchOnGrowing.cpp @@ -72,8 +72,8 @@ SearchOnGrowing(const segcore::SegmentGrowingImpl& segment, SearchResult& search_result) { auto& schema = segment.get_schema(); auto& record = segment.get_insert_record(); - auto active_count = - std::min(int64_t(bitset.size()), segment.get_active_count(timestamp)); + auto active_count = std::min(static_cast(bitset.size()), + segment.get_active_count(timestamp)); // step 1.1: get meta // step 1.2: get which vector field to search diff --git a/internal/core/src/segcore/FieldIndexing.cpp b/internal/core/src/segcore/FieldIndexing.cpp index eb81947fcdba4..bb24accad8a35 100644 --- a/internal/core/src/segcore/FieldIndexing.cpp +++ b/internal/core/src/segcore/FieldIndexing.cpp @@ -198,11 +198,11 @@ VectorFieldIndexing::AppendSegmentIndexDense(int64_t reserved_offset, chunk_id == chunk_id_end ? vector_id_end - chunk_id * size_per_chunk + 1 : size_per_chunk; - std::memcpy( - vec_data.get() + offset * dim, - (const float*)field_raw_data->get_chunk_data(chunk_id) + - chunk_offset * dim, - chunk_copysz * dim * sizeof(float)); + std::memcpy(vec_data.get() + offset * dim, + static_cast( + field_raw_data->get_chunk_data(chunk_id)) + + chunk_offset * dim, + chunk_copysz * dim * sizeof(float)); offset += chunk_copysz; } data_addr = vec_data.get(); @@ -249,7 +249,7 @@ VectorFieldIndexing::AppendSegmentIndexDense(int64_t reserved_offset, auto dataset = knowhere::GenDataSet( chunk_sz, dim, - (const float*)source->get_chunk_data(chunk_id) + + static_cast(source->get_chunk_data(chunk_id)) + chunk_offset * dim); index_->AddWithDataset(dataset, conf); index_cur_.fetch_add(chunk_sz); diff --git a/internal/core/src/segcore/IndexConfigGenerator.cpp b/internal/core/src/segcore/IndexConfigGenerator.cpp index 0c0d041359a89..5303914dca0a3 100644 --- a/internal/core/src/segcore/IndexConfigGenerator.cpp +++ b/internal/core/src/segcore/IndexConfigGenerator.cpp @@ -47,8 +47,10 @@ VecIndexConfig::VecIndexConfig(const int64_t max_index_row_cout, build_params_[knowhere::meta::METRIC_TYPE] = metric_type_; build_params_[knowhere::indexparam::NLIST] = std::to_string(config_.get_nlist()); - build_params_[knowhere::indexparam::SSIZE] = std::to_string( - std::max((int)(config_.get_chunk_rows() / config_.get_nlist()), 48)); + build_params_[knowhere::indexparam::SSIZE] = + std::to_string(std::max(static_cast(config_.get_chunk_rows()) / + static_cast(config_.get_nlist()), + 48)); search_params_[knowhere::indexparam::NPROBE] = std::to_string(config_.get_nprobe()); // note for sparse vector index: drop_ratio_build is not allowed for growing @@ -71,7 +73,7 @@ VecIndexConfig::GetBuildThreshold() const noexcept { assert(VecIndexConfig::index_build_ratio.count(index_type_)); auto ratio = VecIndexConfig::index_build_ratio.at(index_type_); assert(ratio >= 0.0 && ratio < 1.0); - return std::max(int64_t(max_index_row_count_ * ratio), + return std::max(static_cast(max_index_row_count_ * ratio), config_.get_nlist() * 39); } diff --git a/internal/core/src/segcore/SegmentGrowingImpl.cpp b/internal/core/src/segcore/SegmentGrowingImpl.cpp index 8dc1304e6143e..1c48f7bcba437 100644 --- a/internal/core/src/segcore/SegmentGrowingImpl.cpp +++ b/internal/core/src/segcore/SegmentGrowingImpl.cpp @@ -496,7 +496,8 @@ SegmentGrowingImpl::bulk_subscript(FieldId field_id, DataType::VECTOR_SPARSE_FLOAT) { bulk_subscript_sparse_float_vector_impl( field_id, - (const ConcurrentVector*)vec_ptr, + static_cast*>( + vec_ptr), seg_offsets, count, result->mutable_vectors()->mutable_sparse_float_vector()); @@ -722,7 +723,8 @@ SegmentGrowingImpl::bulk_subscript_impl(FieldId field_id, if (offset == INVALID_SEG_OFFSET) { memset(dst, 0, element_sizeof); } else { - auto src = (const uint8_t*)vec.get_element(offset); + auto src = reinterpret_cast( + vec.get_element(offset)); memcpy(dst, src, element_sizeof); } } diff --git a/internal/core/src/segcore/SegmentInterface.cpp b/internal/core/src/segcore/SegmentInterface.cpp index b7b8efbf2418d..d8601b85edca9 100644 --- a/internal/core/src/segcore/SegmentInterface.cpp +++ b/internal/core/src/segcore/SegmentInterface.cpp @@ -86,7 +86,8 @@ SegmentInternalInterface::Search( query::ExecPlanNodeVisitor visitor(*this, timestamp, placeholder_group); auto results = std::make_unique(); *results = visitor.get_moved_result(*plan->plan_node_); - results->segment_ = (void*)this; + results->segment_ = static_cast( + const_cast(this)); return results; } @@ -101,7 +102,8 @@ SegmentInternalInterface::Retrieve(tracer::TraceContext* trace_ctx, auto results = std::make_unique(); query::ExecPlanNodeVisitor visitor(*this, timestamp); auto retrieve_results = visitor.get_retrieve_result(*plan->plan_node_); - retrieve_results.segment_ = (void*)this; + retrieve_results.segment_ = static_cast( + const_cast(this)); results->set_has_more_result(retrieve_results.has_more_result); auto result_rows = retrieve_results.result_offsets_.size(); diff --git a/internal/core/src/segcore/SegmentSealedImpl.cpp b/internal/core/src/segcore/SegmentSealedImpl.cpp index bf58838a164f2..bd111b0937618 100644 --- a/internal/core/src/segcore/SegmentSealedImpl.cpp +++ b/internal/core/src/segcore/SegmentSealedImpl.cpp @@ -652,7 +652,7 @@ int64_t SegmentSealedImpl::num_chunk_index(FieldId field_id) const { auto& field_meta = schema_->operator[](field_id); if (field_meta.is_vector()) { - return int64_t(vector_indexings_.is_ready(field_id)); + return static_cast(vector_indexings_.is_ready(field_id)); } return scalar_indexings_.count(field_id); @@ -1978,8 +1978,8 @@ SegmentSealedImpl::generate_interim_index(const FieldId field_id) { build_config[knowhere::meta::NUM_BUILD_THREAD] = std::to_string(1); auto index_metric = field_binlog_config->GetMetricType(); - auto dataset = - knowhere::GenDataSet(row_count, dim, (void*)vec_data->Data()); + auto dataset = knowhere::GenDataSet( + row_count, dim, static_cast(vec_data->Data())); dataset->SetIsOwner(false); dataset->SetIsSparse(is_sparse); diff --git a/internal/core/src/segcore/collection_c.cpp b/internal/core/src/segcore/collection_c.cpp index fde8119e086fe..56b385a07ead5 100644 --- a/internal/core/src/segcore/collection_c.cpp +++ b/internal/core/src/segcore/collection_c.cpp @@ -21,20 +21,20 @@ CCollection NewCollection(const void* schema_proto_blob, const int64_t length) { auto collection = std::make_unique( schema_proto_blob, length); - return (void*)collection.release(); + return static_cast(collection.release()); } void SetIndexMeta(CCollection collection, const void* proto_blob, const int64_t length) { - auto col = (milvus::segcore::Collection*)collection; + auto col = static_cast(collection); col->parseIndexMeta(proto_blob, length); } void DeleteCollection(CCollection collection) { - auto col = (milvus::segcore::Collection*)collection; + auto col = static_cast(collection); delete col; } diff --git a/internal/core/src/segcore/load_index_c.cpp b/internal/core/src/segcore/load_index_c.cpp index a4be79916568a..9907d400a0950 100644 --- a/internal/core/src/segcore/load_index_c.cpp +++ b/internal/core/src/segcore/load_index_c.cpp @@ -54,7 +54,7 @@ NewLoadIndexInfo(CLoadIndexInfo* c_load_index_info) { void DeleteLoadIndexInfo(CLoadIndexInfo c_load_index_info) { - auto info = (milvus::segcore::LoadIndexInfo*)c_load_index_info; + auto info = static_cast(c_load_index_info); delete info; } @@ -64,7 +64,7 @@ AppendIndexParam(CLoadIndexInfo c_load_index_info, const char* c_index_value) { try { auto load_index_info = - (milvus::segcore::LoadIndexInfo*)c_load_index_info; + static_cast(c_load_index_info); std::string index_key(c_index_key); std::string index_value(c_index_value); load_index_info->index_params[index_key] = index_value; @@ -92,7 +92,7 @@ AppendFieldInfo(CLoadIndexInfo c_load_index_info, const char* mmap_dir_path) { try { auto load_index_info = - (milvus::segcore::LoadIndexInfo*)c_load_index_info; + static_cast(c_load_index_info); load_index_info->collection_id = collection_id; load_index_info->partition_id = partition_id; load_index_info->segment_id = segment_id; @@ -117,8 +117,8 @@ CStatus appendVecIndex(CLoadIndexInfo c_load_index_info, CBinarySet c_binary_set) { try { auto load_index_info = - (milvus::segcore::LoadIndexInfo*)c_load_index_info; - auto binary_set = (knowhere::BinarySet*)c_binary_set; + static_cast(c_load_index_info); + auto binary_set = static_cast(c_binary_set); auto& index_params = load_index_info->index_params; milvus::index::CreateIndexInfo index_info; @@ -175,9 +175,9 @@ CStatus appendScalarIndex(CLoadIndexInfo c_load_index_info, CBinarySet c_binary_set) { try { auto load_index_info = - (milvus::segcore::LoadIndexInfo*)c_load_index_info; + static_cast(c_load_index_info); auto field_type = load_index_info->field_type; - auto binary_set = (knowhere::BinarySet*)c_binary_set; + auto binary_set = static_cast(c_binary_set); auto& index_params = load_index_info->index_params; bool find_index_type = index_params.count("index_type") > 0 ? true : false; @@ -206,7 +206,8 @@ appendScalarIndex(CLoadIndexInfo c_load_index_info, CBinarySet c_binary_set) { CStatus AppendIndex(CLoadIndexInfo c_load_index_info, CBinarySet c_binary_set) { - auto load_index_info = (milvus::segcore::LoadIndexInfo*)c_load_index_info; + auto load_index_info = + static_cast(c_load_index_info); auto field_type = load_index_info->field_type; if (milvus::IsVectorDataType(field_type)) { return appendVecIndex(c_load_index_info, c_binary_set); @@ -322,7 +323,7 @@ CStatus AppendIndexFilePath(CLoadIndexInfo c_load_index_info, const char* c_file_path) { try { auto load_index_info = - (milvus::segcore::LoadIndexInfo*)c_load_index_info; + static_cast(c_load_index_info); std::string index_file_path(c_file_path); load_index_info->index_files.emplace_back(index_file_path); @@ -345,7 +346,7 @@ AppendIndexInfo(CLoadIndexInfo c_load_index_info, int64_t version) { try { auto load_index_info = - (milvus::segcore::LoadIndexInfo*)c_load_index_info; + static_cast(c_load_index_info); load_index_info->index_id = index_id; load_index_info->index_build_id = build_id; load_index_info->index_version = version; @@ -367,7 +368,7 @@ AppendIndexEngineVersionToLoadInfo(CLoadIndexInfo c_load_index_info, int32_t index_engine_version) { try { auto load_index_info = - (milvus::segcore::LoadIndexInfo*)c_load_index_info; + static_cast(c_load_index_info); load_index_info->index_engine_version = index_engine_version; auto status = CStatus(); @@ -386,7 +387,7 @@ CStatus CleanLoadedIndex(CLoadIndexInfo c_load_index_info) { try { auto load_index_info = - (milvus::segcore::LoadIndexInfo*)c_load_index_info; + static_cast(c_load_index_info); auto local_chunk_manager = milvus::storage::LocalChunkManagerSingleton::GetInstance() .GetChunkManager(); @@ -411,7 +412,8 @@ void AppendStorageInfo(CLoadIndexInfo c_load_index_info, const char* uri, int64_t version) { - auto load_index_info = (milvus::segcore::LoadIndexInfo*)c_load_index_info; + auto load_index_info = + static_cast(c_load_index_info); load_index_info->uri = uri; load_index_info->index_store_version = version; } diff --git a/internal/core/src/segcore/plan_c.cpp b/internal/core/src/segcore/plan_c.cpp index 94614ca6c00b1..1d2169154a97e 100644 --- a/internal/core/src/segcore/plan_c.cpp +++ b/internal/core/src/segcore/plan_c.cpp @@ -20,7 +20,7 @@ CreateSearchPlanByExpr(CCollection c_col, const void* serialized_expr_plan, const int64_t size, CSearchPlan* res_plan) { - auto col = (milvus::segcore::Collection*)c_col; + auto col = static_cast(c_col); try { auto res = milvus::query::CreateSearchPlanByExpr( @@ -36,7 +36,7 @@ CreateSearchPlanByExpr(CCollection c_col, auto status = CStatus(); status.error_code = milvus::Success; status.error_msg = ""; - auto plan = (CSearchPlan)res.release(); + auto plan = static_cast(res.release()); *res_plan = plan; return status; } catch (milvus::SegcoreError& e) { @@ -59,16 +59,18 @@ ParsePlaceholderGroup(CSearchPlan c_plan, const void* placeholder_group_blob, const int64_t blob_size, CPlaceholderGroup* res_placeholder_group) { - auto plan = (milvus::query::Plan*)c_plan; + auto plan = static_cast(c_plan); try { auto res = milvus::query::ParsePlaceholderGroup( - plan, (const uint8_t*)(placeholder_group_blob), blob_size); + plan, + static_cast(placeholder_group_blob), + blob_size); auto status = CStatus(); status.error_code = milvus::Success; status.error_msg = ""; - auto group = (CPlaceholderGroup)res.release(); + auto group = static_cast(res.release()); *res_placeholder_group = group; return status; } catch (std::exception& e) { @@ -147,7 +149,7 @@ CreateRetrievePlanByExpr(CCollection c_col, auto status = CStatus(); status.error_code = milvus::Success; status.error_msg = ""; - auto plan = (CRetrievePlan)res.release(); + auto plan = static_cast(res.release()); *res_plan = plan; return status; } catch (milvus::SegcoreError& e) { diff --git a/internal/core/src/segcore/segment_c.cpp b/internal/core/src/segcore/segment_c.cpp index 0baa75345dbd2..5f456231757ee 100644 --- a/internal/core/src/segcore/segment_c.cpp +++ b/internal/core/src/segcore/segment_c.cpp @@ -98,8 +98,8 @@ AsyncSearch(CTraceContext c_trace, CSearchPlan c_plan, CPlaceholderGroup c_placeholder_group, uint64_t timestamp) { - auto segment = (milvus::segcore::SegmentInterface*)c_segment; - auto plan = (milvus::query::Plan*)c_plan; + auto segment = static_cast(c_segment); + auto plan = static_cast(c_plan); auto phg_ptr = reinterpret_cast( c_placeholder_group); diff --git a/internal/core/thirdparty/boost_ext/dynamic_bitset_ext.cpp b/internal/core/thirdparty/boost_ext/dynamic_bitset_ext.cpp index bbe110c991ac7..bc697699bd5c5 100644 --- a/internal/core/thirdparty/boost_ext/dynamic_bitset_ext.cpp +++ b/internal/core/thirdparty/boost_ext/dynamic_bitset_ext.cpp @@ -26,7 +26,7 @@ void from_block_range(PtrWrapper result, PtrWrapper resultB, dynamic_bitset<>& bitset) { - (void)resultB; + static_cast(resultB); result.ptr_ = reinterpret_cast(bitset.m_bits.data()); }