MCPcopy Create free account
hub / github.com/alibaba/zvec / load

Method load

tools/core/flow.h:460–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458 }
459
460 int load(const std::string &path) {
461 if (streamer_) {
462 stg_ = IndexFactory::CreateStorage("MMapFileStorage");
463 if (!stg_) {
464 return IndexError_NoExist;
465 }
466 ailego::Params params;
467 params.set("proxima.mmap_file.storage.memory_warmup", true);
468 int ret = stg_->init(params);
469 if (ret != 0) {
470 return ret;
471 }
472 ret = stg_->open(path, true);
473 if (ret != 0) {
474 return ret;
475 }
476
477 if (!inited_) {
478 IndexMeta meta;
479 ret = IndexHelper::DeserializeFromStorage(stg_.get(), &meta);
480 if (ret != 0) {
481 LOG_ERROR("Failed to get IndexMeta from Storage");
482 return ret;
483 }
484
485 ret = streamer_->init(meta, searcher_params_);
486 if (ret != 0) {
487 return ret;
488 }
489
490 if (!meta.reformer_name().empty()) {
491 reformer_ = IndexFactory::CreateReformer(meta.reformer_name());
492 if (!reformer_) {
493 LOG_ERROR("Failed to create reformer %s",
494 meta.reformer_name().c_str());
495 return IndexError_NoExist;
496 }
497 reformer_->init(meta.reformer_params());
498 // Load converter state (e.g. rotator) so queries are transformed
499 // into the same space as the stored codes.
500 ret = reformer_->load(stg_);
501 if (ret != 0) {
502 LOG_ERROR("Failed to load reformer state from storage");
503 return ret;
504 }
505 }
506 }
507
508 return streamer_->open(stg_);
509 } else {
510 return flow_.load(path);
511 }
512
513 return 0;
514 }
515
516 int unload() {
517 if (streamer_) {

Callers

nothing calls this directly

Calls 7

c_strMethod · 0.80
setMethod · 0.45
initMethod · 0.45
openMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected