Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
index_io_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 // I/O code for indexes
12
13
14 #ifndef FAISS_INDEX_IO_C_H
15 #define FAISS_INDEX_IO_C_H
16
17 #include <stdio.h>
18 #include "faiss_c.h"
19 #include "Index_c.h"
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 /** Write index to a file.
26 * This is equivalent to `faiss::write_index` when a file descriptor is provided.
27 */
28 int faiss_write_index(const FaissIndex *idx, FILE *f);
29
30 /** Write index to a file.
31 * This is equivalent to `faiss::write_index` when a file path is provided.
32 */
33 int faiss_write_index_fname(const FaissIndex *idx, const char *fname);
34
35 #define FAISS_IO_FLAG_MMAP 1
36 #define FAISS_IO_FLAG_READ_ONLY 2
37
38 /** Read index from a file.
39 * This is equivalent to `faiss:read_index` when a file descriptor is given.
40 */
41 int faiss_read_index(FILE *f, int io_flags, FaissIndex **p_out);
42
43 /** Read index from a file.
44 * This is equivalent to `faiss:read_index` when a file path is given.
45 */
46 int faiss_read_index_fname(const char *fname, int io_flags, FaissIndex **p_out);
47
48 /* cloning functions */
49
50 /** Clone an index. This is equivalent to `faiss::clone_index` */
51 int faiss_clone_index (const FaissIndex *, FaissIndex ** p_out);
52
53 #ifdef __cplusplus
54 }
55 #endif
56 #endif