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

Method Serialize

src/algorithm/ivf.cpp:575–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

573 offset += datacell##_size;
574
575void
576IVF::Serialize(StreamWriter& writer) const {
577 JsonType datacell_offsets;
578 JsonType datacell_sizes;
579 uint64_t offset = 0;
580
581 WRITE_DATACELL_WITH_NAME(writer, "bucket", bucket_);
582 WRITE_DATACELL_WITH_NAME(writer, "partition_strategy", partition_strategy_);
583 WRITE_DATACELL_WITH_NAME(writer, "label_table", label_table_);
584
585 if (use_reorder_) {
586 WRITE_DATACELL_WITH_NAME(writer, "reorder_codes", reorder_codes_);
587 }
588
589 if (use_attribute_filter_) {
590 WRITE_DATACELL_WITH_NAME(writer, "attr_filter_index", attr_filter_index_);
591 }
592
593 // serialize footer (introduced since v0.15)
594 JsonType basic_info;
595 basic_info["total_elements"].SetInt(this->total_elements_);
596 basic_info["use_reorder"].SetBool(this->use_reorder_);
597 basic_info["is_trained"].SetBool(this->is_trained_);
598 basic_info[DIM].SetInt(this->dim_);
599 basic_info[EXTRA_INFO_SIZE].SetInt(0);
600 basic_info[INDEX_PARAM].SetString(this->create_param_ptr_->ToString());
601 basic_info["data_type"].SetInt(static_cast<int64_t>(this->data_type_));
602 basic_info["metric"].SetInt(static_cast<int64_t>(this->metric_));
603
604 auto metadata = std::make_shared<Metadata>();
605 metadata->Set(BASIC_INFO, basic_info);
606 metadata->Set("datacell_offsets", datacell_offsets);
607 metadata->Set("datacell_sizes", datacell_sizes);
608
609 auto footer = std::make_shared<Footer>(metadata);
610 footer->Write(writer);
611}
612
613#define READ_DATACELL_WITH_NAME(reader, name, datacell) \
614 reader.PushSeek(datacell_offsets[(name)].GetInt()); \

Callers 1

check_merge_illegalMethod · 0.45

Calls 6

SetIntMethod · 0.80
SetBoolMethod · 0.80
SetStringMethod · 0.80
ToStringMethod · 0.45
SetMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected