1#ifndef KNNCOLLE_LOAD_PREBUILT_HPP
2#define KNNCOLLE_LOAD_PREBUILT_HPP
5#include <unordered_map>
30template<
typename Index_,
typename Data_,
typename Distance_>
36template<
typename Index_,
typename Data_,
typename Distance_>
37auto default_prebuilt_registry() {
38 std::unordered_map<std::string, LoadPrebuiltFunction<Index_, Data_, Distance_> > registry;
40 return new BruteforcePrebuilt<Index_, Data_, Distance_, DistanceMetric<Data_, Distance_> >(prefix);
43 return new VptreePrebuilt<Index_, Data_, Distance_, DistanceMetric<Data_, Distance_> >(prefix);
61template<
typename Index_,
typename Data_,
typename Distance_>
63 static std::unordered_map<std::string, LoadPrebuiltFunction<Index_, Data_, Distance_> > registry = default_prebuilt_registry<Index_, Data_, Distance_>();
79template<
typename Index_,
typename Data_,
typename Distance_>
81 const auto meth_path = prefix +
"ALGORITHM";
85 auto it = reg.find(method);
86 if (it == reg.end()) {
87 throw std::runtime_error(
"cannot find load_prebuilt method for '" + method +
"' at '" + meth_path +
"'");
90 return (it->second)(prefix);
106template<
typename Index_,
typename Data_,
typename Distance_>
124template<
typename Index_,
typename Data_,
typename Distance_>
166template<
typename Index_,
typename Data_,
typename Distance_,
typename Normalized_>
168 return new L2NormalizedPrebuilt<Index_, Data_, Distance_, Normalized_>(prefix);
Implements a brute-force search for nearest neighbors.
Wrapper for L2 normalization prior to search.
Interface for prebuilt nearest-neighbor indices.
Implements a vantage point (VP) tree to search for nearest neighbors.
Interface for prebuilt nearest-neighbor search indices.
Definition Prebuilt.hpp:28
Collection of KNN algorithms.
Definition Bruteforce.hpp:28
Prebuilt< Index_, Data_, Distance_ > * load_l2normalized_prebuilt(const std::string &prefix)
Definition load_prebuilt.hpp:167
std::string quick_load_as_string(const std::string &path)
Definition utils.hpp:73
NumericType
Definition NumericType.hpp:18
std::unordered_map< std::string, LoadPrebuiltFunction< Index_, Data_, Distance_ > > & load_prebuilt_registry()
Definition load_prebuilt.hpp:62
std::unique_ptr< Prebuilt< Index_, Data_, Distance_ > > load_prebuilt_unique(const std::string &prefix)
Definition load_prebuilt.hpp:107
void quick_load(const std::string &path, Input_ *const contents, const Length_ length)
Definition utils.hpp:56
L2NormalizedPrebuiltTypes load_l2normalized_prebuilt_types(const std::string &prefix)
Definition load_prebuilt.hpp:148
std::shared_ptr< Prebuilt< Index_, Data_, Distance_ > > load_prebuilt_shared(const std::string &prefix)
Definition load_prebuilt.hpp:125
Prebuilt< Index_, Data_, Distance_ > * load_prebuilt_raw(const std::string &prefix)
Definition load_prebuilt.hpp:80
std::function< Prebuilt< Index_, Data_, Distance_ > *(const std::string &)> LoadPrebuiltFunction
Definition load_prebuilt.hpp:31
Template type of a saved L2-normalized index.
Definition load_prebuilt.hpp:134
knncolle::NumericType normalized
Definition load_prebuilt.hpp:138