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

Different Loaders. More...

#include <mknn_dataset_loader.hpp>

Static Public Member Functions

static Dataset Custom (DatasetCustom *custom_dataset, bool delete_custom_dataset_on_dataset_release, Domain domain)
 Creates a new custom dataset. More...
 
static Dataset PointerArray (void **object_array, long long num_objects, Domain domain)
 Creates a new dataset from an array of objects. More...
 
static Dataset PointerCompactVectors (void *vectors_header, long long num_vectors, long long vector_num_dimensions, const std::string vector_dimension_datatype)
 Creates a new dataset from a data array. More...
 
static Dataset ParseVectorFile (std::string filename, const std::string datatype)
 Creates a new dataset by reading a text file with vectors. More...
 
static Dataset ParseStringsFile (std::string filename)
 Creates a new dataset by reading a text file with strings. More...
 
static DatasetConcatenate Concatenate (const std::vector< Dataset > &subdatasets)
 Creates a new dataset which is the concatenation of one or more datasets. More...
 
static Dataset SubsetSegment (Dataset &superdataset, long long position_start, long long length)
 Creates a new dataset which is a subset of a bigger dataset. More...
 
static Dataset SubsetPositions (Dataset &superdataset, long long *positions, long long num_positions)
 Creates a new dataset which is a subset of a bigger dataset. More...
 
static Dataset UniformRandomVectors (long long num_objects, long long dimension, double dimension_minValueIncluded, double dimension_maxValueNotIncluded, const std::string datatype)
 Creates a new dataset with random vectors of the given datatype. More...
 
static DatasetMultiObject MultiObject (const std::vector< Dataset > &subdatasets)
 Creates a new dataset where each object is a multi-object. More...
 
static Dataset Empty (Domain domain)
 Creates a new empty dataset that can dynamically grow as new objects are added. More...
 

Detailed Description

Different Loaders.

Member Function Documentation

static DatasetConcatenate mknn::DatasetLoader::Concatenate ( const std::vector< Dataset > &  subdatasets)
static

Creates a new dataset which is the concatenation of one or more datasets.

Parameters
subdatasetsthe array of datasets
delete_subdatasets_on_dataset_releaseall subdatasets[i] must be released (by calling delete) during delete of the new dataset.
Returns
a new dataset (it must be released with delete).
static Dataset mknn::DatasetLoader::Custom ( DatasetCustom custom_dataset,
bool  delete_custom_dataset_on_dataset_release,
Domain  domain 
)
static

Creates a new custom dataset.

The custom dataset must implement the DatasetCustom abstract class.

Parameters
custom_datasetthe object that stores and is used to obtain objects
delete_custom_dataset_on_dataset_releasebinds the lifetime of custom_dataset to the new dataset object
domainthe domain for the objects returned by custom_dataset.
delete_domain_on_dataset_releasebinds the lifetime of domain to this dataset.
Returns
a new dataset object
static Dataset mknn::DatasetLoader::Empty ( Domain  domain)
static

Creates a new empty dataset that can dynamically grow as new objects are added.

The new objects are added by Dataset::pushObject.

Parameters
domainthe domain for the objects that will be added to this dataset.
delete_domain_on_dataset_releasebinds the lifetime of domain to this dataset.
Returns
a new empty dataset (it must be released with delete).
static DatasetMultiObject mknn::DatasetLoader::MultiObject ( const std::vector< Dataset > &  subdatasets)
static

Creates a new dataset where each object is a multi-object.

Each multi-object is created by combining one object of each subdataset. All datasets must contain the same number of objects.

Parameters
subdatasetsthe datasets from which multi-objects will be created.
delete_subdatasets_on_dataset_releaseall subdatasets[i] must be released (by calling delete) during delete of the new dataset.
Returns
a new dataset (it must be released with delete).
static Dataset mknn::DatasetLoader::ParseStringsFile ( std::string  filename)
static

Creates a new dataset by reading a text file with strings.

The format is one string per line.

Parameters
filenamethe filename to read.
Returns
a new dataset (it must be released with delete).
static Dataset mknn::DatasetLoader::ParseVectorFile ( std::string  filename,
const std::string  datatype 
)
static

Creates a new dataset by reading a text file with vectors.

The format is one vector per line, each dimension separated by tab.

Parameters
filenamethe filename to read.
datatypethe datatype of the objects.
Returns
a new dataset (it must be released with delete).
static Dataset mknn::DatasetLoader::PointerArray ( void **  object_array,
long long  num_objects,
Domain  domain 
)
static

Creates a new dataset from an array of objects.

The objects are read from object_array in the following order:

  • first object: object_array[0]
  • second object: object_array[1]
  • ...
  • last object: object_array[num_objects - 1]
Parameters
object_arraypointer to an array of objects.
num_objectsnumber of object to read from the array.
domainthe domain for the objects in the array.
delete_domain_on_dataset_releasebinds the lifetime of domain to this dataset.
Returns
a new dataset (it must be released with delete).
static Dataset mknn::DatasetLoader::PointerCompactVectors ( void *  vectors_header,
long long  num_vectors,
long long  vector_num_dimensions,
const std::string  vector_dimension_datatype 
)
static

Creates a new dataset from a data array.

The objects are read from vectors_header in the following order:

  • first object: vectors_header
  • second object: vectors_header + vector_size
  • ...
  • last object: vectors_header + (num_objects - 1) * vector_size.

The value of vector_size is determined by vector_num_dimensions and vector_dimension_datatype (see mknn::Domain::newVector and mknn::Domain::getVectorSizeInBytes).

Parameters
vectors_headerpointer to the header of the set of vectors.
num_vectorsnumber of object to read from vectors_header.
vector_num_dimensionsnumber of dimensions of the vectors.
vector_dimension_datatypedatatype for the vector values. See constants in mknn::Datatype.
Returns
a new dataset (it must be released with delete).
static Dataset mknn::DatasetLoader::SubsetPositions ( Dataset superdataset,
long long *  positions,
long long  num_positions 
)
static

Creates a new dataset which is a subset of a bigger dataset.

Parameters
superdatasetthe dataset to extract objects
positionseach position of the objects to extract from superdataset. The positions are copied to an internal array.
num_positionslength of array positions. it must be greater than zero.
Returns
a new dataset (it must be released with delete).
static Dataset mknn::DatasetLoader::SubsetSegment ( Dataset superdataset,
long long  position_start,
long long  length 
)
static

Creates a new dataset which is a subset of a bigger dataset.

Parameters
superdatasetthe dataset to extract objects
position_startposition of the first objects to extract.
lengthnumber of consecutive objects to extract, starting from position_start. it must be greater than zero.
Returns
a new dataset (it must be released with delete).
static Dataset mknn::DatasetLoader::UniformRandomVectors ( long long  num_objects,
long long  dimension,
double  dimension_minValueIncluded,
double  dimension_maxValueNotIncluded,
const std::string  datatype 
)
static

Creates a new dataset with random vectors of the given datatype.

Each dimension is bounded in [0, dimension_max_value).

Parameters
num_objectsdesired size of the dataset.
dimensionnumber of dimensions to generate.
dimension_minValueIncludedthe minimum value for each dimension (included).
dimension_maxValueNotIncludedthe maximum value for each dimension (not included).
datatypethe datatype of the generated vectors. See constants in mknn::Datatype.
Returns
a new dataset (it must be released with delete).

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