Files
faiss/c_api/IndexHNSW_c.cpp
T
Gilbert Gilb's f72867d4ab support SearchParameters for IndexBinary (#4761)
Summary:
- Add support ParameterSpace for IndexBinaryHNSW and IndexBinaryIVF
- Add support SearchParameters in search() method for IndexBinaryHNSW and IndexBinaryIVF
- Add support for passing parameters to IndexBinaryHNSW and IndexBinaryIVF from CAPI

fixes https://github.com/facebookresearch/faiss/issues/3503

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4761

Reviewed By: mdouze

Differential Revision: D91060658

Pulled By: juancarpio27

fbshipit-source-id: f8cd87fc020d410bf2982636d2aa393e6d7e3410
2026-02-04 00:03:15 -08:00

54 lines
1.5 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// -*- c++ -*-
#include "IndexHNSW_c.h"
#include <faiss/impl/HNSW.h>
#include "macros_impl.h"
using faiss::SearchParametersHNSW;
/// SearchParametersHNSW definitions
DEFINE_DESTRUCTOR(SearchParametersHNSW)
DEFINE_SEARCH_PARAMETERS_DOWNCAST(SearchParametersHNSW)
int faiss_SearchParametersHNSW_new(FaissSearchParametersHNSW** p_sp) {
try {
SearchParametersHNSW* sp = new SearchParametersHNSW;
*p_sp = reinterpret_cast<FaissSearchParametersHNSW*>(sp);
return 0;
}
CATCH_AND_HANDLE
}
int faiss_SearchParametersHNSW_new_with(
FaissSearchParametersHNSW** p_sp,
FaissIDSelector* sel,
int efSearch) {
try {
SearchParametersHNSW* sp = new SearchParametersHNSW;
sp->sel = reinterpret_cast<faiss::IDSelector*>(sel);
sp->efSearch = efSearch;
*p_sp = reinterpret_cast<FaissSearchParametersHNSW*>(sp);
return 0;
}
CATCH_AND_HANDLE
}
DEFINE_GETTER_PERMISSIVE(SearchParametersHNSW, const FaissIDSelector*, sel)
DEFINE_GETTER(SearchParametersHNSW, int, efSearch)
DEFINE_SETTER(SearchParametersHNSW, int, efSearch)
DEFINE_GETTER(SearchParametersHNSW, int, check_relative_distance)
DEFINE_SETTER(SearchParametersHNSW, int, check_relative_distance)
DEFINE_GETTER(SearchParametersHNSW, int, bounded_queue)
DEFINE_SETTER(SearchParametersHNSW, int, bounded_queue)