Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
/data/users/hoss/faiss/IndexBinaryFlat.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 #ifndef INDEX_BINARY_FLAT_H
11 #define INDEX_BINARY_FLAT_H
12
13 #include <vector>
14
15 #include "IndexBinary.h"
16
17 namespace faiss {
18
19
20 /** Index that stores the full vectors and performs exhaustive search. */
21 struct IndexBinaryFlat : IndexBinary {
22 /// database vectors, size ntotal * d / 8
23 std::vector<uint8_t> xb;
24
25 /** Select between using a heap or counting to select the k smallest values
26 * when scanning inverted lists.
27 */
28 bool use_heap = true;
29
30 size_t query_batch_size = 32;
31
32 explicit IndexBinaryFlat(idx_t d);
33
34 void add(idx_t n, const uint8_t *x) override;
35
36 void reset() override;
37
38 void search(idx_t n, const uint8_t *x, idx_t k,
39 int32_t *distances, idx_t *labels) const override;
40
41 void reconstruct(idx_t key, uint8_t *recons) const override;
42
43 /** Remove some ids. Note that because of the indexing structure,
44 * the semantics of this operation are different from the usual ones:
45 * the new ids are shifted. */
46 long remove_ids(const IDSelector& sel) override;
47
48 IndexBinaryFlat() {}
49 };
50
51
52 } // namespace faiss
53
54 #endif // INDEX_BINARY_FLAT_H
faiss::IndexBinaryFlat
Definition: IndexBinaryFlat.h:21
faiss::IndexBinaryFlat::add
void add(idx_t n, const uint8_t *x) override
Definition: IndexBinaryFlat.cpp:24
faiss::IDSelector
Definition: AuxIndexStructures.h:54
faiss::IndexBinaryFlat::remove_ids
long remove_ids(const IDSelector &sel) override
Definition: IndexBinaryFlat.cpp:58
faiss::IndexBinaryFlat::search
void search(idx_t n, const uint8_t *x, idx_t k, int32_t *distances, idx_t *labels) const override
Definition: IndexBinaryFlat.cpp:34
faiss::IndexBinaryFlat::reconstruct
void reconstruct(idx_t key, uint8_t *recons) const override
Definition: IndexBinaryFlat.cpp:78
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::IndexBinaryFlat::use_heap
bool use_heap
Definition: IndexBinaryFlat.h:28
faiss::IndexBinaryFlat::reset
void reset() override
Removes all elements from the database.
Definition: IndexBinaryFlat.cpp:29
faiss::IndexBinaryFlat::xb
std::vector< uint8_t > xb
database vectors, size ntotal * d / 8
Definition: IndexBinaryFlat.h:23
faiss::IndexBinary
Definition: IndexBinary.h:36