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

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_tmask_
 
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 186 of file lsh_table.h.

Member Typedef Documentation

◆ BucketsSpace

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 194 of file lsh_table.h.

◆ BucketsSpeed

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 199 of file lsh_table.h.

Member Enumeration Documentation

◆ SpeedLevel

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 313 of file lsh_table.h.

Constructor & Destructor Documentation

◆ LshTable() [1/3]

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

Default constructor

Definition at line 203 of file lsh_table.h.

◆ LshTable() [2/3]

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 212 of file lsh_table.h.

◆ LshTable() [3/3]

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

Definition at line 419 of file lsh_table.h.

Member Function Documentation

◆ add() [1/2]

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 249 of file lsh_table.h.

◆ add() [2/2]

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 222 of file lsh_table.h.

◆ getBucketFromKey()

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 266 of file lsh_table.h.

◆ getKey() [1/2]

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

Compute the sub-signature of a feature

Definition at line 295 of file lsh_table.h.

◆ getKey() [2/2]

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 462 of file lsh_table.h.

◆ getStats() [1/2]

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

Get statistics about the table

Returns

◆ getStats() [2/2]

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

Definition at line 495 of file lsh_table.h.

◆ initialize()

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

Initialize some variables

Definition at line 320 of file lsh_table.h.

◆ optimize()

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

Optimize the table for speed/space

Definition at line 328 of file lsh_table.h.

◆ serialize()

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

Definition at line 362 of file lsh_table.h.

Friends And Related Function Documentation

◆ serialization::access

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

Definition at line 386 of file lsh_table.h.

Member Data Documentation

◆ buckets_space_

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 394 of file lsh_table.h.

◆ buckets_speed_

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 390 of file lsh_table.h.

◆ key_bitset_

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 402 of file lsh_table.h.

◆ key_size_

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

The size of the sub-signature in bits

Definition at line 406 of file lsh_table.h.

◆ mask_

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 412 of file lsh_table.h.

◆ speed_level_

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

What is used to store the data

Definition at line 397 of file lsh_table.h.


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


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:29