| 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 |
// I/O code for indexes |
| 10 |
|
| 11 |
#include "clone_index_c.h" |
| 12 |
#include <faiss/clone_index.h> |
| 13 |
#include "macros_impl.h" |
| 14 |
|
| 15 |
using faiss::Index; |
| 16 |
using faiss::IndexBinary; |
| 17 |
|
| 18 |
int faiss_clone_index(const FaissIndex* idx, FaissIndex** p_out) { |
| 19 |
try { |
| 20 |
auto out = faiss::clone_index(reinterpret_cast<const Index*>(idx)); |
| 21 |
*p_out = reinterpret_cast<FaissIndex*>(out); |
| 22 |
} |
| 23 |
CATCH_AND_HANDLE |
| 24 |
} |
| 25 |
|
| 26 |
int faiss_clone_index_binary( |
| 27 |
const FaissIndexBinary* idx, |
| 28 |
FaissIndexBinary** p_out) { |
| 29 |
try { |
| 30 |
auto out = faiss::clone_binary_index( |
| 31 |
reinterpret_cast<const IndexBinary*>(idx)); |
| 32 |
*p_out = reinterpret_cast<FaissIndexBinary*>(out); |
| 33 |
} |
| 34 |
CATCH_AND_HANDLE |
| 35 |
} |