MetricKnn API
Fast Similarity Search using the Metric Space Approach
mknn_params.h File Reference

A parameters object stores parameters in an internal map, which associates a names with its value. More...

#include "../metricknn_c.h"

Go to the source code of this file.

Functions

MknnDistanceParams
MknnDistanceParamsmknn_distanceParams_newEmpty ()
 Creates an empty object. More...
 
MknnDistanceParamsmknn_distanceParams_newParseString (const char *parameters_string)
 Creates an empty object and set parameters by calling method mknn_distanceParams_parseString. More...
 
void mknn_distanceParams_parseString (MknnDistanceParams *params, const char *parameters_string)
 Parses a string in the format: ID_DISTANCE,parameter1=value1,parameter2=value2 More...
 
void mknn_distanceParams_copyAll (MknnDistanceParams *params_to, MknnDistanceParams *params_from)
 Copies all the key-values pairs in params_from and adds them to params_to. More...
 
void mknn_distanceParams_release (MknnDistanceParams *params)
 Releases the parameters object. More...
 
const char * mknn_distanceParams_toString (MknnDistanceParams *params)
 Returns a string with the parameters which can be parsed. More...
 
MknnDistanceParams Add Methods
void mknn_distanceParams_addString (MknnDistanceParams *params, const char *name, const char *value)
 Adds a string to the parameters. More...
 
void mknn_distanceParams_addDouble (MknnDistanceParams *params, const char *name, double value)
 Adds a floating point number to the parameters. More...
 
void mknn_distanceParams_addInt (MknnDistanceParams *params, const char *name, int64_t value)
 Adds an integer number to the parameters. More...
 
void mknn_distanceParams_addBool (MknnDistanceParams *params, const char *name, bool value)
 Adds an boolean value to the parameters. More...
 
void mknn_distanceParams_addObject (MknnDistanceParams *params, const char *name, void *value)
 Adds an object number to the parameters. More...
 
MknnDistanceParams Get Methods
const char * mknn_distanceParams_getString (MknnDistanceParams *params, const char *name)
 Returns a string value. More...
 
double mknn_distanceParams_getDouble (MknnDistanceParams *params, const char *name)
 Returns a floating-point number. More...
 
int64_t mknn_distanceParams_getInt (MknnDistanceParams *params, const char *name)
 Returns an integer number. More...
 
bool mknn_distanceParams_getBool (MknnDistanceParams *params, const char *name)
 Returns a boolean value. More...
 
void * mknn_distanceParams_getObject (MknnDistanceParams *params, const char *name)
 Returns a object reference. More...
 
MknnDistanceParams Other Methods
void mknn_distanceParams_setDistanceId (MknnDistanceParams *p, const char *id_dist)
 
const char * mknn_distanceParams_getDistanceId (MknnDistanceParams *p)
 
MknnIndexParams
MknnIndexParamsmknn_indexParams_newEmpty ()
 Creates an empty object. More...
 
MknnIndexParamsmknn_indexParams_newParseString (const char *parameters_string)
 Creates an empty object and set parameters by calling method mknn_indexParams_parseString. More...
 
void mknn_indexParams_parseString (MknnIndexParams *params, const char *parameters_string)
 Parses a string in the format: ID_INDEX,parameter1=value1,parameter2=value2 More...
 
void mknn_indexParams_copyAll (MknnIndexParams *params_to, MknnIndexParams *params_from)
 Copies all the key-values pairs in params_from and adds them to params_to. More...
 
void mknn_indexParams_release (MknnIndexParams *params)
 Releases the parameters object. More...
 
const char * mknn_indexParams_toString (MknnIndexParams *params)
 Returns a string with the parameters which can be parsed. More...
 
MknnIndexParams Add Methods
void mknn_indexParams_addString (MknnIndexParams *params, const char *name, const char *value)
 Adds a string to the parameters. More...
 
void mknn_indexParams_addDouble (MknnIndexParams *params, const char *name, double value)
 Adds a floating point number to the parameters. More...
 
void mknn_indexParams_addInt (MknnIndexParams *params, const char *name, int64_t value)
 Adds an integer number to the parameters. More...
 
