Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

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
24 struct IndexBinaryHNSW : IndexBinary {
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
faiss::IndexBinaryHNSW::add
void add(idx_t n, const uint8_t *x) override
Definition: IndexBinaryHNSW.cpp:227
faiss::IndexBinary::d
int d
vector dimension
Definition: IndexBinary.h:40
faiss::IndexBinaryHNSW::reconstruct
void reconstruct(idx_t key, uint8_t *recons) const override
Definition: IndexBinaryHNSW.cpp:245
faiss::IndexBinaryHNSW
Definition: IndexBinaryHNSW.h:24
faiss::HNSW
Definition: HNSW.h:47
faiss::IndexBinaryHNSW::train
void train(idx_t n, const uint8_t *x) override
Trains the storage if needed.
Definition: IndexBinaryHNSW.cpp:192
faiss::IndexBinary
Definition: IndexBinary.h:37
faiss::IndexBinary::idx_t
long idx_t
all indices are this type
Definition: IndexBinary.h:38
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:199
faiss::HNSW::storage_idx_t
int storage_idx_t
internal storage of vectors (32 bits: this is expensive)
Definition: HNSW.h:49
faiss::HNSW::DistanceComputer
Definition: HNSW.h:60
faiss::IndexBinaryHNSW::reset
void reset() override
Removes all elements from the database.
Definition: IndexBinaryHNSW.cpp:238