fix: Skip loading primary key if index has raw data (#39921)

issue: https://github.com/milvus-io/milvus/issues/39907

Signed-off-by: sunby <sunbingyi1992@gmail.com>
This commit is contained in:
Bingyi Sun 2025-03-06 17:46:02 +08:00 committed by GitHub
parent 7fbeb5624e
commit 37b118d55d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -201,46 +201,6 @@ ChunkedSegmentSealedImpl::LoadScalarIndex(const LoadIndexInfo& info) {
scalar_indexings_[field_id] =
std::move(const_cast<LoadIndexInfo&>(info).index);
// reverse pk from scalar index and set pks to offset
if (schema_->get_primary_field_id() == field_id) {
AssertInfo(field_id.get() != -1, "Primary key is -1");
switch (field_meta.get_data_type()) {
case DataType::INT64: {
auto int64_index = dynamic_cast<index::ScalarIndex<int64_t>*>(
scalar_indexings_[field_id].get());
if (!is_sorted_by_pk_ && insert_record_.empty_pks() &&
int64_index->HasRawData()) {
for (int i = 0; i < row_count; ++i) {
auto raw = int64_index->Reverse_Lookup(i);
AssertInfo(raw.has_value(), "pk not found");
insert_record_.insert_pk(raw.value(), i);
}
insert_record_.seal_pks();
}
break;
}
case DataType::VARCHAR: {
auto string_index =
dynamic_cast<index::ScalarIndex<std::string>*>(
scalar_indexings_[field_id].get());
if (!is_sorted_by_pk_ && insert_record_.empty_pks() &&
string_index->HasRawData()) {
for (int i = 0; i < row_count; ++i) {
auto raw = string_index->Reverse_Lookup(i);
AssertInfo(raw.has_value(), "pk not found");
insert_record_.insert_pk(raw.value(), i);
}
insert_record_.seal_pks();
}
break;
}
default: {
PanicInfo(DataTypeInvalid,
fmt::format("unsupported primary key type {}",
field_meta.get_data_type()));
}
}
}
set_bit(index_ready_bitset_, field_id, true);
update_row_count(row_count);