Skip to content

Commit

Permalink
fix: Convert C-Style Casts to C++-Style Type Casts
Browse files Browse the repository at this point in the history
issue: #35900

Signed-off-by: Abdullah Ahmed <abdullahdb6@gmail.com>
  • Loading branch information
abd-770 committed Sep 30, 2024
1 parent a05a37a commit 6e58ba0
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 75 deletions.
18 changes: 9 additions & 9 deletions internal/core/src/common/binary_set_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<knowhere::BinarySet*>(c_binary_set);

Check warning on line 40 in internal/core/src/common/binary_set_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/binary_set_c.cpp#L40

Added line #L40 was not covered by tests
delete binary_set;
}

Expand All @@ -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<knowhere::BinarySet*>(c_binary_set);

Check warning on line 51 in internal/core/src/common/binary_set_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/binary_set_c.cpp#L51

Added line #L51 was not covered by tests
std::string index_key(c_index_key);
uint8_t* index = (uint8_t*)index_binary;
uint8_t* index = static_cast<uint8_t*>(index_binary);

Check warning on line 53 in internal/core/src/common/binary_set_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/binary_set_c.cpp#L53

Added line #L53 was not covered by tests
uint8_t* dup = new uint8_t[index_size]();
memcpy(dup, index, index_size);
std::shared_ptr<uint8_t[]> data(dup);
Expand All @@ -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<knowhere::BinarySet*>(c_binary_set);

Check warning on line 70 in internal/core/src/common/binary_set_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/binary_set_c.cpp#L70

Added line #L70 was not covered by tests
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<knowhere::BinarySet*>(c_binary_set);

Check warning on line 76 in internal/core/src/common/binary_set_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/binary_set_c.cpp#L76

Added line #L76 was not covered by tests
auto& map_ = binary_set->binary_map_;
const char** data_ = (const char**)data;
const char** data_ = static_cast<const char**>(data);

Check warning on line 78 in internal/core/src/common/binary_set_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/binary_set_c.cpp#L78

Added line #L78 was not covered by tests
std::size_t i = 0;
for (auto it = map_.begin(); it != map_.end(); ++it, i++) {
data_[i] = it->first.c_str();
Expand All @@ -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<knowhere::BinarySet*>(c_binary_set);

Check warning on line 87 in internal/core/src/common/binary_set_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/binary_set_c.cpp#L87

Added line #L87 was not covered by tests
int64_t ret_ = 0;
try {
std::string key_(key);
Expand All @@ -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<knowhere::BinarySet*>(c_binary_set);

Check warning on line 101 in internal/core/src/common/binary_set_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/binary_set_c.cpp#L101

Added line #L101 was not covered by tests
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<uint8_t*>(data), binary->data.get(), binary->size);

Check warning on line 106 in internal/core/src/common/binary_set_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/common/binary_set_c.cpp#L106

Added line #L106 was not covered by tests
} catch (std::exception& e) {
status.error_code = milvus::ErrorCode::UnexpectedError;
status.error_msg = strdup(e.what());
Expand Down
8 changes: 4 additions & 4 deletions internal/core/src/exec/expression/TermExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(offset.get());

Check warning on line 181 in internal/core/src/exec/expression/TermExpr.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/exec/expression/TermExpr.cpp#L181

Added line #L181 was not covered by tests
cached_bits_[_offset] = true;
}
cached_bits_inited_ = true;
Expand Down Expand Up @@ -515,10 +515,10 @@ PhyTermFilterExpr::ExecVisitorImplForIndex<bool>() {
for (auto& val : expr_->vals_) {
vals.emplace_back(GetValueFromProto<bool>(val) ? 1 : 0);
}
auto execute_sub_batch = [](Index* index_ptr,
const std::vector<uint8_t>& vals) {
auto execute_sub_batch = [](Index* index_ptr, std::vector<uint8_t>& vals) {

Check warning on line 518 in internal/core/src/exec/expression/TermExpr.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/exec/expression/TermExpr.cpp#L518

Added line #L518 was not covered by tests
TermIndexFunc<bool> func;
return std::move(func(index_ptr, vals.size(), (bool*)vals.data()));
return std::move(
func(index_ptr, vals.size(), reinterpret_cast<bool*>(vals.data())));

Check warning on line 521 in internal/core/src/exec/expression/TermExpr.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/exec/expression/TermExpr.cpp#L520-L521

Added lines #L520 - L521 were not covered by tests
};
auto res = ProcessIndexChunks<bool>(execute_sub_batch, vals);
return std::make_shared<ColumnVector>(std::move(res));
Expand Down
10 changes: 7 additions & 3 deletions internal/core/src/index/ScalarIndexSort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ ScalarIndexSort<T>::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<size_t>(index_length->size));

Check warning on line 171 in internal/core/src/index/ScalarIndexSort.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/index/ScalarIndexSort.cpp#L169-L171

Added lines #L169 - L171 were not covered by tests

auto index_data = index_binary.GetByName("index_data");
data_.resize(index_size);
Expand All @@ -176,7 +178,9 @@ ScalarIndexSort<T>::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<size_t>(index_data->size));