void mknn_indexParams_addBool (MknnIndexParams *params, const char *name, bool value)
 Adds an boolean value to the parameters. More...
 
void mknn_indexParams_addObject (MknnIndexParams *params, const char *name, void *value)
 Adds an object number to the parameters. More...
 
MknnIndexParams Get Methods
const char * mknn_indexParams_getString (MknnIndexParams *params, const char *name)
 Returns a string value. More...
 
double mknn_indexParams_getDouble (MknnIndexParams *params, const char *name)
 Returns a floating-point number. More...
 
int64_t mknn_indexParams_getInt (MknnIndexParams *params, const char *name)
 Returns an integer number. More...
 
bool mknn_indexParams_getBool (MknnIndexParams *params, const char *name)
 Returns a boolean value. More...
 
void * mknn_indexParams_getObject (MknnIndexParams *params, const char *name)
 Returns a object reference. More...
 
MknnIndexParams Other Methods
void mknn_indexParams_setIndexId (MknnIndexParams *p, const char *id_index)
 
const char * mknn_indexParams_getIndexId (MknnIndexParams *p)
 
MknnResolverParams
MknnResolverParamsmknn_resolverParams_newEmpty ()
 Creates an empty object. More...
 
MknnResolverParamsmknn_resolverParams_newParseString (int64_t knn, double range, int64_t max_threads, const char *parameters_string)
 Creates an empty object and set parameters by calling methods: mknn_resolverParams_setKnn, mknn_resolverParams_setRange, mknn_resolverParams_setMaxThreads, mknn_resolverParams_parseString. More...
 
void mknn_resolverParams_parseString (MknnResolverParams *params, const char *parameters_string)
 Parses a string in the format: parameter1=value1,parameter2=value2 More...
 
void mknn_resolverParams_copyAll (MknnResolverParams *params_to, MknnResolverParams *params_from)
 Copies all the key-values pairs in params_from and adds them to params_to. More...
 
void mknn_resolverParams_release (MknnResolverParams *params)
 Releases the parameters object. More...
 
const char * mknn_resolverParams_toString (MknnResolverParams *params)
 Returns a string with the parameters which can be parsed. More...
 
MknnResolverParams Add Methods
void mknn_resolverParams_addString (MknnResolverParams *params, const char *name, const char *value)
 Adds a string to the parameters. More...
 
void mknn_resolverParams_addDouble (MknnResolverParams *params, const char *name, double value)
 Adds a floating point number to the parameters. More...
 
void mknn_resolverParams_addInt (MknnResolverParams *params, const char *name, int64_t value)
 Adds an integer number to the parameters. More...
 
void mknn_resolverParams_addBool (MknnResolverParams *params, const char *name, bool value)
 Adds an boolean value to the parameters. More...
 
void mknn_resolverParams_addObject (MknnResolverParams *params, const char *name, void *value)
 Adds an object number to the parameters. More...
 
MknnResolverParams Get Methods
const char * mknn_resolverParams_getString (MknnResolverParams *params, const char *name)
 Returns a string value. More...
 
double mknn_resolverParams_getDouble (MknnResolverParams *params, const char *name)
 Returns a floating-point number. More...
 
int64_t mknn_resolverParams_getInt (MknnResolverParams *params, const char *name)
 Returns an integer number. More...
 
bool mknn_resolverParams_getBool (MknnResolverParams *params, const char *name)
 Returns a boolean value. More...
 
void * mknn_resolverParams_getObject (MknnResolverParams *params, const char *name)
 Returns a object reference. More...
 
MknnResolverParams Other Methods
void mknn_resolverParams_setKnn (MknnResolverParams *params, int64_t knn)
 Sets the K parameter for resolvers in k-NN searches. More...
 
void mknn_resolverParams_setRange (MknnResolverParams *params, double range)
 Sets the range parameter for resolvers in range searches. More...
 
void mknn_resolverParams_setMaxThreads (MknnResolverParams *params, int64_t max_threads)
 Sets the maximum number of threads to be used by a resolver. More...
 
int64_t mknn_resolverParams_getKnn (MknnResolverParams *params)
 
