MCPcopy Create free account
hub / github.com/antgroup/vsag / Deserialize

Method Deserialize

src/algorithm/ivf.cpp:618–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616 (reader).PopSeek();
617
618void
619IVF::Deserialize(StreamReader& reader) {
620 // try to deserialize footer (only in new version)
621 auto footer = Footer::Parse(reader);
622
623 BufferStreamReader buffer_reader(
624 &reader, std::numeric_limits<uint64_t>::max(), this->allocator_);
625
626 if (footer == nullptr) { // old format, DON'T EDIT, remove in the future
627 logger::debug("parse with v0.14 version format");
628
629 StreamReader::ReadObj(buffer_reader, this->total_elements_);
630 StreamReader::ReadObj(buffer_reader, this->use_reorder_);
631 StreamReader::ReadObj(buffer_reader, this->is_trained_);
632
633 this->bucket_->Deserialize(buffer_reader);
634 this->partition_strategy_->Deserialize(buffer_reader);
635 this->label_table_->Deserialize(buffer_reader);
636 if (use_reorder_) {
637 this->reorder_codes_->Deserialize(buffer_reader);
638 }
639
640 if (use_attribute_filter_) {
641 this->attr_filter_index_->Deserialize(buffer_reader);
642 this->has_attribute_ = true;
643 }
644 } else { // create like `else if ( ver in [v0.15, v0.17] )` here if need in the future
645 logger::debug("parse with new version format");
646
647 auto metadata = footer->GetMetadata();
648 if (metadata->EmptyIndex()) {
649 return;
650 }
651
652 auto basic_info = metadata->Get(BASIC_INFO);
653 this->total_elements_ = basic_info["total_elements"].GetInt();
654 this->use_reorder_ = basic_info["use_reorder"].GetBool();
655 this->is_trained_ = basic_info["is_trained"].GetBool();
656 if (basic_info.Contains(INDEX_PARAM)) {
657 auto param_str = basic_info[INDEX_PARAM].GetString();
658 auto index_param = std::make_shared<IVFParameter>();
659 index_param->FromString(param_str);
660 if (not this->create_param_ptr_->CheckCompatibility(index_param)) {
661 auto message = fmt::format("IVF index parameter not match, current: {}, new: {}",
662 this->create_param_ptr_->ToString(),
663 index_param->ToString());
664 logger::error(message);
665 throw VsagException(ErrorType::INVALID_ARGUMENT, message);
666 }
667 }
668
669 JsonType datacell_offsets = metadata->Get(DATACELL_OFFSETS);
670 logger::debug("datacell_offsets: {}", datacell_offsets.Dump());
671 JsonType datacell_sizes = metadata->Get(DATACELL_SIZES);
672 logger::debug("datacell_sizes: {}", datacell_sizes.Dump());
673
674 READ_DATACELL_WITH_NAME(buffer_reader, "bucket", this->bucket_);
675 READ_DATACELL_WITH_NAME(buffer_reader, "partition_strategy", this->partition_strategy_);

Callers

nothing calls this directly

Calls 15

fill_location_mapMethod · 0.95
cal_memory_usageMethod · 0.95
VsagExceptionClass · 0.85
EmptyIndexMethod · 0.80
GetIntMethod · 0.80
GetBoolMethod · 0.80
GetStringMethod · 0.80
FromStringMethod · 0.80
debugFunction · 0.50
errorFunction · 0.50
GetMetadataMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected