| 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 "IndexLSH_c.h" |
| 11 |
#include <faiss/IndexLSH.h> |
| 12 |
#include "macros_impl.h" |
| 13 |
|
| 14 |
using faiss::Index; |
| 15 |
using faiss::IndexLSH; |
| 16 |
|
| 17 |
DEFINE_DESTRUCTOR(IndexLSH) |
| 18 |
DEFINE_INDEX_DOWNCAST(IndexLSH) |
| 19 |
|
| 20 |
DEFINE_GETTER(IndexLSH, int, nbits) |
| 21 |
DEFINE_GETTER(IndexLSH, int, code_size) |
| 22 |
DEFINE_GETTER_PERMISSIVE(IndexLSH, int, rotate_data) |
| 23 |
DEFINE_GETTER_PERMISSIVE(IndexLSH, int, train_thresholds) |
| 24 |
|
| 25 |
int faiss_IndexLSH_new(FaissIndexLSH** p_index, idx_t d, int nbits) { |
| 26 |
try { |
| 27 |
*p_index = reinterpret_cast<FaissIndexLSH*>(new IndexLSH(d, nbits)); |
| 28 |
} |
| 29 |
CATCH_AND_HANDLE |
| 30 |
} |
| 31 |
|
| 32 |
int faiss_IndexLSH_new_with_options( |
| 33 |
FaissIndexLSH** p_index, |
| 34 |
idx_t d, |
| 35 |
int nbits, |
| 36 |
int rotate_data, |
| 37 |
int train_thresholds) { |
| 38 |
try { |
| 39 |
*p_index = reinterpret_cast<FaissIndexLSH*>(new IndexLSH( |
| 40 |
d, |
| 41 |
nbits, |
| 42 |
static_cast<bool>(rotate_data), |
| 43 |
static_cast<bool>(train_thresholds))); |
| 44 |
} |
| 45 |
CATCH_AND_HANDLE |
| 46 |
} |