MetricKnn API
Fast Similarity Search using the Metric Space Approach
|
A MknnDomain represents the type of object that are contained in a dataset. More...
#include "../metricknn_c.h"
Go to the source code of this file.
Functions | |
MknnGeneralDomain | mknn_domain_getGeneralDomain (MknnDomain *domain) |
Returns the general domain of the given domain object. More... | |
bool | mknn_domain_isGeneralDomainString (MknnDomain *domain) |
Returns true if the general domain is string. More... | |
bool | mknn_domain_isGeneralDomainVector (MknnDomain *domain) |
Returns true if the general domain is vector. More... | |
bool | mknn_domain_isGeneralDomainMultiObject (MknnDomain *domain) |
Returns true if the general domain is multi-object. More... | |
bool | mknn_domain_isGeneralDomainCustomObject (MknnDomain *domain) |
Returns true if the general domain is custom-object. More... | |
bool | mknn_domain_testEqual (MknnDomain *domain1, MknnDomain *domain2) |
Two domains are equal if they coincide in their general domains and all their attributes. More... | |
bool | mknn_domain_testEqualExceptDatatype (MknnDomain *domain1, MknnDomain *domain2) |
Two domains are equalExceptDatatype if they coincide in their general domains and all their attributes EXCEPT in datatypes. More... | |
char * | mknn_domain_toString (MknnDomain *domain) |
Creates a text representation of the domain and its attributes. More... | |
MknnDomain * | mknn_domain_newParseString (const char *string_domain) |
Creates a new domain object by parsing a string representation generated by mknn_domain_toString. More... | |
MknnDomain * | mknn_domain_newClone (MknnDomain *domain) |
Duplicates a domain. More... | |
void | mknn_domain_release (MknnDomain *domain) |
Releases the memory used by the domain. More... | |
Specific functions for the general domain String. | |
MknnDomain * | mknn_domain_newString () |
Creates a new domain object that represents strings. More... | |
Specific functions for the general domain Vector. | |
MknnDomain * | mknn_domain_newVector (int64_t num_dimensions, MknnDatatype dimension_datatype) |
Creates a new domain object that represents a vector of some fixed dimension and datatype. More... | |
int64_t | mknn_domain_vector_getNumDimensions (MknnDomain *domain) |
Returns the number of dimensions of the vectors. More... | |
MknnDatatype | mknn_domain_vector_getDimensionDataType (MknnDomain *domain) |
Returns the dimension datatype of the vectors. More... | |
void * | mknn_domain_vector_createNewEmptyVectors (MknnDomain *domain, int64_t num_vectors) |
Creates an array with the size to store consecutive num_vectors. More... | |
void * | mknn_domain_vector_getVectorInArray (MknnDomain *domain, void *vectors_array, int64_t pos_vector) |
int64_t | mknn_domain_vector_getVectorLengthInBytes (MknnDomain *domain) |
Returns total size in bytes for one vector, which corresponds to dimensions * sizeof(datatype) , where the size of a datatype is given by mknn_datatype_sizeof. More... | |
Specific functions for the general domain Multi-Object. | |
MknnDomain * | mknn_domain_newMultiobject (int64_t length, MknnDomain **subdomains, bool free_subdomains_on_domain_release) |
Creates a new domain object that represents a multi-object, i.e., the combination of many objects in an array. More... | |
int64_t | mknn_domain_multiobject_getLength (MknnDomain *domain) |
The number of objects in the multi-object, i.e., the size of the void** array. More... | |
MknnDomain * | mknn_domain_multiobject_getSubDomain (MknnDomain *domain, int64_t num_subdomain) |
The domain of each object in the multi-object. More... | |
Specific functions for the general domain Custom. | |
MknnDomain * | mknn_domain_newCustomObject (int64_t custom_id, void *custom_data) |
Creates a new domain object that represents a multi-object, i.e., the combination of many objects in an array. More... | |
int64_t | mknn_domain_custom_getId (MknnDomain *domain) |
void * | mknn_domain_custom_getData (MknnDomain *domain) |
A MknnDomain represents the type of object that are contained in a dataset.
A general domain represents a broad type of object. Currently, MetricKnn supports two general domains: Strings and Vectors. In the case of vectors a domain considers the number of dimensions and its datatype.
In order to avoid memory leaks, each created MknnDomain* must call the function mknn_domain_release.
The declaration of object domain is needed in order to use some of the pre-defined distances. The domain enables to cast the void*
object into other more meaningful type. If the objects in a dataset will be compared with some user-defined distance, then there is no need to declare the domain of objects.
void* mknn_domain_custom_getData | ( | MknnDomain * | domain | ) |
domain |
custom_data
defined in the constructor int64_t mknn_domain_custom_getId | ( | MknnDomain * | domain | ) |
domain |
custom_id
defined in the constructor MknnGeneralDomain mknn_domain_getGeneralDomain | ( | MknnDomain * | domain | ) |
Returns the general domain of the given domain object.
domain |
MKNN_DOMAIN_xxx
that represents the general domain of domain
. bool mknn_domain_isGeneralDomainCustomObject | ( | MknnDomain * | domain | ) |
Returns true if the general domain is custom-object.
test if mknn_domain_getGeneralDomain returns the constant MKNN_GENERAL_DOMAIN_CUSTOMOBJECT.
domain |
domain
is MKNN_GENERAL_DOMAIN_CUSTOMOBJECT. bool mknn_domain_isGeneralDomainMultiObject | ( | MknnDomain * | domain | ) |
Returns true if the general domain is multi-object.
test if mknn_domain_getGeneralDomain returns the constant MKNN_GENERAL_DOMAIN_MULTIOBJECT.
domain |
domain
is MKNN_GENERAL_DOMAIN_MULTIOBJECT. bool mknn_domain_isGeneralDomainString | ( | MknnDomain * | domain | ) |
Returns true if the general domain is string.
test if mknn_domain_getGeneralDomain returns the constant MKNN_GENERAL_DOMAIN_STRING.
domain |
domain
is MKNN_GENERAL_DOMAIN_STRING. bool mknn_domain_isGeneralDomainVector | ( | MknnDomain * | domain | ) |
Returns true if the general domain is vector.
test if mknn_domain_getGeneralDomain returns the constant MKNN_GENERAL_DOMAIN_VECTOR.
domain |
domain
is MKNN_GENERAL_DOMAIN_VECTOR. int64_t mknn_domain_multiobject_getLength | ( | MknnDomain * | domain | ) |
The number of objects in the multi-object, i.e., the size of the void**
array.
domain |
MknnDomain* mknn_domain_multiobject_getSubDomain | ( | MknnDomain * | domain, |
int64_t | num_subdomain | ||
) |
The domain of each object in the multi-object.
domain | |
num_subdomain | the number of the subdomain to retrieve. A number between zero and mknn_domain_multiobject_getLength - 1. |
MknnDomain* mknn_domain_newClone | ( | MknnDomain * | domain | ) |
Duplicates a domain.
domain | the original domain |
domain
(it must be released with mknn_domain_release). MknnDomain* mknn_domain_newCustomObject | ( | int64_t | custom_id, |
void * | custom_data | ||
) |
Creates a new domain object that represents a multi-object, i.e., the combination of many objects in an array.
custom_id | a user-defined parameter |
custom_data | a user-defined parameter |
MknnDomain* mknn_domain_newMultiobject | ( | int64_t | length, |
MknnDomain ** | subdomains, | ||
bool | free_subdomains_on_domain_release | ||
) |
Creates a new domain object that represents a multi-object, i.e., the combination of many objects in an array.
The objects will be casted to void**
. The size of the multi-object corresponds to the number of objects that are combined.
length | the number of objects that are combined in a single array. |
subdomains | the domain of each object to be combined. |
free_subdomains_on_domain_release | to release all subdomains during the new domain release. |
MknnDomain* mknn_domain_newParseString | ( | const char * | string_domain | ) |
Creates a new domain object by parsing a string representation generated by mknn_domain_toString.
string_domain | a string representation of a domain. |
MknnDomain* mknn_domain_newString | ( | ) |
Creates a new domain object that represents strings.
The objects will be casted to char*
. As usual in C, the end of each string is given by char '\0'
.
MknnDomain* mknn_domain_newVector | ( | int64_t | num_dimensions, |
MknnDatatype | dimension_datatype | ||
) |
Creates a new domain object that represents a vector of some fixed dimension and datatype.
The objects will be casted to datatype*
. See MKNN_DATATYPE_xxx
constants.
num_dimensions | number of dimensions |
dimension_datatype | datatype for the vector values. Must be one of the constants MKNN_DATATYPE_xxx . |
void mknn_domain_release | ( | MknnDomain * | domain | ) |
Releases the memory used by the domain.
The released object becomes invalid and it must not be read. In order to avoid memory leaks, each created MknnDomain* must call the function mknn_domain_release.
domain |
bool mknn_domain_testEqual | ( | MknnDomain * | domain1, |
MknnDomain * | domain2 | ||
) |
Two domains are equal if they coincide in their general domains and all their attributes.
e.g., in the general domain vector:
128-double
and 128-double
are equal. 128-double
and 128-uint8
are NOT equal. 128-double
and 100-double
are NOT equal.domain1 | |
domain2 |
bool mknn_domain_testEqualExceptDatatype | ( | MknnDomain * | domain1, |
MknnDomain * | domain2 | ||
) |
Two domains are equalExceptDatatype if they coincide in their general domains and all their attributes EXCEPT in datatypes.
e.g., in the general domain vector:
128-double
and 128-double
are equalExceptDatatype. 128-double
and 128-uint8
are equalExceptDatatype. 128-double
and 100-double
are NOT equalExceptDatatype.domain1 | |
domain2 |
char* mknn_domain_toString | ( | MknnDomain * | domain | ) |
Creates a text representation of the domain and its attributes.
domain |
void* mknn_domain_vector_createNewEmptyVectors | ( | MknnDomain * | domain, |
int64_t | num_vectors | ||
) |
Creates an array with the size to store consecutive num_vectors.
domain |
MknnDatatype mknn_domain_vector_getDimensionDataType | ( | MknnDomain * | domain | ) |
Returns the dimension datatype of the vectors.
If the general domain is not MKNN_GENERAL_DOMAIN_VECTOR the method returns NULL.
domain |
int64_t mknn_domain_vector_getNumDimensions | ( | MknnDomain * | domain | ) |
Returns the number of dimensions of the vectors.
If the general domain is not MKNN_GENERAL_DOMAIN_VECTOR the method returns 0.
domain |
void* mknn_domain_vector_getVectorInArray | ( | MknnDomain * | domain, |
void * | vectors_array, | ||
int64_t | pos_vector | ||
) |
domain | |
vectors_array | |
pos_vector |
int64_t mknn_domain_vector_getVectorLengthInBytes | ( | MknnDomain * | domain | ) |
Returns total size in bytes for one vector, which corresponds to dimensions * sizeof(datatype)
, where the size of a datatype is given by mknn_datatype_sizeof.
If the general domain is not MKNN_GENERAL_DOMAIN_VECTOR the method returns 0.
domain |