double mknn_resolverParams_getRange (MknnResolverParams *params)
 
int64_t mknn_resolverParams_getMaxThreads (MknnResolverParams *params)
 

Detailed Description

A parameters object stores parameters in an internal map, which associates a names with its value.

The internal map only stores two type of objects: strings and void pointers. The getter and setter methods that use integer/double/boolean actually convert them to/from a string.

Function Documentation

void mknn_distanceParams_addBool ( MknnDistanceParams params,
const char *  name,
bool  value 
)

Adds an boolean value to the parameters.

A copy of name is stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_distanceParams_addDouble ( MknnDistanceParams params,
const char *  name,
double  value 
)

Adds a floating point number to the parameters.

A copy of name is stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_distanceParams_addInt ( MknnDistanceParams params,
const char *  name,
int64_t  value 
)

Adds an integer number to the parameters.

A copy of name is stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_distanceParams_addObject ( MknnDistanceParams params,
const char *  name,
void *  value 
)

Adds an object number to the parameters.

A copy of name is stored in params but the value pointer itself is stored in params. Therefore the value pointer must remain valid during all the lifetime of params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_distanceParams_addString ( MknnDistanceParams params,
const char *  name,
const char *  value 
)

Adds a string to the parameters.

A copy of name and value are stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_distanceParams_copyAll ( MknnDistanceParams params_to,
MknnDistanceParams params_from 
)

Copies all the key-values pairs in params_from and adds them to params_to.

Parameters
params_tothe parameters where the values are copies to
params_fromthe parameters from which the values are read.
bool mknn_distanceParams_getBool ( MknnDistanceParams params,
const char *  name 
)

Returns a boolean value.

Parameters
paramsparameters
namethe name of the parameter.
Returns
the stored value. If the stored value is not a boolean value, it will raise an error.
const char* mknn_distanceParams_getDistanceId ( MknnDistanceParams p)
Parameters
p
Returns
double mknn_distanceParams_getDouble ( MknnDistanceParams params,
const char *  name 
)

Returns a floating-point number.

Parameters
paramsparameters
namethe name of the parameter.
Returns
the stored number. If the stored value is not a number, it will raise an error.
int64_t mknn_distanceParams_getInt ( MknnDistanceParams params,
const char *  name 
)

Returns an integer number.

Parameters
paramsparameters
namethe name of the parameter.
Returns
the stored number. If the stored value is not a number, it will raise an error.
void* mknn_distanceParams_getObject ( MknnDistanceParams params,
const char *  name 
)

Returns a object reference.

Parameters
paramsparameters
namethe name of the parameter.
Returns
a pointer to the stored object.
const char* mknn_distanceParams_getString ( MknnDistanceParams params,
const char *  name 
)

Returns a string value.

Parameters
paramsparameters
namethe name of the parameter.
Returns
a pointer to the stored string (it must not be modified).
MknnDistanceParams* mknn_distanceParams_newEmpty ( )

Creates an empty object.

Returns
a new empty object.
MknnDistanceParams* mknn_distanceParams_newParseString ( const char *  parameters_string)

Creates an empty object and set parameters by calling method mknn_distanceParams_parseString.

Parameters
parameters_stringthe string with parameters.
Returns
a parameters object
void mknn_distanceParams_parseString ( MknnDistanceParams params,
const char *  parameters_string 
)

Parses a string in the format: ID_DISTANCE,parameter1=value1,parameter2=value2

Each parsed parameter is added to params.

For example:

  • LP,order=0.5
  • DPF,order=1,pct_discard=0.1

The list of valid IDs can be listed by invoking mknn_predefDistance_helpListDistances.

Parameters
paramsthe parameters object
parameters_stringthe string with parameters.
void mknn_distanceParams_release ( MknnDistanceParams params)

Releases the parameters object.

Parameters
paramsthe parameters object to be released.
void mknn_distanceParams_setDistanceId ( MknnDistanceParams p,
const char *  id_dist 
)
Parameters
p
id_dist
const char* mknn_distanceParams_toString ( MknnDistanceParams params)

Returns a string with the parameters which can be parsed.

