Merge branch 'ms-372' into 'branch-0.4.0'

MS372 dev clone index and get index deviceId

See merge request megasearch/milvus!381

Former-commit-id: 82df26e98dbc3e09e90b38fb3cc27dfc70a0f62e
pull/191/head
jinhai 2019-08-17 17:34:09 +08:00
commit e78231f995
3 changed files with 23 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#include "knowhere/index/vector_index/idmap.h"
#include "knowhere/index/vector_index/gpu_ivf.h"
#include "knowhere/common/exception.h"
#include "knowhere/index/vector_index/cloner.h"
#include "vec_impl.h"
#include "data_transfer.h"
@ -152,6 +153,22 @@ VecIndexPtr VecIndexImpl::CopyToCpu(const Config &cfg) {
return std::make_shared<VecIndexImpl>(cpu_index, type);
}
VecIndexPtr VecIndexImpl::Clone() {
auto clone_index = std::make_shared<VecIndexImpl>(index_->Clone(), type);
clone_index->dim = dim;
return clone_index;
}
int64_t VecIndexImpl::GetDeviceId() {
if (auto device_idx = std::dynamic_pointer_cast<GPUIndex>(index_)){
return device_idx->GetGpuDevice();
}
else {
return -1; // -1 == cpu
}
return 0;
}
float *BFIndex::GetRawVectors() {
auto raw_index = std::dynamic_pointer_cast<IDMAP>(index_);
if (raw_index) { return raw_index->GetRawVectors(); }

View File

@ -33,6 +33,8 @@ class VecIndexImpl : public VecIndex {
server::KnowhereError Add(const long &nb, const float *xb, const long *ids, const Config &cfg) override;
zilliz::knowhere::BinarySet Serialize() override;
server::KnowhereError Load(const zilliz::knowhere::BinarySet &index_binary) override;
VecIndexPtr Clone() override;
int64_t GetDeviceId() override;
server::KnowhereError Search(const long &nq, const float *xq, float *dist, long *ids, const Config &cfg) override;
protected:

View File

@ -63,6 +63,10 @@ class VecIndex {
virtual VecIndexPtr CopyToCpu(const Config &cfg = Config()) = 0;
virtual VecIndexPtr Clone() = 0;
virtual int64_t GetDeviceId() = 0;
virtual IndexType GetType() = 0;
virtual int64_t Dimension() = 0;