From ee5d02939e35d99e58c55a1ce25dc44536cdd6a1 Mon Sep 17 00:00:00 2001 From: Xu Peng Date: Tue, 16 Apr 2019 09:48:58 +0800 Subject: [PATCH] feat(db): add search api for db Former-commit-id: 593c7ef1ea7a37022773cf49d82bd2b16763f173 --- cpp/src/db/db.h | 3 +++ cpp/src/db/db_impl.cpp | 6 ++++++ cpp/src/db/db_impl.h | 3 +++ cpp/src/db/types.h | 3 +++ 4 files changed, 15 insertions(+) diff --git a/cpp/src/db/db.h b/cpp/src/db/db.h index abaa498421..c14822b041 100644 --- a/cpp/src/db/db.h +++ b/cpp/src/db/db.h @@ -29,6 +29,9 @@ public: virtual Status add_vectors(const std::string& group_id_, size_t n, const float* vectors, IDNumbers& vector_ids_) = 0; + virtual Status search(const std::string& group_id, size_t k, size_t nq, + const float* vectors, QueryResults& results) = 0; + DB() = default; DB(const DB&) = delete; DB& operator=(const DB&) = delete; diff --git a/cpp/src/db/db_impl.cpp b/cpp/src/db/db_impl.cpp index a23fbe1db6..87c83e7027 100644 --- a/cpp/src/db/db_impl.cpp +++ b/cpp/src/db/db_impl.cpp @@ -52,6 +52,12 @@ Status DBImpl::add_vectors(const std::string& group_id_, } } +Status DBImpl::search(const std::string& group_id, size_t k, size_t nq, + const float* vectors, QueryResults& results) { + // PXU TODO + return Status::OK(); +} + void DBImpl::start_timer_task(int interval_) { std::thread bg_task(&DBImpl::background_timer_task, this, interval_); bg_task.detach(); diff --git a/cpp/src/db/db_impl.h b/cpp/src/db/db_impl.h index d9e3a3d7c9..b8e45f8006 100644 --- a/cpp/src/db/db_impl.h +++ b/cpp/src/db/db_impl.h @@ -31,6 +31,9 @@ public: virtual Status add_vectors(const std::string& group_id_, size_t n, const float* vectors, IDNumbers& vector_ids_) override; + virtual Status search(const std::string& group_id, size_t k, size_t nq, + const float* vectors, QueryResults& results) override; + virtual ~DBImpl(); private: diff --git a/cpp/src/db/types.h b/cpp/src/db/types.h index c9ed274def..be538b9b1c 100644 --- a/cpp/src/db/types.h +++ b/cpp/src/db/types.h @@ -10,6 +10,9 @@ typedef long IDNumber; typedef IDNumber* IDNumberPtr; typedef std::vector IDNumbers; +typedef std::vector QueryResult; +typedef std::vector QueryResults; + } // namespace engine } // namespace vecwise