Parameters
paramsthe parameters object
Returns
a string representation of parameters. The string is released during mknn_distanceParams_release.
void mknn_indexParams_addBool ( MknnIndexParams params,
const char *  name,
bool  value 
)

Adds an boolean value to the parameters.

A copy of name is stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_indexParams_addDouble ( MknnIndexParams params,
const char *  name,
double  value 
)

Adds a floating point number to the parameters.

A copy of name is stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_indexParams_addInt ( MknnIndexParams params,
const char *  name,
int64_t  value 
)

Adds an integer number to the parameters.

A copy of name is stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_indexParams_addObject ( MknnIndexParams params,
const char *  name,
void *  value 
)

Adds an object number to the parameters.

A copy of name is stored in params but the value pointer itself is stored in params. Therefore the value pointer must remain valid during all the lifetime of params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_indexParams_addString ( MknnIndexParams params,
const char *  name,
const char *  value 
)

Adds a string to the parameters.

A copy of name and value are stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_indexParams_copyAll ( MknnIndexParams params_to,
MknnIndexParams params_from 
)

Copies all the key-values pairs in params_from and adds them to params_to.

Parameters
params_tothe parameters where the values are copies to
params_fromthe parameters from which the values are read.
bool mknn_indexParams_getBool ( MknnIndexParams params,
const char *  name 
)

Returns a boolean value.

Parameters
paramsparameters
namethe name of the parameter.
Returns
the stored value. If the stored value is not a boolean value, it will raise an error.
double mknn_indexParams_getDouble ( MknnIndexParams params,
const char *  name 
)

Returns a floating-point number.

Parameters
paramsparameters
namethe name of the parameter.
Returns
the stored number. If the stored value is not a number, it will raise an error.
const char* mknn_indexParams_getIndexId ( MknnIndexParams p)
Parameters
p
Returns
int64_t mknn_indexParams_getInt ( MknnIndexParams params,
const char *  name 
)

Returns an integer number.

Parameters
paramsparameters
namethe name of the parameter.
Returns
the stored number. If the stored value is not a number, it will raise an error.
void* mknn_indexParams_getObject ( MknnIndexParams params,
const char *  name 
)

Returns a object reference.

Parameters
paramsparameters
namethe name of the parameter.
Returns
a pointer to the stored object.
const char* mknn_indexParams_getString ( MknnIndexParams params,
const char *  name 
)

Returns a string value.

Parameters
paramsparameters
namethe name of the parameter.
Returns
a pointer to the stored string (it must not be modified).
MknnIndexParams* mknn_indexParams_newEmpty ( )

Creates an empty object.

Returns
a new empty object.
MknnIndexParams* mknn_indexParams_newParseString ( const char *  parameters_string)

Creates an empty object and set parameters by calling method mknn_indexParams_parseString.

Parameters
parameters_stringthe string in the given format.
Returns
a parameters object
void mknn_indexParams_parseString ( MknnIndexParams params,
const char *  parameters_string 
)

Parses a string in the format: ID_INDEX,parameter1=value1,parameter2=value2

Each parsed parameters is added to params.

The list of valid indexes and their IDs can be listed by invoking mknn_predefIndex_helpListIndexes.

Parameters
paramsthe parameters object
parameters_stringthe string in the given format.
void mknn_indexParams_release ( MknnIndexParams params)

Releases the parameters object.

Parameters
paramsthe parameters object to be released.
void mknn_indexParams_setIndexId ( MknnIndexParams p,
const char *  id_index 
)
Parameters
p
id_index
const char* mknn_indexParams_toString ( MknnIndexParams params)

Returns a string with the parameters which can be parsed.

Parameters
paramsthe parameters object
Returns
a string representation of parameters. The string is released during mknn_indexParams_release.
void mknn_resolverParams_addBool ( MknnResolverParams params,
const char *  name,
bool  value 
)

Adds an boolean value to the parameters.

A copy of name is stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_resolverParams_addDouble ( MknnResolverParams params,
const char *  name,
double  value 
)

Adds a floating point number to the parameters.

A copy of name is stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_resolverParams_addInt ( MknnResolverParams params,
const char *  name,
int64_t  value 
)

Adds an integer number to the parameters.

