#include <lsh_table.h>
Public Types | |
typedef std::map< BucketKey, Bucket > | BucketsSpace |
typedef std::vector< Bucket > | BucketsSpeed |
Public Member Functions | |
void | add (unsigned int value, const ElementType *feature) |
void | add (const std::vector< std::pair< size_t, ElementType * > > &features) |
const Bucket * | getBucketFromKey (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 |
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.
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.
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.
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
Definition at line 252 of file lsh_table.h.
rtflann::lsh::LshTable< ElementType >::LshTable | ( | ) | [inline] |
Default constructor
Definition at line 142 of file lsh_table.h.
rtflann::lsh::LshTable< ElementType >::LshTable | ( | unsigned | int, |
unsigned | int | ||
) | [inline] |
Default constructor Create the mask and allocate the memory
feature_size | is the size of the feature (considered as a ElementType[]) |
key_size | is the number of bits that are turned on in the feature |
Definition at line 151 of file lsh_table.h.
rtflann::lsh::LshTable< unsigned char >::LshTable | ( | unsigned int | feature_size, |
unsigned int | subsignature_size | ||
) | [inline] |
Definition at line 358 of file lsh_table.h.
void rtflann::lsh::LshTable< ElementType >::add | ( | unsigned int | value, |
const ElementType * | feature | ||
) | [inline] |
Add a feature to the table
value | the value to store for that feature |
feature | the feature itself |
Definition at line 161 of file lsh_table.h.
void rtflann::lsh::LshTable< ElementType >::add | ( | const std::vector< std::pair< size_t, ElementType * > > & | features | ) | [inline] |
Add a set of features to the table
dataset | the values to store |
Definition at line 188 of file lsh_table.h.
const Bucket* rtflann::lsh::LshTable< ElementType >::getBucketFromKey | ( | BucketKey | key | ) | const [inline] |
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.
size_t rtflann::lsh::LshTable< unsigned char >::getKey | ( | const unsigned char * | feature | ) | const [inline] |
Return the Subsignature of a feature
feature | the feature to analyze |
Definition at line 399 of file lsh_table.h.
LshStats rtflann::lsh::LshTable< ElementType >::getStats | ( | ) | const |
Get statistics about the table
LshStats rtflann::lsh::LshTable< unsigned char >::getStats | ( | ) | const [inline] |
Definition at line 432 of file lsh_table.h.
void rtflann::lsh::LshTable< ElementType >::initialize | ( | size_t | key_size | ) | [inline, private] |
Initialize some variables
Definition at line 259 of file lsh_table.h.
void rtflann::lsh::LshTable< ElementType >::optimize | ( | ) | [inline, private] |
Optimize the table for speed/space
Definition at line 267 of file lsh_table.h.
void rtflann::lsh::LshTable< ElementType >::serialize | ( | Archive & | ar | ) | [inline, private] |
Definition at line 301 of file lsh_table.h.
friend struct serialization::access [friend] |
Definition at line 325 of file lsh_table.h.
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.
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.
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.
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.
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.
SpeedLevel rtflann::lsh::LshTable< ElementType >::speed_level_ [private] |
What is used to store the data
Definition at line 336 of file lsh_table.h.