2018-05-02 19:39:59 +08:00
|
|
|
/**
|
2019-06-12 21:46:08 +08:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-05-02 19:39:59 +08:00
|
|
|
*
|
2019-06-12 21:46:08 +08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
2018-05-02 19:39:59 +08:00
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// -*- c++ -*-
|
|
|
|
// I/O code for indexes
|
|
|
|
|
|
|
|
#ifndef FAISS_INDEX_IO_C_H
|
|
|
|
#define FAISS_INDEX_IO_C_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2022-03-16 18:28:46 +08:00
|
|
|
#include "IndexBinary_c.h"
|
2018-05-02 19:39:59 +08:00
|
|
|
#include "Index_c.h"
|
2021-02-25 20:44:50 +08:00
|
|
|
#include "faiss_c.h"
|
2018-05-02 19:39:59 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** Write index to a file.
|
2021-02-25 20:44:50 +08:00
|
|
|
* This is equivalent to `faiss::write_index` when a file descriptor is
|
|
|
|
* provided.
|
2018-05-02 19:39:59 +08:00
|
|
|
*/
|
2021-02-25 20:44:50 +08:00
|
|
|
int faiss_write_index(const FaissIndex* idx, FILE* f);
|
2018-05-02 19:39:59 +08:00
|
|
|
|
|
|
|
/** Write index to a file.
|
|
|
|
* This is equivalent to `faiss::write_index` when a file path is provided.
|
|
|
|
*/
|
2021-02-25 20:44:50 +08:00
|
|
|
int faiss_write_index_fname(const FaissIndex* idx, const char* fname);
|
2018-05-02 19:39:59 +08:00
|
|
|
|
|
|
|
#define FAISS_IO_FLAG_MMAP 1
|
|
|
|
#define FAISS_IO_FLAG_READ_ONLY 2
|
|
|
|
|
|
|
|
/** Read index from a file.
|
|
|
|
* This is equivalent to `faiss:read_index` when a file descriptor is given.
|
|
|
|
*/
|
2021-02-25 20:44:50 +08:00
|
|
|
int faiss_read_index(FILE* f, int io_flags, FaissIndex** p_out);
|
2018-05-02 19:39:59 +08:00
|
|
|
|
|
|
|
/** Read index from a file.
|
|
|
|
* This is equivalent to `faiss:read_index` when a file path is given.
|
|
|
|
*/
|
2021-02-25 20:44:50 +08:00
|
|
|
int faiss_read_index_fname(const char* fname, int io_flags, FaissIndex** p_out);
|
2018-05-02 19:39:59 +08:00
|
|
|
|
2022-03-16 18:28:46 +08:00
|
|
|
/** Write index to a file.
|
|
|
|
* This is equivalent to `faiss::write_index_binary` when a file descriptor is
|
|
|
|
* provided.
|
|
|
|
*/
|
|
|
|
int faiss_write_index_binary(const FaissIndexBinary* idx, FILE* f);
|
|
|
|
|
|
|
|
/** Write index to a file.
|
|
|
|
* This is equivalent to `faiss::write_index_binary` when a file path is
|
|
|
|
* provided.
|
|
|
|
*/
|
|
|
|
int faiss_write_index_binary_fname(
|
|
|
|
const FaissIndexBinary* idx,
|
|
|
|
const char* fname);
|
|
|
|
|
|
|
|
/** Read index from a file.
|
|
|
|
* This is equivalent to `faiss:read_index_binary` when a file descriptor is
|
|
|
|
* given.
|
|
|
|
*/
|
|
|
|
int faiss_read_index_binary(FILE* f, int io_flags, FaissIndexBinary** p_out);
|
|
|
|
|
|
|
|
/** Read index from a file.
|
|
|
|
* This is equivalent to `faiss:read_index_binary` when a file path is given.
|
|
|
|
*/
|
|
|
|
int faiss_read_index_binary_fname(
|
|
|
|
const char* fname,
|
|
|
|
int io_flags,
|
|
|
|
FaissIndexBinary** p_out);
|
2018-05-02 19:39:59 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2021-02-25 20:44:50 +08:00
|
|
|
#endif
|