Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

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