Faiss
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
/tmp/faiss/IndexBinaryHNSW.h
1 /**
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD+Patents license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 // -*- c++ -*-
10 
11 #pragma once
12 
13 #include "HNSW.h"
14 #include "IndexBinaryFlat.h"
15 #include "utils.h"
16 
17 
18 namespace faiss {
19 
20 
21 /** The HNSW index is a normal random-access index with a HNSW
22  * link structure built on top */
23 
25  typedef HNSW::storage_idx_t storage_idx_t;
26 
27  // the link strcuture
28  HNSW hnsw;
29 
30  // the sequential storage
31  bool own_fields;
32  IndexBinary *storage;
33 
34  explicit IndexBinaryHNSW();
35  explicit IndexBinaryHNSW(int d, int M = 32);
36  explicit IndexBinaryHNSW(IndexBinary *storage, int M = 32);
37 
38  ~IndexBinaryHNSW() override;
39 
40  HNSW::DistanceComputer *get_distance_computer() const;
41 
42  void add(idx_t n, const uint8_t *x) override;
43 
44  /// Trains the storage if needed
45  void train(idx_t n, const uint8_t* x) override;
46 
47  /// entry point for search
48  void search(idx_t n, const uint8_t *x, idx_t k,
49  int32_t *distances, idx_t *labels) const override;
50 
51  void reconstruct(idx_t key, uint8_t* recons) const override;
52 
53  void reset() override;
54 };
55 
56 
57 } // namespace faiss
void add(idx_t n, const uint8_t *x) override
int d
vector dimension
Definition: IndexBinary.h:40
void reconstruct(idx_t key, uint8_t *recons) const override
void train(idx_t n, const uint8_t *x) override
Trains the storage if needed.
long idx_t
all indices are this type
Definition: IndexBinary.h:38
void search(idx_t n, const uint8_t *x, idx_t k, int32_t *distances, idx_t *labels) const override
entry point for search
int storage_idx_t
internal storage of vectors (32 bits: this is expensive)
Definition: HNSW.h:49
void reset() override
Removes all elements from the database.