File: MetaIndexes_c.h

package info (click to toggle)
faiss 1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,572 kB
  • sloc: cpp: 85,627; python: 27,889; sh: 905; ansic: 425; makefile: 41
file content (99 lines) | stat: -rw-r--r-- 3,072 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

// -*- c++ -*-

#ifndef METAINDEXES_C_H
#define METAINDEXES_C_H

#include "Index_c.h"
#include "faiss_c.h"

#ifdef __cplusplus
extern "C" {
#endif

/** Index that translates search results to ids */
FAISS_DECLARE_CLASS_INHERITED(IndexIDMap, Index)

FAISS_DECLARE_GETTER_SETTER(IndexIDMap, int, own_fields)

int faiss_IndexIDMap_new(FaissIndexIDMap** p_index, FaissIndex* index);

/** attempt a dynamic cast to a IDMap, thus checking
 * check whether the underlying index type is `IndexIDMap`.
 *
 * @param index opaque pointer to index object
 * @return the same pointer if the index is a IDMap index, NULL otherwise
 */
FAISS_DECLARE_INDEX_DOWNCAST(IndexIDMap)

/** get a pointer to the index map's internal ID vector (the `id_map` field).
 * The outputs of this function become invalid after any operation that can
 * modify the index.
 *
 * @param index   opaque pointer to index object
 * @param p_id_map    output, the pointer to the beginning of `id_map`.
 * @param p_size  output, the current length of `id_map`.
 */
void faiss_IndexIDMap_id_map(
        FaissIndexIDMap* index,
        idx_t** p_id_map,
        size_t* p_size);

/** get a pointer to the sub-index (the `index` field).
 * The outputs of this function become invalid after any operation that can
 * modify the index.
 *
 * @param index   opaque pointer to index object
 */
FaissIndex* faiss_IndexIDMap_sub_index(FaissIndexIDMap* index);

/** same as IndexIDMap but also provides an efficient reconstruction
    implementation via a 2-way index */
FAISS_DECLARE_CLASS_INHERITED(IndexIDMap2, Index)

FAISS_DECLARE_GETTER_SETTER(IndexIDMap2, int, own_fields)

int faiss_IndexIDMap2_new(FaissIndexIDMap2** p_index, FaissIndex* index);

/// make the rev_map from scratch
int faiss_IndexIDMap2_construct_rev_map(FaissIndexIDMap2* index);

/** attempt a dynamic cast to a IDMap2, thus checking
 * check whether the underlying index type is `IndexIDMap`.
 *
 * @param index opaque pointer to index object
 * @return the same pointer if the index is a IDMap2 index, NULL otherwise
 */
FAISS_DECLARE_INDEX_DOWNCAST(IndexIDMap2)

/** get a pointer to the index map's internal ID vector (the `id_map` field).
 * The outputs of this function become invalid after any operation that can
 * modify the index.
 *
 * @param index   opaque pointer to index object
 * @param p_id_map    output, the pointer to the beginning of `id_map`.
 * @param p_size  output, the current length of `id_map`.
 */
void faiss_IndexIDMap2_id_map(
        FaissIndexIDMap2* index,
        idx_t** p_id_map,
        size_t* p_size);

/** get a pointer to the sub-index (the `index` field).
 * The outputs of this function become invalid after any operation that can
 * modify the index.
 *
 * @param index   opaque pointer to index object
 */
FaissIndex* faiss_IndexIDMap2_sub_index(FaissIndexIDMap2* index);

#ifdef __cplusplus
}
#endif
#endif