MetricKnn API
Fast Similarity Search using the Metric Space Approach
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
mknn::Domain Class Reference

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.
 
Domainoperator= (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...
 
DomaingetMultiobjectSubDomain (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 ()
 

Detailed Description

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.

Member Function Documentation

void* mknn::Domain::getCustomObjectData ( )
Returns
the parameter custom_data defined in the constructor
long long mknn::Domain::getCustomObjectId ( )
Returns
the parameter custom_id defined in the constructor
std::string mknn::Domain::getGeneralDomain ( )

Returns the general domain of the given domain object.

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

Returns
the number of objects combined in the multi-object.
Domain& mknn::Domain::getMultiobjectSubDomain ( long long  num_subdomain)

The domain of each object in the multi-object.

Parameters
num_subdomainthe number of the subdomain to retrieve. A number between zero and getMultiobjectLength - 1.
Returns
the domain that describes each object in the multi-object.
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.

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

Returns
the number of dimensions of the domain.
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.

Returns
the total size in bytes for one vector.
bool mknn::Domain::isGeneralDomainCustomObject ( )

Returns true if the general domain is custom-object.

test if getGeneralDomain returns the constant GENERAL_DOMAIN_CUSTOMOBJECT.

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

Returns
true if general domain is GENERAL_DOMAIN_MULTIOBJECT.
bool mknn::Domain::isGeneralDomainString ( )

Returns true if the general domain is string.

test if getGeneralDomain returns the constant GENERAL_DOMAIN_STRING.

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

Returns
true if general domain of domain is GENERAL_DOMAIN_VECTOR.
static Domain mknn::Domain::newClone ( Domain  domain)
static

Duplicates a domain.

Parameters
domainthe original domain
Returns
a new domain equal to domain (it must be released with delete).
static Domain mknn::Domain::newCustomObject ( long long  custom_id,
void *  custom_data 
)
static

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
static Domain mknn::Domain::newMultiobject ( const std::vector< Domain > &  subdomains)
static

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
subdomainsthe domain of each object to be combined.
delete_subdomains_on_domain_releasebinds the lifetime of subdomains to the new domain
Returns
a multi-object domain.
static Domain mknn::Domain::newParseString ( std::string  string_domain)
static

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

Parameters
string_domaina string representation of a domain.
Returns
a new domain (it must be released with delete).
static Domain mknn::Domain::newString ( )
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'.

Returns
a new domain (it must be released with delete).
static Domain mknn::Domain::newVector ( long long  num_dimensions,
std::string  dimension_datatype 
)
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.

Parameters
num_dimensionsnumber of dimensions
dimension_datatypedatatype for the vector values. Must be one of the constants.
Returns
a new domain (it must be released with delete).
static bool mknn::Domain::testEqual ( Domain domain1,
Domain domain2 
)
static

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.
static bool mknn::Domain::testEqualExceptDatatype ( Domain domain1,
Domain domain2 
)
static

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 compatible, false otherwise.
std::string mknn::Domain::toString ( )

Creates a text representation of the domain and its attributes.

Returns
a string representation of the domain

Member Data Documentation

const std::string mknn::Domain::GENERAL_DOMAIN_CUSTOMOBJECT
static

General Domain of Custom Objects.

The custom objects are not casted, thus they cannot be saved or printed.

const std::string mknn::Domain::GENERAL_DOMAIN_MULTIOBJECT
static

General Domain of Multi-Object.

The objects will be casted to void** (an array of objects).

const std::string mknn::Domain::GENERAL_DOMAIN_STRING
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'.

const std::string mknn::Domain::GENERAL_DOMAIN_VECTOR
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*.


The documentation for this class was generated from the following file:
Powered by Download MetricKnn