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

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...
 
MknnDomainmknn_domain_newParseString (const char *string_domain)
 Creates a new domain object by parsing a string representation generated by mknn_domain_toString. More...
 
MknnDomainmknn_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.
MknnDomainmknn_domain_newString ()
 Creates a new domain object that represents strings. More...
 
Specific functions for the general domain Vector.
MknnDomainmknn_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.
MknnDomainmknn_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...
 
MknnDomainmknn_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.
MknnDomainmknn_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)
 

Detailed Description

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.

Function Documentation

void* mknn_domain_custom_getData ( MknnDomain domain)
Parameters
domain
Returns
the parameter custom_data defined in the constructor
int64_t mknn_domain_custom_getId ( MknnDomain domain)
Parameters
domain
Returns
the parameter custom_id defined in the constructor
MknnGeneralDomain mknn_domain_getGeneralDomain ( MknnDomain domain)

Returns the general domain of the given domain object.

Parameters
domain
Returns
the constant 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.

Parameters
domain
Returns
true if general domain of 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.

Parameters
domain
Returns
true if general domain of 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.

Parameters
domain
Returns
true if general domain of 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.

Parameters
domain
Returns
true if general domain of 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.

Parameters
domain
Returns
the number of objects combined in the multi-object.
MknnDomain* mknn_domain_multiobject_getSubDomain ( MknnDomain domain,
int64_t  num_subdomain 
)

The domain of each object in the multi-object.

Parameters
domain
num_subdomainthe number of the subdomain to retrieve. A number between zero and mknn_domain_multiobject_getLength - 1.
Returns
the domain that describes each object in the multi-object.
MknnDomain* mknn_domain_newClone ( MknnDomain domain)

Duplicates a domain.

Parameters
domainthe original domain
Returns
a new domain equal to 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.

Parameters
custom_ida user-defined parameter
custom_dataa user-defined parameter
Returns
the new domain
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.

Parameters
lengththe number of objects that are combined in a single array.
subdomainsthe domain of each object to be combined.
free_subdomains_on_domain_releaseto release all subdomains during the new domain release.
Returns
a multi-object domain.
MknnDomain* mknn_domain_newParseString ( const char *  string_domain)

Creates a new domain object by parsing a string representation generated by mknn_domain_toString.

Parameters
string_domaina string representation of a domain.
Returns
a new domain (it must be released with mknn_domain_release).
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'.

Returns
a new domain (it must be released with mknn_domain_release).
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.

Parameters
num_dimensionsnumber of dimensions
dimension_datatypedatatype for the vector values. Must be one of the constants MKNN_DATATYPE_xxx.
Returns
a new domain (it must be released with mknn_domain_release).
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.

Parameters
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.
Parameters
domain1
domain2
Returns
true if both domains are equal, false otherwise.
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.
Parameters
domain1
domain2
Returns
true if both domains are equal without considering datatypes, false otherwise.
char* mknn_domain_toString ( MknnDomain domain)

Creates a text representation of the domain and its attributes.

Parameters
domain
Returns
a string representation of the domain
void* mknn_domain_vector_createNewEmptyVectors ( MknnDomain domain,
int64_t  num_vectors 
)

Creates an array with the size to store consecutive num_vectors.

Parameters
domain
Returns
a pointer to a new allocated array (it must be released with free).
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.

Parameters
domain
Returns
the datatype for the vectors.
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.

Parameters
domain
Returns
the number of dimensions of the domain.
void* mknn_domain_vector_getVectorInArray ( MknnDomain domain,
void *  vectors_array,
int64_t  pos_vector 
)
Parameters
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.

Parameters
domain
Returns
the total size in bytes for one vector.
Powered by Download MetricKnn