Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
MetaIndexes_c.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 // Copyright 2004-present Facebook. All Rights Reserved.
10 // -*- c++ -*-
11
12 #ifndef METAINDEXES_C_H
13 #define METAINDEXES_C_H
14
15 #include "faiss_c.h"
16 #include "Index_c.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 /** Index that translates search results to ids */
23 FAISS_DECLARE_CLASS_INHERITED(IndexIDMap, Index)
24
25 FAISS_DECLARE_GETTER_SETTER(IndexIDMap, int, own_fields)
26
27 int faiss_IndexIDMap_new(FaissIndexIDMap** p_index, FaissIndex* index);
28
29 /** get a pointer to the index map's internal ID vector (the `id_map` field). The
30 * outputs of this function become invalid after any operation that can modify the index.
31 *
32 * @param index opaque pointer to index object
33 * @param p_id_map output, the pointer to the beginning of `id_map`.
34 * @param p_size output, the current length of `id_map`.
35 */
36 void faiss_IndexIDMap_id_map(FaissIndexIDMap* index, long** p_id_map, size_t* p_size);
37
38 /** same as IndexIDMap but also provides an efficient reconstruction
39 implementation via a 2-way index */
40 FAISS_DECLARE_CLASS_INHERITED(IndexIDMap2, IndexIDMap)
41
42 int faiss_IndexIDMap2_new(FaissIndexIDMap2** p_index, FaissIndex* index);
43
44 /// make the rev_map from scratch
45 int faiss_IndexIDMap2_construct_rev_map(FaissIndexIDMap2* index);
46
47 /** Index that concatenates the results from several sub-indexes
48 */
49 FAISS_DECLARE_CLASS_INHERITED(IndexShards, Index)
50
51 FAISS_DECLARE_GETTER_SETTER(IndexShards, int, own_fields)
52 FAISS_DECLARE_GETTER_SETTER(IndexShards, int, threaded)
53 FAISS_DECLARE_GETTER_SETTER(IndexShards, int, successive_ids)
54
55 int faiss_IndexShards_new(FaissIndexShards** p_index, idx_t d);
56
57 int faiss_IndexShards_new_with_options(FaissIndexShards** p_index, idx_t d, int threaded, int successive_ids);
58
59 /** get a pointer to the index' shards (the `shard_indexes` field). The
60 * outputs of this function become invalid after any operation that can modify the index.
61 *
62 * @param index opaque pointer to index object
63 * @param p_shard_indexes output, the pointer to the beginning of `shard_indexes`.
64 * @param p_size output, the current length of `shard_indexes`.
65 */
66 void faiss_IndexShards_shard_indexes(FaissIndexShards* index, FaissIndex** p_shard_indexes, size_t* p_size);
67
68 int faiss_IndexShards_add_shard(FaissIndexShards* index, FaissIndex* shard);
69
70 /// update metric_type and ntotal
71 int faiss_IndexShards_sync_with_shard_indexes(FaissIndexShards* index);
72
73 FaissIndex* faiss_IndexShards_at(FaissIndexShards* index, int i);
74
75 #ifdef __cplusplus
76 }
77 #endif
78 #endif