Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
rtflann::lsh::LshTable< ElementType > Class Template Reference

#include <lsh_table.h>

Public Types

typedef std::map< BucketKey, BucketBucketsSpace
 
typedef std::vector< BucketBucketsSpeed
 

Public Member Functions

void add (unsigned int value, const ElementType *feature)
 
void add (const std::vector< std::pair< size_t, ElementType * > > &features)
 
const BucketgetBucketFromKey (BucketKey key) const
 
size_t getKey (const ElementType *) const
 
template<>
size_t getKey (const unsigned char *feature) const
 
LshStats getStats () const
 
template<>
LshStats getStats () const
 
 LshTable ()
 
 LshTable (unsigned int, unsigned int)
 
template<>
 LshTable (unsigned int feature_size, unsigned int subsignature_size)
 

Private Types

enum  SpeedLevel { kArray, kBitsetHash, kHash }
 

Private Member Functions

void initialize (size_t key_size)
 
void optimize ()
 
template<typename Archive >
void serialize (Archive &ar)
 

Private Attributes

BucketsSpace buckets_space_
 
BucketsSpeed buckets_speed_
 
DynamicBitset key_bitset_
 
unsigned int key_size_
 
std::vector< size_t > mask_
 
SpeedLevel speed_level_
 

Friends

struct serialization::access
 

Detailed Description

template<typename ElementType>
class rtflann::lsh::LshTable< ElementType >

Lsh hash table. As its key is a sub-feature, and as usually the size of it is pretty small, we keep it as a continuous memory array. The value is an index in the corpus of features (we keep it as an unsigned int for pure memory reasons, it could be a size_t)

Definition at line 125 of file lsh_table.h.

Member Typedef Documentation

template<typename ElementType>
typedef std::map<BucketKey, Bucket> rtflann::lsh::LshTable< ElementType >::BucketsSpace

A container of all the feature indices. Optimized for space

Definition at line 133 of file lsh_table.h.

template<typename ElementType>
typedef std::vector<Bucket> rtflann::lsh::LshTable< ElementType >::BucketsSpeed

A container of all the feature indices. Optimized for speed

Definition at line 138 of file lsh_table.h.

Member Enumeration Documentation

template<typename ElementType>
enum rtflann::lsh::LshTable::SpeedLevel
private

defines the speed fo the implementation kArray uses a vector for storing data kBitsetHash uses a hash map but checks for the validity of a key with a bitset kHash uses a hash map only

Enumerator
kArray 
kBitsetHash 
kHash 

Definition at line 252 of file lsh_table.h.

Constructor & Destructor Documentation

template<typename ElementType>
rtflann::lsh::LshTable< ElementType >::LshTable ( )
inline

Default constructor

Definition at line 142 of file lsh_table.h.

template<typename ElementType>
rtflann::lsh::LshTable< ElementType >::LshTable ( unsigned  int,
unsigned  int 
)
inline

Default constructor Create the mask and allocate the memory

Parameters
feature_sizeis the size of the feature (considered as a ElementType[])
key_sizeis the number of bits that are turned on in the feature

Definition at line 151 of file lsh_table.h.

template<>
rtflann::lsh::LshTable< unsigned char >::LshTable ( unsigned int  feature_size,
unsigned int  subsignature_size 
)
inline

Definition at line 358 of file lsh_table.h.

Member Function Documentation

template<typename ElementType>
void rtflann::lsh::LshTable< ElementType >::add ( unsigned int  value,
const ElementType *  feature 
)
inline

Add a feature to the table

Parameters
valuethe value to store for that feature
featurethe feature itself

Definition at line 161 of file lsh_table.h.

template<typename ElementType>
void rtflann::lsh::LshTable< ElementType >::add ( const std::vector< std::pair< size_t, ElementType * > > &  features)
inline

Add a set of features to the table

Parameters
datasetthe values to store

Definition at line 188 of file lsh_table.h.

template<typename ElementType>
const Bucket* rtflann::lsh::LshTable< ElementType >::getBucketFromKey ( BucketKey  key) const
inline

Get a bucket given the key

Parameters
key
Returns

Definition at line 205 of file lsh_table.h.

template<typename ElementType>
size_t rtflann::lsh::LshTable< ElementType >::getKey ( const ElementType *  ) const
inline

Compute the sub-signature of a feature

Definition at line 234 of file lsh_table.h.

template<>
size_t rtflann::lsh::LshTable< unsigned char >::getKey ( const unsigned char *  feature) const
inline

Return the Subsignature of a feature

Parameters
featurethe feature to analyze

Definition at line 399 of file lsh_table.h.

template<typename ElementType>
LshStats rtflann::lsh::LshTable< ElementType >::getStats ( ) const

Get statistics about the table

Returns
template<>
LshStats rtflann::lsh::LshTable< unsigned char >::getStats ( ) const
inline

Definition at line 432 of file lsh_table.h.

template<typename ElementType>
void rtflann::lsh::LshTable< ElementType >::initialize ( size_t  key_size)
inlineprivate

Initialize some variables

Definition at line 259 of file lsh_table.h.

template<typename ElementType>
void rtflann::lsh::LshTable< ElementType >::optimize ( )
inlineprivate

Optimize the table for speed/space

Definition at line 267 of file lsh_table.h.

template<typename ElementType>
template<typename Archive >
void rtflann::lsh::LshTable< ElementType >::serialize ( Archive &  ar)
inlineprivate

Definition at line 301 of file lsh_table.h.

Friends And Related Function Documentation

template<typename ElementType>
friend struct serialization::access
friend

Definition at line 325 of file lsh_table.h.

Member Data Documentation

template<typename ElementType>
BucketsSpace rtflann::lsh::LshTable< ElementType >::buckets_space_
private

The hash table of all the buckets in case we cannot use the speed version

Definition at line 333 of file lsh_table.h.

template<typename ElementType>
BucketsSpeed rtflann::lsh::LshTable< ElementType >::buckets_speed_
private

The vector of all the buckets if they are held for speed

Definition at line 329 of file lsh_table.h.

template<typename ElementType>
DynamicBitset rtflann::lsh::LshTable< ElementType >::key_bitset_
private

If the subkey is small enough, it will keep track of which subkeys are set through that bitset That is just a speedup so that we don't look in the hash table (which can be mush slower that checking a bitset)

Definition at line 341 of file lsh_table.h.

template<typename ElementType>
unsigned int rtflann::lsh::LshTable< ElementType >::key_size_
private

The size of the sub-signature in bits

Definition at line 345 of file lsh_table.h.

template<typename ElementType>
std::vector<size_t> rtflann::lsh::LshTable< ElementType >::mask_
private

The mask to apply to a feature to get the hash key Only used in the unsigned char case

Definition at line 351 of file lsh_table.h.

template<typename ElementType>
SpeedLevel rtflann::lsh::LshTable< ElementType >::speed_level_
private

What is used to store the data

Definition at line 336 of file lsh_table.h.


The documentation for this class was generated from the following file:


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:43:43