A copy of name is stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_resolverParams_addObject ( MknnResolverParams params,
const char *  name,
void *  value 
)

Adds an object number to the parameters.

A copy of name is stored in params but the value pointer itself is stored in params. Therefore the value pointer must remain valid during all the lifetime of params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_resolverParams_addString ( MknnResolverParams params,
const char *  name,
const char *  value 
)

Adds a string to the parameters.

A copy of name and value are stored in params.

Parameters
paramsparameters
namethe name of the parameter.
valuethe value of the parameter.
void mknn_resolverParams_copyAll ( MknnResolverParams params_to,
MknnResolverParams params_from 
)

Copies all the key-values pairs in params_from and adds them to params_to.

Parameters
params_tothe parameters where the values are copies to
params_fromthe parameters from which the values are read.
bool mknn_resolverParams_getBool ( MknnResolverParams params,
const char *  name 
)

Returns a boolean value.

Parameters
paramsparameters
namethe name of the parameter.
Returns
the stored value. If the stored value is not a boolean value, it will raise an error.
double mknn_resolverParams_getDouble ( MknnResolverParams params,
const char *  name 
)

Returns a floating-point number.

Parameters
paramsparameters
namethe name of the parameter.
Returns
the stored number. If the stored value is not a number, it will raise an error.
int64_t mknn_resolverParams_getInt ( MknnResolverParams params,
const char *  name 
)

Returns an integer number.

Parameters
paramsparameters
namethe name of the parameter.
Returns
the stored number. If the stored value is not a number, it will raise an error.
int64_t mknn_resolverParams_getKnn ( MknnResolverParams params)
Parameters
params
Returns
int64_t mknn_resolverParams_getMaxThreads ( MknnResolverParams params)
Parameters
params
Returns
void* mknn_resolverParams_getObject ( MknnResolverParams params,
const char *  name 
)

Returns a object reference.

Parameters
paramsparameters
namethe name of the parameter.
Returns
a pointer to the stored object.
double mknn_resolverParams_getRange ( MknnResolverParams params)
Parameters
params
Returns
const char* mknn_resolverParams_getString ( MknnResolverParams params,
const char *  name 
)

Returns a string value.

Parameters
paramsparameters
namethe name of the parameter.
Returns
a pointer to the stored string (it must not be modified).
MknnResolverParams* mknn_resolverParams_newEmpty ( )

Creates an empty object.

Returns
a new empty object.
MknnResolverParams* mknn_resolverParams_newParseString ( int64_t  knn,
double  range,
int64_t  max_threads,
const char *  parameters_string 
)

Creates an empty object and set parameters by calling methods: mknn_resolverParams_setKnn, mknn_resolverParams_setRange, mknn_resolverParams_setMaxThreads, mknn_resolverParams_parseString.

Parameters
knn
range
max_threads
parameters_stringthe string in the format parameter1=value1,...
Returns
a parameters object
void mknn_resolverParams_parseString ( MknnResolverParams params,
const char *  parameters_string 
)

Parses a string in the format: parameter1=value1,parameter2=value2

Each parsed parameters is added to params

Parameters
paramsthe parameters object
parameters_stringthe string in the format parameter1=value1,...
void mknn_resolverParams_release ( MknnResolverParams params)

Releases the parameters object.

Parameters
paramsthe parameters object to be released.
void mknn_resolverParams_setKnn ( MknnResolverParams params,
int64_t  knn 
)

Sets the K parameter for resolvers in k-NN searches.

Parameters
paramsparameters
knn
void mknn_resolverParams_setMaxThreads ( MknnResolverParams params,
int64_t  max_threads 
)

Sets the maximum number of threads to be used by a resolver.

Parameters
paramsparameters
max_threads
void mknn_resolverParams_setRange ( MknnResolverParams params,
double  range 
)

Sets the range parameter for resolvers in range searches.

Parameters
paramsparameters
range
const char* mknn_resolverParams_toString ( MknnResolverParams params)

Returns a string with the parameters which can be parsed.

Parameters
paramsthe parameters object
Returns
a string representation of parameters. The string is released during mknn_resolverParams_release.
Powered by Download MetricKnn