Debian Codegraph @

c_api/index_factory_c.cpp

raw
1 /*
2 * Copyright (c) Meta Platforms, Inc. and 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 #include "index_factory_c.h"
11 #include <faiss/index_factory.h>
12 #include <cstring>
13 #include "macros_impl.h"
14
15 using faiss::Index;
16
17 /** Build an index with the sequence of processing steps described in
18 * the string.
19 */
20 int faiss_index_factory(
21 FaissIndex** p_index,
22 int d,
23 const char* description,
24 FaissMetricType metric) {
25 try {
26 *p_index = reinterpret_cast<FaissIndex*>(faiss::index_factory(
27 d, description, static_cast<faiss::MetricType>(metric)));
28 }
29 CATCH_AND_HANDLE
30 }
31
32 /** Build an index with the sequence of processing steps described in
33 * the string.
34 */
35 int faiss_index_binary_factory(
36 FaissIndexBinary** p_index,
37 int d,
38 const char* description) {
39 try {
40 *p_index = reinterpret_cast<FaissIndexBinary*>(
41 faiss::index_binary_factory(d, description));
42 }
43 CATCH_AND_HANDLE
44 }