From 92983fcfbfa5cf9475cb5e2f061856372b333525 Mon Sep 17 00:00:00 2001 From: Xu Peng Date: Wed, 17 Apr 2019 12:23:00 +0800 Subject: [PATCH] fix(wrapper): fix write index Former-commit-id: 98af046872115568f3b4e7859bf6b6970b0655f6 --- cpp/src/wrapper/Index.cpp | 4 ++++ cpp/src/wrapper/Index.h | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cpp/src/wrapper/Index.cpp b/cpp/src/wrapper/Index.cpp index ef849bc2f7..351baf00d3 100644 --- a/cpp/src/wrapper/Index.cpp +++ b/cpp/src/wrapper/Index.cpp @@ -62,6 +62,10 @@ bool Index::search(idx_t n, const float *data, idx_t k, float *distances, long * return true; } +void write_index(const Index_ptr &index, const std::string &file_name) { + write_index(index->index_.get(), file_name.c_str()); +} + } } } diff --git a/cpp/src/wrapper/Index.h b/cpp/src/wrapper/Index.h index d5dfa9cb55..8695b9eb93 100644 --- a/cpp/src/wrapper/Index.h +++ b/cpp/src/wrapper/Index.h @@ -23,6 +23,9 @@ namespace zilliz { namespace vecwise { namespace engine { +class Index; +using Index_ptr = std::shared_ptr; + class Index { typedef long idx_t; @@ -61,6 +64,7 @@ public: // virtual bool index_display(); private: + friend void write_index(const Index_ptr &index, const std::string &file_name); std::shared_ptr index_ = nullptr; // std::vector res_; // std::vector devs_; @@ -69,9 +73,8 @@ private: // faiss::gpu::GpuMultipleClonerOptions *options = new faiss::gpu::GpuMultipleClonerOptions(); }; -using Index_ptr = std::shared_ptr; -extern void write_index(const Index_ptr &index, const std::string &file_name); +void write_index(const Index_ptr &index, const std::string &file_name); extern Index_ptr read_index(const std::string &file_name); @@ -79,4 +82,3 @@ extern Index_ptr read_index(const std::string &file_name); } } } -