Check warning on line 183 in internal/core/src/index/ScalarIndexSort.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/index/ScalarIndexSort.cpp#L181-L183

Added lines #L181 - L183 were not covered by tests
for (size_t i = 0; i < data_.size(); ++i) {
idx_to_offsets_[data_[i].idx_] = i;
valid_bitset.set(data_[i].idx_);
Expand Down Expand Up @@ -207,7 +211,7 @@ ScalarIndexSort<T>::Load(milvus::tracer::TraceContext ctx,
auto size = data->DataSize();
auto deleter = [&](uint8_t*) {}; // avoid repeated deconstruction
auto buf = std::shared_ptr<uint8_t[]>(
(uint8_t*)const_cast<void*>(data->Data()), deleter);
static_cast<uint8_t*>(const_cast<void*>(data->Data())), deleter);

Check warning on line 214 in internal/core/src/index/ScalarIndexSort.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/index/ScalarIndexSort.cpp#L214

Added line #L214 was not covered by tests
binary_set.Append(key, buf, size);
}

Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/index/StringIndexMarisa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[]>(
(uint8_t*)const_cast<void*>(data->Data()), deleter);
static_cast<uint8_t*>(const_cast<void*>(data->Data())), deleter);

Check warning on line 242 in internal/core/src/index/StringIndexMarisa.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/index/StringIndexMarisa.cpp#L242

Added line #L242 was not covered by tests
binary_set.Append(key, buf, size);
}

Expand Down
7 changes: 4 additions & 3 deletions internal/core/src/index/VectorDiskIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ VectorDiskAnnIndex<T>::BuildWithDataset(const DatasetPtr& dataset,
}

int64_t offset = 0;
auto num = uint32_t(milvus::GetDatasetRows(dataset));
auto num = static_cast<uint32_t>(milvus::GetDatasetRows(dataset));

Check warning on line 216 in internal/core/src/index/VectorDiskIndex.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/index/VectorDiskIndex.cpp#L216

Added line #L216 was not covered by tests
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<uint32_t>(milvus::GetDatasetDim(dataset));

Check warning on line 220 in internal/core/src/index/VectorDiskIndex.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/index/VectorDiskIndex.cpp#L220

Added line #L220 was not covered by tests
local_chunk_manager->Write(local_data_path, offset, &dim, sizeof(dim));
offset += sizeof(dim);

Expand Down Expand Up @@ -256,7 +256,8 @@ VectorDiskAnnIndex<T>::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<int>(search_beamwidth_);

Check warning on line 260 in internal/core/src/index/VectorDiskIndex.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/index/VectorDiskIndex.cpp#L259-L260

Added lines #L259 - L260 were not covered by tests
// set json reset field, will be removed later
search_config[DISK_ANN_PQ_CODE_BUDGET] = 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion internal/core/src/index/VectorMemIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ VectorMemIndex<T>::Load(milvus::tracer::TraceContext ctx,
auto size = data->Size();
auto deleter = [&](uint8_t*) {}; // avoid repeated deconstruction
auto buf = std::shared_ptr<uint8_t[]>(
(uint8_t*)const_cast<void*>(data->Data()), deleter);
static_cast<uint8_t*>(const_cast<void*>(data->Data())), deleter);

Check warning on line 249 in internal/core/src/index/VectorMemIndex.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/index/VectorMemIndex.cpp#L249

Added line #L249 was not covered by tests
binary_set.Append(key, buf, size);
}

Expand Down
28 changes: 18 additions & 10 deletions internal/core/src/indexbuilder/index_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<BuildIndexInfo*>(c_build_index_info);

Check warning on line 586 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L586

Added line #L586 was not covered by tests
delete info;
}

Expand All @@ -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 =

Check warning on line 595 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L595

Added line #L595 was not covered by tests
static_cast<BuildIndexInfo*>(c_build_index_info);
auto index_params =
std::make_unique<milvus::proto::indexcgo::IndexParams>();
auto res = index_params->ParseFromArray(serialized_index_params, len);
Expand All @@ -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 =

Check warning on line 623 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L623

Added line #L623 was not covered by tests
static_cast<BuildIndexInfo*>(c_build_index_info);
auto type_params =
std::make_unique<milvus::proto::indexcgo::TypeParams>();
auto res = type_params->ParseFromArray(serialized_type_params, len);
Expand Down Expand Up @@ -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 =

Check warning on line 656 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L656

Added line #L656 was not covered by tests
static_cast<BuildIndexInfo*>(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;
Expand All @@ -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 =

Check warning on line 680 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L680

Added line #L680 was not covered by tests
static_cast<BuildIndexInfo*>(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;
Expand All @@ -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 =

Check warning on line 707 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L707

Added line #L707 was not covered by tests
static_cast<BuildIndexInfo*>(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;
Expand All @@ -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 =

Check warning on line 729 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L729

Added line #L729 was not covered by tests
static_cast<BuildIndexInfo*>(c_build_index_info);
std::string insert_file_path(c_file_path);
build_index_info->insert_files.emplace_back(insert_file_path);

Expand All @@ -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<BuildIndexInfo*>(c_load_index_info);

Check warning on line 747 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L747

Added line #L747 was not covered by tests
build_index_info->index_engine_version = index_engine_version;

auto status = CStatus();
Expand All @@ -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 =

Check warning on line 765 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L765

Added line #L765 was not covered by tests
static_cast<BuildIndexInfo*>(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;
Expand Down Expand Up @@ -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 =

Check warning on line 813 in internal/core/src/indexbuilder/index_c.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/indexbuilder/index_c.cpp#L813

Added line #L813 was not covered by tests
static_cast<BuildIndexInfo*>(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()) {
Expand Down
4 changes: 3 additions & 1 deletion internal/core/src/log/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check warning on line 135 in internal/core/src/log/Log.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/log/Log.cpp#L135

Added line #L135 was not covered by tests
"%lld ",
reinterpret_cast<long long*>(&val)); // NOLINT
if (i == 22) {
break;
}
Expand Down
4 changes: 2 additions & 2 deletions internal/core/src/query/SearchOnGrowing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(bitset.size()),
segment.get_active_count(timestamp));

Check warning on line 76 in internal/core/src/query/SearchOnGrowing.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/query/SearchOnGrowing.cpp#L75-L76

Added lines #L75 - L76 were not covered by tests

// step 1.1: get meta
// step 1.2: get which vector field to search
Expand Down
12 changes: 6 additions & 6 deletions internal/core/src/segcore/FieldIndexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check warning on line 201 in internal/core/src/segcore/FieldIndexing.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/FieldIndexing.cpp#L201

Added line #L201 was not covered by tests
static_cast<const float*>(
field_raw_data->get_chunk_data(chunk_id)) +

Check warning on line 203 in internal/core/src/segcore/FieldIndexing.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/FieldIndexing.cpp#L203

Added line #L203 was not covered by tests
chunk_offset * dim,
chunk_copysz * dim * sizeof(float));

Check warning on line 205 in internal/core/src/segcore/FieldIndexing.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/FieldIndexing.cpp#L205

Added line #L205 was not covered by tests
offset += chunk_copysz;
}
data_addr = vec_data.get();
Expand Down Expand Up @@ -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<const float*>(source->get_chunk_data(chunk_id)) +

Check warning on line 252 in internal/core/src/segcore/FieldIndexing.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/FieldIndexing.cpp#L252

Added line #L252 was not covered by tests
chunk_offset * dim);
index_->AddWithDataset(dataset, conf);
index_cur_.fetch_add(chunk_sz);
Expand Down
8 changes: 5 additions & 3 deletions internal/core/src/segcore/IndexConfigGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(config_.get_chunk_rows()) /
static_cast<int>(config_.get_nlist()),
48));

Check warning on line 53 in internal/core/src/segcore/IndexConfigGenerator.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/IndexConfigGenerator.cpp#L50-L53

Added lines #L50 - L53 were not covered by tests
search_params_[knowhere::indexparam::NPROBE] =
std::to_string(config_.get_nprobe());
// note for sparse vector index: drop_ratio_build is not allowed for growing
Expand All @@ -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<int64_t>(max_index_row_count_ * ratio),

Check warning on line 76 in internal/core/src/segcore/IndexConfigGenerator.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/IndexConfigGenerator.cpp#L76

Added line #L76 was not covered by tests
config_.get_nlist() * 39);
}

Expand Down
6 changes: 4 additions & 2 deletions internal/core/src/segcore/SegmentGrowingImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ SegmentGrowingImpl::bulk_subscript(FieldId field_id,
DataType::VECTOR_SPARSE_FLOAT) {
bulk_subscript_sparse_float_vector_impl(
field_id,
(const ConcurrentVector<SparseFloatVector>*)vec_ptr,
static_cast<const ConcurrentVector<SparseFloatVector>*>(
vec_ptr),
seg_offsets,
count,
result->mutable_vectors()->mutable_sparse_float_vector());
Expand Down Expand Up @@ -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<const uint8_t*>(
vec.get_element(offset));

Check warning on line 727 in internal/core/src/segcore/SegmentGrowingImpl.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/SegmentGrowingImpl.cpp#L726-L727

Added lines #L726 - L727 were not covered by tests
memcpy(dst, src, element_sizeof);
}
}
Expand Down
6 changes: 4 additions & 2 deletions internal/core/src/segcore/SegmentInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ SegmentInternalInterface::Search(
query::ExecPlanNodeVisitor visitor(*this, timestamp, placeholder_group);
auto results = std::make_unique<SearchResult>();
*results = visitor.get_moved_result(*plan->plan_node_);
results->segment_ = (void*)this;
results->segment_ = static_cast<void*>(

Check warning on line 89 in internal/core/src/segcore/SegmentInterface.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/SegmentInterface.cpp#L89

Added line #L89 was not covered by tests
const_cast<milvus::segcore::SegmentInternalInterface*>(this));
return results;
}

Expand All @@ -101,7 +102,8 @@ SegmentInternalInterface::Retrieve(tracer::TraceContext* trace_ctx,
auto results = std::make_unique<proto::segcore::RetrieveResults>();
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<void*>(

Check warning on line 105 in internal/core/src/segcore/SegmentInterface.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/SegmentInterface.cpp#L105

Added line #L105 was not covered by tests
const_cast<milvus::segcore::SegmentInternalInterface*>(this));
results->set_has_more_result(retrieve_results.has_more_result);

auto result_rows = retrieve_results.result_offsets_.size();
Expand Down
6 changes: 3 additions & 3 deletions internal/core/src/segcore/SegmentSealedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(vector_indexings_.is_ready(field_id));

Check warning on line 655 in internal/core/src/segcore/SegmentSealedImpl.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/SegmentSealedImpl.cpp#L655

Added line #L655 was not covered by tests
}

return scalar_indexings_.count(field_id);
Expand Down Expand Up @@ -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<const void*>(vec_data->Data()));

Check warning on line 1982 in internal/core/src/segcore/SegmentSealedImpl.cpp

View check run for this annotation

Codecov / codecov/patch

internal/core/src/segcore/SegmentSealedImpl.cpp#L1981-L1982

Added lines #L1981 - L1982 were not covered by tests
dataset->SetIsOwner(false);
dataset->SetIsSparse(is_sparse);

Expand Down
Loading

0 comments on commit 6e58ba0

Please sign in to comment.