Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

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