knncolle_hnsw
knncolle bindings for HNSW
Loading...
Searching...
No Matches
utils.hpp
1#ifndef KNNCOLLE_HNSW_UTILS_HPP
2#define KNNCOLLE_HNSW_UTILS_HPP
3
4#include "hnswlib/hnswalg.h"
5
6#include <functional>
7#include <string>
8#include <type_traits>
9#include <filesystem>
10
11namespace knncolle_hnsw {
12
16template<typename Input_>
17using I = std::remove_cv_t<std::remove_reference_t<Input_> >;
37template<class HnswData_>
38std::function<void(const std::filesystem::path&)>& custom_save_for_hnsw_data() {
39 static std::function<void(const std::filesystem::path&)> fun;
40 return fun;
41}
42
62template<typename HnswData_>
63std::function<void(const std::filesystem::path&, const hnswlib::SpaceInterface<HnswData_>*)>& custom_save_for_hnsw_distance() {
64 static std::function<void(const std::filesystem::path&, const hnswlib::SpaceInterface<HnswData_>*)> fun;
65 return fun;
66}
67
87template<typename Distance_>
88std::function<void(const std::filesystem::path&, const std::function<Distance_(Distance_)>&)>& custom_save_for_hnsw_normalize() {
89 static std::function<void(const std::filesystem::path&, const std::function<Distance_(Distance_)>&)> fun;
90 return fun;
91}
92
113template<typename HnswData_>
114std::function<hnswlib::SpaceInterface<HnswData_>*(const std::filesystem::path&, std::size_t)>& custom_load_for_hnsw_distance() {
115 static std::function<hnswlib::SpaceInterface<HnswData_>*(const std::filesystem::path&, std::size_t)> fun;
116 return fun;
117}
118
137template<typename Distance_>
138std::function<std::function<Distance_(Distance_)>(const std::filesystem::path&)>& custom_load_for_hnsw_normalize() {
139 static std::function<std::function<Distance_(Distance_)>(const std::filesystem::path&)> fun;
140 return fun;
141}
142
143}
144
145#endif
knncolle bindings for HNSW search.
Definition distances.hpp:13
std::function< void(const std::filesystem::path &)> & custom_save_for_hnsw_data()
Definition utils.hpp:38
std::function< void(const std::filesystem::path &, const hnswlib::SpaceInterface< HnswData_ > *)> & custom_save_for_hnsw_distance()
Definition utils.hpp:63
std::function< void(const std::filesystem::path &, const std::function< Distance_(Distance_)> &)> & custom_save_for_hnsw_normalize()
Definition utils.hpp:88
std::function< std::function< Distance_(Distance_)>(const std::filesystem::path &)> & custom_load_for_hnsw_normalize()
Definition utils.hpp:138
std::function< hnswlib::SpaceInterface< HnswData_ > *(const std::filesystem::path &, std::size_t)> & custom_load_for_hnsw_distance()
Definition utils.hpp:114