template class cvflann::lsh::LshTable

Overview

Lsh hash table. Moreā€¦

#include <lsh_table.h>

template <typename ElementType>
class LshTable
{
public:
    // typedefs

    typedef std::map<BucketKey, Bucket> BucketsSpace;
    typedef std::vector<Bucket> BucketsSpeed;

    // construction

    LshTable();

    LshTable(
        unsigned int feature_size,
        unsigned int key_size
        );

    LshTable(
        unsigned int feature_size,
        unsigned int subsignature_size
        );

    // methods

    void
    add(
        unsigned int value,
        const ElementType* feature
        );

    void
    add(Matrix<ElementType> dataset);

    const Bucket*
    getBucketFromKey(BucketKey key) const;

    size_t
    getKey(const ElementType*) const;

    size_t
    getKey(const unsigned char* feature) const;

    LshStats
    getStats() const;

    LshStats
    getStats() const;
};

Detailed Documentation

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)

Typedefs

typedef std::map<BucketKey, Bucket> BucketsSpace

A container of all the feature indices. Optimized for space

typedef std::vector<Bucket> BucketsSpeed

A container of all the feature indices. Optimized for speed

Construction

LshTable()

Default constructor

LshTable(
    unsigned int feature_size,
    unsigned int key_size
    )

Default constructor Create the mask and allocate the memory

Parameters:

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

Methods

void
add(
    unsigned int value,
    const ElementType* feature
    )

Add a feature to the table

Parameters:

value the value to store for that feature
feature the feature itself
void
add(Matrix<ElementType> dataset)

Add a set of features to the table

Parameters:

dataset the values to store
const Bucket*
getBucketFromKey(BucketKey key) const

Get a bucket given the key

Parameters:

key  

Returns:

size_t
getKey(const ElementType*) const

Compute the sub-signature of a feature

size_t
getKey(const unsigned char* feature) const

Return the Subsignature of a feature

Parameters:

feature the feature to analyze
LshStats
getStats() const

Get statistics about the table

Returns: