mirror of https://github.com/milvus-io/milvus.git
add safty check 4 annoy load index (#2022)
Signed-off-by: cms <chenmaosen0@gmail.com>pull/2031/head
parent
00e76219f6
commit
c7eb9b0fa2
|
@ -835,9 +835,9 @@ class AnnoyIndexInterface {
|
|||
virtual bool load_index(void* index_data, const int64_t& index_size, char** error = NULL) = 0;
|
||||
virtual T get_distance(S i, S j) const = 0;
|
||||
virtual void get_nns_by_item(S item, size_t n, int search_k, vector<S>* result, vector<T>* distances,
|
||||
faiss::ConcurrentBitsetPtr bitset = nullptr) const = 0;
|
||||
faiss::ConcurrentBitsetPtr& bitset = nullptr) const = 0;
|
||||
virtual void get_nns_by_vector(const T* w, size_t n, int search_k, vector<S>* result, vector<T>* distances,
|
||||
faiss::ConcurrentBitsetPtr bitset = nullptr) const = 0;
|
||||
faiss::ConcurrentBitsetPtr& bitset = nullptr) const = 0;
|
||||
virtual S get_n_items() const = 0;
|
||||
virtual S get_dim() const = 0;
|
||||
virtual S get_n_trees() const = 0;
|
||||
|
@ -1173,14 +1173,14 @@ public:
|
|||
}
|
||||
|
||||
void get_nns_by_item(S item, size_t n, int search_k, vector<S>* result, vector<T>* distances,
|
||||
faiss::ConcurrentBitsetPtr bitset) const {
|
||||
faiss::ConcurrentBitsetPtr& bitset) const {
|
||||
// TODO: handle OOB
|
||||
const Node* m = _get(item);
|
||||
_get_all_nns(m->v, n, search_k, result, distances, bitset);
|
||||
}
|
||||
|
||||
void get_nns_by_vector(const T* w, size_t n, int search_k, vector<S>* result, vector<T>* distances,
|
||||
faiss::ConcurrentBitsetPtr bitset) const {
|
||||
faiss::ConcurrentBitsetPtr& bitset) const {
|
||||
_get_all_nns(w, n, search_k, result, distances, bitset);
|
||||
}
|
||||
|
||||
|
@ -1328,7 +1328,7 @@ protected:
|
|||
}
|
||||
|
||||
void _get_all_nns(const T* v, size_t n, int search_k, vector<S>* result, vector<T>* distances,
|
||||
faiss::ConcurrentBitsetPtr bitset) const {
|
||||
faiss::ConcurrentBitsetPtr& bitset) const {
|
||||
Node* v_node = (Node *)alloca(_s);
|
||||
D::template zero_value<Node>(v_node);
|
||||
memcpy(v_node->v, v, sizeof(T) * _f);
|
||||
|
|
Loading…
Reference in New Issue