diff --git a/cpp/conf/server_config.template b/cpp/conf/server_config.template index 037e55a0a8..c80e981bcd 100644 --- a/cpp/conf/server_config.template +++ b/cpp/conf/server_config.template @@ -45,5 +45,3 @@ engine_config: use_blas_threshold: 20 metric_type: L2 # compare vectors by euclidean distance(L2) or inner product(IP), optional: L2 or IP omp_thread_num: 0 # how many compute threads be used by engine, 0 means use all cpu core to compute - use_hybrid_index: false # use GPU/CPU hybrid index - hybrid_index_gpu: 0 # hybrid index gpu device id diff --git a/cpp/src/cache/CacheMgr.cpp b/cpp/src/cache/CacheMgr.cpp index 5e54c9abe1..977c7e1c42 100644 --- a/cpp/src/cache/CacheMgr.cpp +++ b/cpp/src/cache/CacheMgr.cpp @@ -46,7 +46,7 @@ DataObjPtr CacheMgr::GetItem(const std::string& key) { return cache_->get(key); } -engine::Index_ptr CacheMgr::GetIndex(const std::string& key) { +engine::VecIndexPtr CacheMgr::GetIndex(const std::string& key) { DataObjPtr obj = GetItem(key); if(obj != nullptr) { return obj->data(); @@ -65,7 +65,7 @@ void CacheMgr::InsertItem(const std::string& key, const DataObjPtr& data) { server::Metrics::GetInstance().CacheAccessTotalIncrement(); } -void CacheMgr::InsertItem(const std::string& key, const engine::Index_ptr& index) { +void CacheMgr::InsertItem(const std::string& key, const engine::VecIndexPtr& index) { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return; diff --git a/cpp/src/cache/CacheMgr.h b/cpp/src/cache/CacheMgr.h index 003c883be7..b6f1ec8ef1 100644 --- a/cpp/src/cache/CacheMgr.h +++ b/cpp/src/cache/CacheMgr.h @@ -19,10 +19,10 @@ public: virtual bool ItemExists(const std::string& key); virtual DataObjPtr GetItem(const std::string& key); - virtual engine::Index_ptr GetIndex(const std::string& key); + virtual engine::VecIndexPtr GetIndex(const std::string& key); virtual void InsertItem(const std::string& key, const DataObjPtr& data); - virtual void InsertItem(const std::string& key, const engine::Index_ptr& index); + virtual void InsertItem(const std::string& key, const engine::VecIndexPtr& index); virtual void EraseItem(const std::string& key); diff --git a/cpp/src/cache/DataObj.h b/cpp/src/cache/DataObj.h index 341df34174..d9c14f4d1b 100644 --- a/cpp/src/cache/DataObj.h +++ b/cpp/src/cache/DataObj.h @@ -6,7 +6,7 @@ #pragma once -#include "wrapper/Index.h" +#include "wrapper/knowhere/vec_index.h" #include @@ -16,17 +16,17 @@ namespace cache { class DataObj { public: - DataObj(const engine::Index_ptr& index) + DataObj(const engine::VecIndexPtr& index) : index_(index) {} - DataObj(const engine::Index_ptr& index, int64_t size) + DataObj(const engine::VecIndexPtr& index, int64_t size) : index_(index), size_(size) {} - engine::Index_ptr data() { return index_; } - const engine::Index_ptr& data() const { return index_; } + engine::VecIndexPtr data() { return index_; } + const engine::VecIndexPtr& data() const { return index_; } int64_t size() const { if(index_ == nullptr) { @@ -41,7 +41,7 @@ public: } private: - engine::Index_ptr index_ = nullptr; + engine::VecIndexPtr index_ = nullptr; int64_t size_ = 0; }; diff --git a/cpp/src/wrapper/FaissGpuResources.cpp b/cpp/src/wrapper/FaissGpuResources.cpp deleted file mode 100644 index b4372f1a2c..0000000000 --- a/cpp/src/wrapper/FaissGpuResources.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#include "FaissGpuResources.h" -#include "map" - -namespace zilliz { -namespace milvus { -namespace engine { - -FaissGpuResources::Ptr& FaissGpuResources::GetGpuResources(int device_id) { - static std::map gpu_resources_map; - auto search = gpu_resources_map.find(device_id); - if (search != gpu_resources_map.end()) { - return gpu_resources_map[device_id]; - } else { - gpu_resources_map[device_id] = std::make_shared(); - return gpu_resources_map[device_id]; - } -} - -void FaissGpuResources::SelectGpu() { - using namespace zilliz::milvus::server; - ServerConfig &config = ServerConfig::GetInstance(); - ConfigNode server_config = config.GetConfig(CONFIG_SERVER); - gpu_num_ = server_config.GetInt32Value(server::CONFIG_GPU_INDEX, 0); -} - -int32_t FaissGpuResources::GetGpu() { - return gpu_num_; -} - -} -} -} \ No newline at end of file diff --git a/cpp/src/wrapper/FaissGpuResources.h b/cpp/src/wrapper/FaissGpuResources.h deleted file mode 100644 index 45c011df85..0000000000 --- a/cpp/src/wrapper/FaissGpuResources.h +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved - * Unauthorized copying of this file, via any medium is strictly prohibited. - * Proprietary and confidential. - ******************************************************************************/ -#pragma once - -#include "faiss/gpu/GpuResources.h" -#include "faiss/gpu/StandardGpuResources.h" - -#include "server/ServerConfig.h" - -namespace zilliz { -namespace milvus { -namespace engine { - -class FaissGpuResources { - - public: - using Ptr = std::shared_ptr; - - static FaissGpuResources::Ptr& GetGpuResources(int device_id); - - void SelectGpu(); - - int32_t GetGpu(); - - FaissGpuResources() : gpu_num_(0) { SelectGpu(); } - - private: - int32_t gpu_num_; -}; - -} -} -} \ No newline at end of file diff --git a/cpp/src/wrapper/Index.cpp b/cpp/src/wrapper/Index.cpp deleted file mode 100644 index 6d2ca19449..0000000000 --- a/cpp/src/wrapper/Index.cpp +++ /dev/null @@ -1,109 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#if 0 -// TODO: maybe support static search -#ifdef GPU_VERSION - -#include "faiss/gpu/GpuAutoTune.h" -#include "faiss/gpu/StandardGpuResources.h" -#include "faiss/gpu/utils/DeviceUtils.h" - - -#endif - -#include "Index.h" -#include "faiss/index_io.h" -#include "faiss/IndexIVF.h" -#include "faiss/IVFlib.h" -#include "faiss/IndexScalarQuantizer.h" -#include "server/ServerConfig.h" -#include "src/wrapper/FaissGpuResources.h" - - -namespace zilliz { -namespace milvus { -namespace engine { - -using std::string; -using std::unordered_map; -using std::vector; - -Index::Index(const std::shared_ptr &raw_index) { - index_ = raw_index; - dim = index_->d; - ntotal = index_->ntotal; - store_on_gpu = false; -} - -bool Index::reset() { - try { - index_->reset(); - ntotal = index_->ntotal; - } - catch (std::exception &e) { -// LOG(ERROR) << e.what(); - return false; - } - return true; -} - -bool Index::add_with_ids(idx_t n, const float *xdata, const long *xids) { - try { - index_->add_with_ids(n, xdata, xids); - ntotal += n; - } - catch (std::exception &e) { -// LOG(ERROR) << e.what(); - return false; - } - return true; -} - -bool Index::search(idx_t n, const float *data, idx_t k, float *distances, long *labels) const { - try { - index_->search(n, data, k, distances, labels); - } - catch (std::exception &e) { -// LOG(ERROR) << e.what(); - return false; - } - return true; -} - -void write_index(const Index_ptr &index, const std::string &file_name) { - write_index(index->index_.get(), file_name.c_str()); -} - -Index_ptr read_index(const std::string &file_name) { - std::shared_ptr raw_index = nullptr; - faiss::Index *cpu_index = faiss::read_index(file_name.c_str()); - - server::ServerConfig &config = server::ServerConfig::GetInstance(); - server::ConfigNode engine_config = config.GetConfig(server::CONFIG_ENGINE); - bool use_hybrid_index_ = engine_config.GetBoolValue(server::CONFIG_USE_HYBRID_INDEX, false); - - if (dynamic_cast(cpu_index) != nullptr && use_hybrid_index_) { - - int device_id = engine_config.GetInt32Value(server::CONFIG_HYBRID_INDEX_GPU, 0); - auto gpu_resources = engine::FaissGpuResources::GetGpuResources(device_id); - faiss::gpu::GpuClonerOptions clone_option; - clone_option.storeInCpu = true; - faiss::Index *gpu_index = faiss::gpu::index_cpu_to_gpu(gpu_resources.get(), device_id, cpu_index, &clone_option); - - delete cpu_index; - raw_index.reset(gpu_index); - return std::make_shared(raw_index); - } else { - raw_index.reset(cpu_index); - return std::make_shared(raw_index); - } -} - -} -} -} -#endif diff --git a/cpp/src/wrapper/Index.h b/cpp/src/wrapper/Index.h deleted file mode 100644 index d722b85330..0000000000 --- a/cpp/src/wrapper/Index.h +++ /dev/null @@ -1,88 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -//#include -//#include -//#include -//#include -//#include -// -//#include "faiss/AutoTune.h" -//#include "faiss/index_io.h" -// -//#include "Operand.h" - -#include "knowhere/vec_index.h" - - -namespace zilliz { -namespace milvus { -namespace engine { - -using Index_ptr = VecIndexPtr; - -#if 0 -//class Index; -//using Index_ptr = std::shared_ptr; - -class Index { - typedef long idx_t; - -public: - int dim; ///< std::vector dimension - idx_t ntotal; ///< total nb of indexed std::vectors - bool store_on_gpu; - - explicit Index(const std::shared_ptr &raw_index); - - virtual bool reset(); - - /** - * @brief Same as add, but stores xids instead of sequential ids. - * - * @param data input matrix, size n * d - * @param if ids is not empty ids for the std::vectors - */ - virtual bool add_with_ids(idx_t n, const float *xdata, const long *xids); - - /** - * @brief for each query std::vector, find its k nearest neighbors in the database - * - * @param n queries size - * @param data query std::vectors - * @param k top k nearest neighbors - * @param distances top k nearest distances - * @param labels neighbors of the queries - */ - virtual bool search(idx_t n, const float *data, idx_t k, float *distances, long *labels) const; - - //virtual bool search(idx_t n, const std::vector &data, idx_t k, - // std::vector &distances, std::vector &labels) const; - - //virtual bool remove_ids(const faiss::IDSelector &sel, long &nremove, long &location); - //virtual bool remove_ids_range(const faiss::IDSelector &sel, long &nremove); - //virtual bool index_display(); - - virtual std::shared_ptr data() { return index_; } - - virtual const std::shared_ptr& data() const { return index_; } - -private: - friend void write_index(const Index_ptr &index, const std::string &file_name); - std::shared_ptr index_ = nullptr; -}; - - -void write_index(const Index_ptr &index, const std::string &file_name); - -extern Index_ptr read_index(const std::string &file_name); -#endif - -} -} -} diff --git a/cpp/src/wrapper/IndexBuilder.cpp b/cpp/src/wrapper/IndexBuilder.cpp deleted file mode 100644 index e2b6971281..0000000000 --- a/cpp/src/wrapper/IndexBuilder.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#if 0 -#include "mutex" - - -#ifdef GPU_VERSION -#include -#include -#include -#endif - - -#include -#include -#include "faiss/IndexScalarQuantizer.h" - -#include "server/ServerConfig.h" -#include "IndexBuilder.h" -#include "FaissGpuResources.h" - - -namespace zilliz { -namespace milvus { -namespace engine { - -using std::vector; - -static std::mutex gpu_resource; -static std::mutex cpu_resource; - -IndexBuilder::IndexBuilder(const Operand_ptr &opd) { - opd_ = opd; - - using namespace zilliz::milvus::server; - ServerConfig &config = ServerConfig::GetInstance(); - ConfigNode engine_config = config.GetConfig(CONFIG_ENGINE); - use_hybrid_index_ = engine_config.GetBoolValue(CONFIG_USE_HYBRID_INDEX, false); - hybrid_index_device_id_ = engine_config.GetInt32Value(server::CONFIG_HYBRID_INDEX_GPU, 0); -} - -// Default: build use gpu -Index_ptr IndexBuilder::build_all(const long &nb, - const float *xb, - const long *ids, - const long &nt, - const float *xt) { - std::shared_ptr host_index = nullptr; -#ifdef GPU_VERSION - { - LOG(DEBUG) << "Build index by GPU"; - // TODO: list support index-type. - faiss::MetricType metric_type = opd_->metric_type == "L2" ? faiss::METRIC_L2 : faiss::METRIC_INNER_PRODUCT; - faiss::Index *ori_index = faiss::index_factory(opd_->d, opd_->get_index_type(nb).c_str(), metric_type); - - std::lock_guard lk(gpu_resource); - -#ifdef UNITTEST_ONLY - faiss::gpu::StandardGpuResources res; - int device_id = 0; - faiss::gpu::GpuClonerOptions clone_option; - clone_option.storeInCpu = use_hybrid_index_; - auto device_index = faiss::gpu::index_cpu_to_gpu(&res, device_id, ori_index, &clone_option); -#else - engine::FaissGpuResources res; - int device_id = res.GetGpu(); - auto gpu_resources = engine::FaissGpuResources::GetGpuResources(device_id); - faiss::gpu::GpuClonerOptions clone_option; - clone_option.storeInCpu = use_hybrid_index_; - auto device_index = faiss::gpu::index_cpu_to_gpu(gpu_resources.get(), device_id, ori_index, &clone_option); -#endif - - if (!device_index->is_trained) { - nt == 0 || xt == nullptr ? device_index->train(nb, xb) - : device_index->train(nt, xt); - } - device_index->add_with_ids(nb, xb, ids); // TODO: support with add_with_IDMAP - - if (dynamic_cast(ori_index) != nullptr - && use_hybrid_index_) { - std::shared_ptr device_hybrid_index = nullptr; - if (hybrid_index_device_id_ != device_id) { - auto host_hybrid_index = faiss::gpu::index_gpu_to_cpu(device_index); - auto hybrid_gpu_resources = engine::FaissGpuResources::GetGpuResources(hybrid_index_device_id_); - auto another_device_index = faiss::gpu::index_cpu_to_gpu(hybrid_gpu_resources.get(), - hybrid_index_device_id_, - host_hybrid_index, - &clone_option); - device_hybrid_index.reset(another_device_index); - delete device_index; - delete host_hybrid_index; - } else { - device_hybrid_index.reset(device_index); - } - delete ori_index; - return std::make_shared(device_hybrid_index); - } - - host_index.reset(faiss::gpu::index_gpu_to_cpu(device_index)); - - delete device_index; - delete ori_index; - } -#else - { - LOG(DEBUG) << "Build index by CPU"; - faiss::MetricType metric_type = opd_->metric_type == "L2" ? faiss::METRIC_L2 : faiss::METRIC_INNER_PRODUCT; - faiss::Index *index = faiss::index_factory(opd_->d, opd_->get_index_type(nb).c_str(), metric_type); - if (!index->is_trained) { - nt == 0 || xt == nullptr ? index->train(nb, xb) - : index->train(nt, xt); - } - index->add_with_ids(nb, xb, ids); - host_index.reset(index); - } -#endif - - return std::make_shared(host_index); -} - -Index_ptr IndexBuilder::build_all(const long &nb, const vector &xb, - const vector &ids, - const long &nt, const vector &xt) { - return build_all(nb, xb.data(), ids.data(), nt, xt.data()); -} - -BgCpuBuilder::BgCpuBuilder(const zilliz::milvus::engine::Operand_ptr &opd) : IndexBuilder(opd) {}; - -Index_ptr BgCpuBuilder::build_all(const long &nb, const float *xb, const long *ids, const long &nt, const float *xt) { - std::shared_ptr index = nullptr; - faiss::MetricType metric_type = opd_->metric_type == "L2" ? faiss::METRIC_L2 : faiss::METRIC_INNER_PRODUCT; - index.reset(faiss::index_factory(opd_->d, opd_->get_index_type(nb).c_str(), metric_type)); - - LOG(DEBUG) << "Build index by CPU"; - { - std::lock_guard lk(cpu_resource); - if (!index->is_trained) { - nt == 0 || xt == nullptr ? index->train(nb, xb) - : index->train(nt, xt); - } - index->add_with_ids(nb, xb, ids); - } - - return std::make_shared(index); -} - -IndexBuilderPtr GetIndexBuilder(const Operand_ptr &opd) { - if (opd->index_type == "IDMap") { - IndexBuilderPtr index = nullptr; - return std::make_shared(opd); - } - - return std::make_shared(opd); -} - -} -} -} -#endif diff --git a/cpp/src/wrapper/IndexBuilder.h b/cpp/src/wrapper/IndexBuilder.h deleted file mode 100644 index 2142df83ee..0000000000 --- a/cpp/src/wrapper/IndexBuilder.h +++ /dev/null @@ -1,70 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#if 0 -#pragma once - -#include "faiss/Index.h" - -#include "Operand.h" -#include "Index.h" - - -namespace zilliz { -namespace milvus { -namespace engine { - -class IndexBuilder { - public: - explicit IndexBuilder(const Operand_ptr &opd); - - virtual Index_ptr build_all(const long &nb, - const float *xb, - const long *ids, - const long &nt = 0, - const float *xt = nullptr); - - virtual Index_ptr build_all(const long &nb, - const std::vector &xb, - const std::vector &ids, - const long &nt = 0, - const std::vector &xt = std::vector()); - - //void train(const long &nt, - // const std::vector &xt); - // - //Index_ptr add(const long &nb, - // const std::vector &xb, - // const std::vector &ids); - // - //void set_build_option(const Operand_ptr &opd); - - - protected: - Operand_ptr opd_ = nullptr; - bool use_hybrid_index_; - int hybrid_index_device_id_; -}; - -class BgCpuBuilder : public IndexBuilder { - public: - BgCpuBuilder(const Operand_ptr &opd); - - virtual Index_ptr build_all(const long &nb, - const float *xb, - const long *ids, - const long &nt = 0, - const float *xt = nullptr) override; -}; - -using IndexBuilderPtr = std::shared_ptr; - -extern IndexBuilderPtr GetIndexBuilder(const Operand_ptr &opd); - -} -} -} -#endif diff --git a/cpp/src/wrapper/Operand.cpp b/cpp/src/wrapper/Operand.cpp deleted file mode 100644 index 8bc708eb72..0000000000 --- a/cpp/src/wrapper/Operand.cpp +++ /dev/null @@ -1,123 +0,0 @@ - -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#if 0 -#include "Operand.h" - - -namespace zilliz { -namespace milvus { -namespace engine { - -using std::string; - -enum IndexType { - Invalid_Option = 0, - IVF = 1, - IDMAP = 2, - IVFSQ8 = 3, -}; - -IndexType resolveIndexType(const string &index_type) { - if (index_type == "IVF") { return IndexType::IVF; } - if (index_type == "IDMap") { return IndexType::IDMAP; } - if (index_type == "IVFSQ8") { return IndexType::IVFSQ8; } - return IndexType::Invalid_Option; -} - -int CalcBacketCount(int nb, size_t nlist) { - int backet_count = int(nb / 1000000.0 * nlist); - if(backet_count == 0) { - backet_count = 1; //avoid faiss rash - } - - return backet_count; -} - -// nb at least 100 -string Operand::get_index_type(const int &nb) { - if (!index_str.empty()) { return index_str; } - - switch (resolveIndexType(index_type)) { - case Invalid_Option: { - // TODO: add exception - break; - } - case IVF: { - - using namespace zilliz::milvus::server; - ServerConfig &config = ServerConfig::GetInstance(); - ConfigNode engine_config = config.GetConfig(CONFIG_ENGINE); - size_t nlist = engine_config.GetInt32Value(CONFIG_NLIST, 16384); - - index_str += (ncent != 0 ? index_type + std::to_string(ncent) : - index_type + std::to_string(CalcBacketCount(nb, nlist))); -// std::cout<<"nlist = "<>(std::istream &is, Operand &obj) { - is >> obj.d - >> obj.index_type - >> obj.metric_type - >> obj.preproc - >> obj.postproc - >> obj.ncent; - return is; -} - -std::string operand_to_str(const Operand_ptr &opd) { - std::ostringstream ss; - ss << *opd; - return ss.str(); -} - -Operand_ptr str_to_operand(const std::string &input) { - std::istringstream is(input); - auto opd = std::make_shared(); - is >> *(opd.get()); - - return opd; -} - -} -} -} -#endif diff --git a/cpp/src/wrapper/Operand.h b/cpp/src/wrapper/Operand.h deleted file mode 100644 index 0e675f6a1b..0000000000 --- a/cpp/src/wrapper/Operand.h +++ /dev/null @@ -1,46 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved -// Unauthorized copying of this file, via any medium is strictly prohibited. -// Proprietary and confidential. -//////////////////////////////////////////////////////////////////////////////// - -#if 0 -#pragma once - -#include -#include -#include -#include - - -namespace zilliz { -namespace milvus { -namespace engine { - -struct Operand { - friend std::ostream &operator<<(std::ostream &os, const Operand &obj); - - friend std::istream &operator>>(std::istream &is, Operand &obj); - - int d; - std::string index_type = "IVF"; - std::string metric_type = "L2"; //> L2 / IP(Inner Product) - std::string preproc; - std::string postproc = "Flat"; - std::string index_str; - int ncent = 0; - - std::string get_index_type(const int &nb); -}; - -using Operand_ptr = std::shared_ptr; - -extern std::string operand_to_str(const Operand_ptr &opd); - -extern Operand_ptr str_to_operand(const std::string &input); - - -} -} -} -#endif diff --git a/cpp/unittest/server/cache_test.cpp b/cpp/unittest/server/cache_test.cpp index 4f1d1db4ef..4d9379dc73 100644 --- a/cpp/unittest/server/cache_test.cpp +++ b/cpp/unittest/server/cache_test.cpp @@ -8,7 +8,6 @@ #include "cache/GpuCacheMgr.h" #include "utils/Error.h" -#include "wrapper/Index.h" #include "wrapper/knowhere/vec_index.h" using namespace zilliz::milvus; @@ -112,7 +111,7 @@ TEST(CacheTest, CPU_CACHE_TEST) { for (int i = 0; i < 20; i++) { MockVecIndex* mock_index = new MockVecIndex(); mock_index->ntotal_ = 1000000;//less 1G per index - engine::Index_ptr index(mock_index); + engine::VecIndexPtr index(mock_index); cpu_mgr->InsertItem("index_" + std::to_string(i), index); } @@ -137,7 +136,7 @@ TEST(CacheTest, CPU_CACHE_TEST) { MockVecIndex* mock_index = new MockVecIndex(); mock_index->ntotal_ = 6000000;//6G less - engine::Index_ptr index(mock_index); + engine::VecIndexPtr index(mock_index); cpu_mgr->InsertItem("index_6g", index); ASSERT_EQ(cpu_mgr->ItemCount(), 0);//data greater than capacity can not be inserted sucessfully @@ -154,7 +153,7 @@ TEST(CacheTest, GPU_CACHE_TEST) { for(int i = 0; i < 20; i++) { MockVecIndex* mock_index = new MockVecIndex(); mock_index->ntotal_ = 1000; - engine::Index_ptr index(mock_index); + engine::VecIndexPtr index(mock_index); cache::DataObjPtr obj = std::make_shared(index); @@ -175,7 +174,7 @@ TEST(CacheTest, INVALID_TEST) { ASSERT_EQ(mgr.GetItem("test"), nullptr); mgr.InsertItem("test", cache::DataObjPtr()); - mgr.InsertItem("test", engine::Index_ptr(nullptr)); + mgr.InsertItem("test", engine::VecIndexPtr(nullptr)); mgr.EraseItem("test"); mgr.PrintInfo(); mgr.ClearCache(); @@ -189,7 +188,7 @@ TEST(CacheTest, INVALID_TEST) { for(int i = 0; i < 20; i++) { MockVecIndex* mock_index = new MockVecIndex(); mock_index->ntotal_ = 2; - engine::Index_ptr index(mock_index); + engine::VecIndexPtr index(mock_index); cache::DataObjPtr obj = std::make_shared(index); mgr.InsertItem("index_" + std::to_string(i), obj);