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

Represents a set of objects of any type. More...

#include <mknn_dataset.hpp>

Inherited by mknn::DatasetConcatenate, and mknn::DatasetMultiObject.

Public Member Functions

 Dataset ()
 Default constructor.
 
virtual ~Dataset ()
 Default destructor.
 
 Dataset (const Dataset &other)
 Copy constructor.
 
Datasetoperator= (const Dataset &other)
 Assignment operator.
 
Using the dataset
long long getNumObjects ()
 Size of the dataset. More...
 
void * getObject (long long pos)
 Retrieves the object in position pos in dataset. More...
 
void pushObject (void *object)
 Adds an object to a dataset. More...
 
Domain getDomain ()
 Returns the domain assigned to the dataset. More...
 
void * getCompactVectors ()
 The objects in the dataset are stored in a single long array. More...
 
void printObjectsToTextFile (std::string filename_write)
 It saves the objects in a dataset in text format. More...
 

Protected Attributes

std::unique_ptr< Impl > pimpl
 opaque object
 

Friends

class DatasetLoader
 
class Distance
 
class Index
 
class PredefDistance
 
class Resolver
 

Load/Save datasets

void save (std::string filename_write)
 The dataset is saved to a file. More...
 
static Dataset restore (std::string filename_read)
 Loads a dataset from a file. More...
 

Detailed Description

Represents a set of objects of any type.

Objects in dataset are type void*. In order to use some pre-defined distance, the objects in the dataset must have defined a Domain.

Member Function Documentation

void* mknn::Dataset::getCompactVectors ( )

The objects in the dataset are stored in a single long array.

The format of the created data is similar to the input described in DatasetLoader::PointerCompactVectors.

The dataset must contain vectors (i.e., the domain in the dataset must belong to some constant in mknn::Domain::GENERAL_DOMAIN_VECTOR.

The type of the returned array (float*, double*, ...) depends on the domain datatype.

The returned pointer is cached, thus consecutive calls do not compact again the vectors. The cache is released together with the dataset. If an object is added to a dynamic dataset after the call to this method, the cache is released it will not be added.

Returns
a pointer to an array with all the vectors one after the other. The vector will be released by delete (it must not be freed).
Domain mknn::Dataset::getDomain ( )

Returns the domain assigned to the dataset.

Do not modify or free the returned domain.

Returns
domain assigned to the dataset or NULL if no domain has been assigned.
long long mknn::Dataset::getNumObjects ( )

Size of the dataset.

Returns
the number of objects in dataset
void* mknn::Dataset::getObject ( long long  pos)

Retrieves the object in position pos in dataset.

Parameters
posthe position of the object to retrieve. It must be a number between 0 and getNumObjects - 1.
void mknn::Dataset::printObjectsToTextFile ( std::string  filename_write)

It saves the objects in a dataset in text format.

This method is useful for reviewing the objects that are inside a dataset.

Parameters
filename_writeFilename to write or overwrite.
void mknn::Dataset::pushObject ( void *  object)

Adds an object to a dataset.

The dataset must be dynamic in order to support this method (see DatasetLoader::Empty).

Parameters
objectthe new object to add at the end of the dataset.
static Dataset mknn::Dataset::restore ( std::string  filename_read)
static

Loads a dataset from a file.

The file must have been created by save.

Parameters
filename_readFile to read. If the file does not exists an error is raised.
Returns
a new dataset (it must be released with delete).
void mknn::Dataset::save ( std::string  filename_write)

The dataset is saved to a file.

It may create other files using filename_write as prefix. The created files may be in binary format for fast loading.

Parameters
filename_writeFile to create. If the file already exists it is overwritten.

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