MetricKnn API
Fast Similarity Search using the Metric Space Approach
|
A domain represents the type of object that are contained in a dataset. More...
#include <mknn_domain.hpp>
Public Member Functions | |
std::string | getGeneralDomain () |
Returns the general domain of the given domain object. More... | |
bool | isGeneralDomainString () |
Returns true if the general domain is string. More... | |
bool | isGeneralDomainVector () |
Returns true if the general domain is vector. More... | |
bool | isGeneralDomainMultiObject () |
Returns true if the general domain is multi-object. More... | |
bool | isGeneralDomainCustomObject () |
Returns true if the general domain is custom-object. More... | |
std::string | toString () |
Creates a text representation of the domain and its attributes. More... | |
Domain () | |
Default constructor. | |
virtual | ~Domain () |
Default destructor. | |
Domain (const Domain &other) | |
Copy constructor. | |
Domain & | operator= (const Domain &other) |
Assignment operator. | |
Static Public Member Functions | |
static bool | testEqual (Domain &domain1, Domain &domain2) |
Two domains are equal if they coincide in their general domains and all their attributes. More... | |
static bool | testEqualExceptDatatype (Domain &domain1, Domain &domain2) |
Two domains are equalExceptDatatype if they coincide in their general domains and all their attributes EXCEPT in datatypes. More... | |
static Domain | newParseString (std::string string_domain) |
Creates a new domain object by parsing a string representation generated by toString. More... | |
static Domain | newClone (Domain domain) |
Duplicates a domain. More... | |
Specific functions for the general domain String. | |
static Domain | newString () |
Creates a new domain object that represents strings. More... | |
Static Public Attributes | |
static const std::string | GENERAL_DOMAIN_STRING |
General Domain of Strings. More... | |
static const std::string | GENERAL_DOMAIN_VECTOR |
General Domain of Vectors. More... | |
static const std::string | GENERAL_DOMAIN_MULTIOBJECT |
General Domain of Multi-Object. More... | |
static const std::string | GENERAL_DOMAIN_CUSTOMOBJECT |
General Domain of Custom Objects. More... | |
Protected Attributes | |
std::unique_ptr< Impl > | pimpl |
opaque object | |
Friends | |
class | Dataset |
class | DatasetLoader |
class | Distance |
class | Printer |
Specific functions for the general domain Vector. | |
static Domain | newVector (long long num_dimensions, std::string dimension_datatype) |
Creates a new domain object that represents a vector of some fixed dimension and datatype. More... | |
long long | getVectorNumDimensions () |
Returns the number of dimensions of the vectors. More... | |
std::string | getVectorDimensionDataType () |
Returns the dimension datatype of the vectors. More... | |
long long | getVectorSizeInBytes () |
Returns total size in bytes for one vector, which corresponds to dimensions * sizeof(datatype) , where the size of a datatype is given by Datatype::getNumBytes. More... | |
Specific functions for the general domain Multi-Object. | |
static Domain | newMultiobject (const std::vector< Domain > &subdomains) |
Creates a new domain object that represents a multi-object, i.e., the combination of many objects in an array. More... | |
long long | getMultiobjectLength () |
The number of objects in the multi-object, i.e., the size of the void** array. More... | |
Domain & | getMultiobjectSubDomain (long long num_subdomain) |
The domain of each object in the multi-object. More... | |
Specific functions for the general domain Custom. | |
static Domain | newCustomObject (long long 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... | |
long long | getCustomObjectId () |
void * | getCustomObjectData () |
A domain 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 delete.
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::getCustomObjectData | ( | ) |
custom_data
defined in the constructor long long mknn::Domain::getCustomObjectId | ( | ) |
custom_id
defined in the constructor std::string mknn::Domain::getGeneralDomain | ( | ) |
Returns the general domain of the given domain object.
MKNN_DOMAIN_xxx
that represents the general domain of domain
. long long mknn::Domain::getMultiobjectLength | ( | ) |
The number of objects in the multi-object, i.e., the size of the void**
array.
Domain& mknn::Domain::getMultiobjectSubDomain | ( | long long | num_subdomain | ) |
The domain of each object in the multi-object.
num_subdomain | the number of the subdomain to retrieve. A number between zero and getMultiobjectLength - 1. |
std::string mknn::Domain::getVectorDimensionDataType | ( | ) |
Returns the dimension datatype of the vectors.
If the general domain is not GENERAL_DOMAIN_VECTOR
the method returns NULL.
long long mknn::Domain::getVectorNumDimensions | ( | ) |
Returns the number of dimensions of the vectors.
If the general domain is not GENERAL_DOMAIN_VECTOR the method returns 0.
long long mknn::Domain::getVectorSizeInBytes | ( | ) |
Returns total size in bytes for one vector, which corresponds to dimensions * sizeof(datatype)
, where the size of a datatype is given by Datatype::getNumBytes.
If the general domain is not GENERAL_DOMAIN_VECTOR the method returns 0.
bool mknn::Domain::isGeneralDomainCustomObject | ( | ) |
Returns true if the general domain is custom-object.
test if getGeneralDomain returns the constant GENERAL_DOMAIN_CUSTOMOBJECT.
bool mknn::Domain::isGeneralDomainMultiObject | ( | ) |
Returns true if the general domain is multi-object.
test if getGeneralDomain returns the constant GENERAL_DOMAIN_MULTIOBJECT.
bool mknn::Domain::isGeneralDomainString | ( | ) |
Returns true if the general domain is string.
test if getGeneralDomain returns the constant GENERAL_DOMAIN_STRING.
domain
is GENERAL_DOMAIN_STRING. bool mknn::Domain::isGeneralDomainVector | ( | ) |
Returns true if the general domain is vector.
test if getGeneralDomain returns the constant GENERAL_DOMAIN_VECTOR.
domain
is GENERAL_DOMAIN_VECTOR. Duplicates a domain.
domain | the original domain |
domain
(it must be released with delete).
|
static |
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 |
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.
subdomains | the domain of each object to be combined. |
delete_subdomains_on_domain_release | binds the lifetime of subdomains to the new domain |
|
static |
Creates a new domain object by parsing a string representation generated by toString.
string_domain | a string representation of a domain. |
|
static |
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'
.
|
static |
Creates a new domain object that represents a vector of some fixed dimension and datatype.
The objects will be casted to datatype*
. See constants.
num_dimensions | number of dimensions |
dimension_datatype | datatype for the vector values. Must be one of the constants. |
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 |
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 |
std::string mknn::Domain::toString | ( | ) |
Creates a text representation of the domain and its attributes.
|
static |
General Domain of Custom Objects.
The custom objects are not casted, thus they cannot be saved or printed.
|
static |
General Domain of Multi-Object.
The objects will be casted to void**
(an array of objects).
|
static |
General Domain of Strings.
The objects will be casted to char*
. As usual in C, the end of each string is given by char '\0'
.
|
static |
General Domain of Vectors.
In order to declare a domain the number of dimensions and datatype are needed. The objects will be casted to datatype*
.