From f5b0ec50cf3abc7a77320f8f4a1fee0e4ed4b9ce Mon Sep 17 00:00:00 2001 From: Xu Peng Date: Sun, 5 May 2019 10:21:26 +0800 Subject: [PATCH] refactor(db): typedef engine ptr Former-commit-id: 4629cac435fd484ab949ab112b639a4849e37fca --- cpp/src/db/FaissExecutionEngine.cpp | 4 ++-- cpp/src/db/FaissExecutionEngine.h | 5 ++++- cpp/src/db/MemManager.h | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cpp/src/db/FaissExecutionEngine.cpp b/cpp/src/db/FaissExecutionEngine.cpp index 6f275f58f..b33a23726 100644 --- a/cpp/src/db/FaissExecutionEngine.cpp +++ b/cpp/src/db/FaissExecutionEngine.cpp @@ -75,7 +75,7 @@ Status FaissExecutionEngine::Merge(const std::string& location) { return Status::OK(); } -std::shared_ptr FaissExecutionEngine::BuildIndex(const std::string& location) { +FaissExecutionEngine::Ptr FaissExecutionEngine::BuildIndex(const std::string& location) { auto opd = std::make_shared(); opd->d = pIndex_->d; opd->index_type = BuildIndexType; @@ -87,7 +87,7 @@ std::shared_ptr FaissExecutionEngine::BuildIndex(const std dynamic_cast(from_index->index)->xb.data(), from_index->id_map.data()); - std::shared_ptr new_ee(new FaissExecutionEngine(index->data(), location)); + Ptr new_ee(new FaissExecutionEngine(index->data(), location)); new_ee->Serialize(); return new_ee; } diff --git a/cpp/src/db/FaissExecutionEngine.h b/cpp/src/db/FaissExecutionEngine.h index e2d007ffc..0dea46f6b 100644 --- a/cpp/src/db/FaissExecutionEngine.h +++ b/cpp/src/db/FaissExecutionEngine.h @@ -13,9 +13,12 @@ namespace zilliz { namespace vecwise { namespace engine { +class FaissExecutionEngine; class FaissExecutionEngine : public ExecutionEngine { public: + typedef std::shared_ptr Ptr; + FaissExecutionEngine(uint16_t dimension, const std::string& location); FaissExecutionEngine(std::shared_ptr index, const std::string& location); @@ -42,7 +45,7 @@ public: float *distances, long *labels) const; - std::shared_ptr BuildIndex(const std::string&); + FaissExecutionEngine::Ptr BuildIndex(const std::string&); Status Cache(); protected: diff --git a/cpp/src/db/MemManager.h b/cpp/src/db/MemManager.h index ec8e19173..47d3aa335 100644 --- a/cpp/src/db/MemManager.h +++ b/cpp/src/db/MemManager.h @@ -22,6 +22,8 @@ namespace meta { template class MemVectors { public: + typedef typename EngineT::Ptr EnginePtr; + explicit MemVectors(const std::shared_ptr&, const meta::GroupFileSchema&, const Options&); @@ -46,7 +48,7 @@ private: Options options_; meta::GroupFileSchema schema_; IDGenerator* _pIdGenerator; - std::shared_ptr pEE_; + EnginePtr pEE_; }; // MemVectors -- GitLab