2019-11-19 07:36:44 -03:00
|
|
|
/**
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
// -*- c++ -*-
|
|
|
|
|
|
|
|
#include "index_factory_c.h"
|
2021-02-25 04:44:50 -08:00
|
|
|
#include <faiss/index_factory.h>
|
|
|
|
#include <cstring>
|
2019-11-19 07:36:44 -03:00
|
|
|
#include "macros_impl.h"
|
|
|
|
|
|
|
|
using faiss::Index;
|
|
|
|
|
2024-03-29 02:37:19 -07:00
|
|
|
/** Build an index with the sequence of processing steps described in
|
2019-11-19 07:36:44 -03:00
|
|
|
* the string.
|
|
|
|
*/
|
2021-02-25 04:44:50 -08:00
|
|
|
int faiss_index_factory(
|
|
|
|
FaissIndex** p_index,
|
|
|
|
int d,
|
|
|
|
const char* description,
|
|
|
|
FaissMetricType metric) {
|
2019-11-19 07:36:44 -03:00
|
|
|
try {
|
|
|
|
*p_index = reinterpret_cast<FaissIndex*>(faiss::index_factory(
|
2021-02-25 04:44:50 -08:00
|
|
|
d, description, static_cast<faiss::MetricType>(metric)));
|
|
|
|
}
|
|
|
|
CATCH_AND_HANDLE
|
2021-02-15 12:40:02 -08:00
|
|
|
}
|
2024-03-29 02:37:19 -07:00
|
|
|
|
|
|
|
/** Build an index with the sequence of processing steps described in
|
|
|
|
* the string.
|
|
|
|
*/
|
|
|
|
int faiss_index_binary_factory(
|
|
|
|
FaissIndexBinary** p_index,
|
|
|
|
int d,
|
|
|
|
const char* description) {
|
|
|
|
try {
|
|
|
|
*p_index = reinterpret_cast<FaissIndexBinary*>(
|
|
|
|
faiss::index_binary_factory(d, description));
|
|
|
|
}
|
|
|
|
CATCH_AND_HANDLE
|
|
|
|
}
|