MetricKnn API
Fast Similarity Search using the Metric Space Approach
mknn_params.hpp
1 /*
2  * Copyright (C) 2012-2015, Juan Manuel Barrios <juanmanuel@barrios.cl>
3  * All rights reserved.
4  *
5  * This file is part of MetricKnn.
6  * MetricKnn is made available under the terms of the BSD 2-Clause License.
7  */
8 
9 #ifndef MKNN_PARAMS_HPP_
10 #define MKNN_PARAMS_HPP_
11 
12 #include "../metricknn_cpp.hpp"
13 
14 namespace mknn {
15 
22 public:
27  static DistanceParams newEmpty();
28 
34  static DistanceParams newParseString(std::string parameters_string);
35 
50  void parseString(std::string parameters_string);
51 
56  void copyAll(DistanceParams &params_from);
57 
62  std::string toString();
63 
79  void addString(std::string name, std::string value);
80 
88  void addDouble(std::string name, double value);
89 
97  void addInt(std::string name, long long value);
98 
106  void addBool(std::string name, bool value);
107 
116  void addObject(std::string name, void *value);
132  std::string getString(std::string name);
139  double getDouble(std::string name);
140 
147  long long getInt(std::string name);
148 
155  bool getBool(std::string name);
156 
163  void *getObject(std::string name);
164 
177  void setDistanceId(std::string id_dist);
182  std::string getDistanceId();
190  DistanceParams();
194  virtual ~DistanceParams();
198  DistanceParams(const DistanceParams &other);
202  DistanceParams &operator=(const DistanceParams &other);
203 
204 protected:
208  class Impl;
212  std::unique_ptr<Impl> pimpl;
213 
214  friend class Distance;
215  friend class PredefDistance;
216 };
217 
223 class IndexParams {
224 public:
229  static IndexParams newEmpty();
230 
236  static IndexParams newParseString(std::string parameters_string);
237 
248  void parseString(std::string parameters_string);
249 
254  void copyAll(IndexParams &params_from);
255 
260  std::string toString();
261 
273  void addString(std::string name, std::string value);
274 
282  void addDouble(std::string name, double value);
283 
291  void addInt(std::string name, long long value);
292 
300  void addBool(std::string name, bool value);
301 
310  void addObject(std::string name, void *value);
326  std::string getString(std::string name);
333  double getDouble(std::string name);
334 
341  long long getInt(std::string name);
342 
349  bool getBool(std::string name);
350 
357  void *getObject(std::string name);
358 
371  void setIndexId(std::string id_index);
376  std::string getIndexId();
377 
384  IndexParams();
388  virtual ~IndexParams();
392  IndexParams(const IndexParams &other);
396  IndexParams &operator=(const IndexParams &other);
397 
398 protected:
402  class Impl;
406  std::unique_ptr<Impl> pimpl;
407 
408  friend class Index;
409  friend class PredefIndex;
410 };
411 
418 public:
419 
424  static ResolverParams newEmpty();
425 
436  static ResolverParams newParseString(long long knn, double range,
437  long long max_threads, std::string parameters_string);
438 
447  void parseString(std::string parameters_string);
448 
453  void copyAll(ResolverParams &params_from);
454 
459  std::string toString();
460 
472  void addString(std::string name, std::string value);
473 
481  void addDouble(std::string name, double value);
482 
490  void addInt(std::string name, long long value);
491 
499  void addBool(std::string name, bool value);
500 
509  void addObject(std::string name, void *value);
525  std::string getString(std::string name);
532  double getDouble(std::string name);
533 
540  long long getInt(std::string name);
541 
548  bool getBool(std::string name);
549 
556  void *getObject(std::string name);
570  void setKnn(long long knn);
576  void setRange(double range);
582  void setMaxThreads(long long max_threads);
587  long long getKnn();
592  long long getRange();
597  long long getMaxThreads();
598 
605  ResolverParams();
609  virtual ~ResolverParams();
613  ResolverParams(const ResolverParams &other);
617  ResolverParams &operator=(const ResolverParams &other);
618 
619 protected:
623  class Impl;
627  std::unique_ptr<Impl> pimpl;
628 
629  friend class Resolver;
630  friend class Index;
631  friend class PredefIndex;
632 };
633 
634 }
635 
636 #endif
bool getBool(std::string name)
Returns a boolean value.
Stores parameters in an internal map, which associates a names with its value.
Definition: mknn_params.hpp:21
Stores parameters in an internal map, which associates a names with its value.
Definition: mknn_params.hpp:223
void addBool(std::string name, bool value)
Adds an boolean value to the parameters.
void * getObject(std::string name)
Returns a object reference.
bool getBool(std::string name)
Returns a boolean value.
DistanceParams()
Default constructor.
void addInt(std::string name, long long value)
Adds an integer number to the parameters.
MetricKnn provides a set of pre-defined distances.
Definition: mknn_predefined_distance.hpp:30
void setIndexId(std::string id_index)
long long getInt(std::string name)
Returns an integer number.
void parseString(std::string parameters_string)
Parses a string in the format: ID_INDEX,parameter1=value1,parameter2=value2
long long getMaxThreads()
void addDouble(std::string name, double value)
Adds a floating point number to the parameters.
void setDistanceId(std::string id_dist)
std::unique_ptr< Impl > pimpl
opaque object
Definition: mknn_params.hpp:623
long long getInt(std::string name)
Returns an integer number.
void addInt(std::string name, long long value)
Adds an integer number to the parameters.
void addObject(std::string name, void *value)
Adds an object number to the parameters.
std::string getString(std::string name)
Returns a string value.
double getDouble(std::string name)
Returns a floating-point number.
void copyAll(ResolverParams &params_from)
Copies all the key-values pairs in params_from and adds them to params_to.
std::string toString()
Returns a string with the parameters which can be parsed.
ResolverParams()
Default constructor.
void addBool(std::string name, bool value)
Adds an boolean value to the parameters.
virtual ~DistanceParams()
Default destructor.
A Index represents the index structure.
Definition: mknn_index.hpp:45
virtual ~ResolverParams()
Default destructor.
std::string getIndexId()
void copyAll(DistanceParams &params_from)
Copies all the key-values pairs in params_from and adds them to params_to.
void * getObject(std::string name)
Returns a object reference.
Stores parameters in an internal map, which associates a names with its value.
Definition: mknn_params.hpp:417
void addBool(std::string name, bool value)
Adds an boolean value to the parameters.
IndexParams()
Default constructor.
void setMaxThreads(long long max_threads)
Sets the maximum number of threads to be used by a resolver.
void addObject(std::string name, void *value)
Adds an object number to the parameters.
static IndexParams newParseString(std::string parameters_string)
Creates an empty object and set parameters by calling method parseString.
std::string getString(std::string name)
Returns a string value.
static ResolverParams newEmpty()
Creates an empty object.
double getDouble(std::string name)
Returns a floating-point number.
DistanceParams & operator=(const DistanceParams &other)
Assignment operator.
void parseString(std::string parameters_string)
Parses a string in the format: ID_DISTANCE,parameter1=value1,parameter2=value2
ResolverParams & operator=(const ResolverParams &other)
Assignment operator.
void addDouble(std::string name, double value)
Adds a floating point number to the parameters.
Definition: mevaluation_answers.hpp:18
void copyAll(IndexParams &params_from)
Copies all the key-values pairs in params_from and adds them to params_to.
static DistanceParams newParseString(std::string parameters_string)
Creates an empty object and set parameters by calling method parseString.
void setRange(double range)
Sets the range parameter for resolvers in range searches.
void addDouble(std::string name, double value)
Adds a floating point number to the parameters.
IndexParams & operator=(const IndexParams &other)
Assignment operator.
std::string toString()
Returns a string with the parameters which can be parsed.
The Distance is the object with the definition of the method for comparing objects.
Definition: mknn_distance.hpp:59
std::unique_ptr< Impl > pimpl
opaque object
Definition: mknn_params.hpp:208
void addObject(std::string name, void *value)
Adds an object number to the parameters.
static ResolverParams newParseString(long long knn, double range, long long max_threads, std::string parameters_string)
Creates an empty object and set parameters by calling methods: setKnn, setRange, setMaxThreads, parseString.
std::string toString()
Returns a string with the parameters which can be parsed.
long long getInt(std::string name)
Returns an integer number.
void setKnn(long long knn)
Sets the K parameter for resolvers in k-NN searches.
virtual ~IndexParams()
Default destructor.
void addInt(std::string name, long long value)
Adds an integer number to the parameters.
long long getRange()
std::string getString(std::string name)
Returns a string value.
void addString(std::string name, std::string value)
Adds a string to the parameters.
std::unique_ptr< Impl > pimpl
opaque object
Definition: mknn_params.hpp:402
void addString(std::string name, std::string value)
Adds a string to the parameters.
double getDouble(std::string name)
Returns a floating-point number.
std::string getDistanceId()
void addString(std::string name, std::string value)
Adds a string to the parameters.
MetricKnn provides a set of pre-defined indexes.
Definition: mknn_predefined_index.hpp:24
A Resolver represents the parameters of a similarity search.
Definition: mknn_resolver.hpp:27
void parseString(std::string parameters_string)
Parses a string in the format: parameter1=value1,parameter2=value2
static DistanceParams newEmpty()
Creates an empty object.
static IndexParams newEmpty()
Creates an empty object.
void * getObject(std::string name)
Returns a object reference.
bool getBool(std::string name)
Returns a boolean value.
Powered by Download MetricKnn