vec_impl.h 2.9 KB
Newer Older
X
MS-154  
xj.lin 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "knowhere/index/vector_index/vector_index.h"

#include "vec_index.h"


namespace zilliz {
X
xj.lin 已提交
15
namespace milvus {
X
MS-154  
xj.lin 已提交
16 17 18 19
namespace engine {

class VecIndexImpl : public VecIndex {
 public:
X
xj.lin 已提交
20 21
    explicit VecIndexImpl(std::shared_ptr<zilliz::knowhere::VectorIndex> index, const IndexType &type)
        : index_(std::move(index)), type(type) {};
X
xj.lin 已提交
22 23 24 25 26 27
    server::KnowhereError BuildAll(const long &nb,
                                   const float *xb,
                                   const long *ids,
                                   const Config &cfg,
                                   const long &nt,
                                   const float *xt) override;
X
xj.lin 已提交
28
    IndexType GetType() override;
X
xj.lin 已提交
29 30
    int64_t Dimension() override;
    int64_t Count() override;
X
xj.lin 已提交
31
    server::KnowhereError Add(const long &nb, const float *xb, const long *ids, const Config &cfg) override;
X
MS-154  
xj.lin 已提交
32
    zilliz::knowhere::BinarySet Serialize() override;
X
xj.lin 已提交
33 34
    server::KnowhereError Load(const zilliz::knowhere::BinarySet &index_binary) override;
    server::KnowhereError Search(const long &nq, const float *xq, float *dist, long *ids, const Config &cfg) override;
X
MS-154  
xj.lin 已提交
35

X
xj.lin 已提交
36
 protected:
X
xj.lin 已提交
37
    int64_t dim = 0;
X
xj.lin 已提交
38
    IndexType type = IndexType::INVALID;
X
MS-154  
xj.lin 已提交
39 40 41
    std::shared_ptr<zilliz::knowhere::VectorIndex> index_ = nullptr;
};

X
xj.lin 已提交
42 43
class IVFMixIndex : public VecIndexImpl {
 public:
X
xj.lin 已提交
44 45 46
    explicit IVFMixIndex(std::shared_ptr<zilliz::knowhere::VectorIndex> index, const IndexType &type)
        : VecIndexImpl(std::move(index), type) {};

X
xj.lin 已提交
47 48 49 50 51 52 53
    server::KnowhereError BuildAll(const long &nb,
                                   const float *xb,
                                   const long *ids,
                                   const Config &cfg,
                                   const long &nt,
                                   const float *xt) override;
    server::KnowhereError Load(const zilliz::knowhere::BinarySet &index_binary) override;
X
xj.lin 已提交
54 55
};

X
xj.lin 已提交
56 57
class BFIndex : public VecIndexImpl {
 public:
X
xj.lin 已提交
58 59
    explicit BFIndex(std::shared_ptr<zilliz::knowhere::VectorIndex> index) : VecIndexImpl(std::move(index),
                                                                                          IndexType::FAISS_IDMAP) {};
X
xj.lin 已提交
60
    server::KnowhereError Build(const Config& cfg);
X
xj.lin 已提交
61
    float *GetRawVectors();
X
xj.lin 已提交
62 63 64 65 66 67
    server::KnowhereError BuildAll(const long &nb,
                                   const float *xb,
                                   const long *ids,
                                   const Config &cfg,
                                   const long &nt,
                                   const float *xt) override;
X
xj.lin 已提交
68
    int64_t *GetRawIds();
X
xj.lin 已提交
69 70
};

X
MS-154  
xj.lin 已提交
71 72 73
}
}
}