VaneDB 0.1.0
Embeddable vector database for edge AI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
vanedb::HNSWIndex Class Reference

#include <hnsw_index.h>

Public Member Functions

 HNSWIndex (size_t dimension, DistanceMetric metric=DistanceMetric::L2, size_t max_elements=100000, size_t M=16, size_t ef_construction=200, uint32_t seed=42)
 
void add (uint64_t id, const float *vec)
 
std::vector< HNSWSearchResultsearch (const float *query, size_t k) const
 
void set_ef_search (size_t ef)
 
size_t get_ef_search () const
 
size_t size () const
 
size_t dimension () const
 
size_t capacity () const
 
bool contains (uint64_t id) const
 
std::vector< float > get_vector (uint64_t id) const
 
void save (const std::string &filename) const
 

Static Public Member Functions

static std::unique_ptr< HNSWIndexload (const std::string &filename)
 

Static Public Attributes

static constexpr uint32_t MAGIC = 0x51565244
 
static constexpr uint32_t VERSION = 2
 
static constexpr int MAX_LEVEL = 32
 
static constexpr size_t INVALID_ID = static_cast<size_t>(-1)
 

Detailed Description

Definition at line 55 of file hnsw_index.h.

Constructor & Destructor Documentation

◆ HNSWIndex()

vanedb::HNSWIndex::HNSWIndex ( size_t  dimension,
DistanceMetric  metric = DistanceMetric::L2,
size_t  max_elements = 100000,
size_t  M = 16,
size_t  ef_construction = 200,
uint32_t  seed = 42 
)
inlineexplicit

Definition at line 62 of file hnsw_index.h.

References dimension().

Member Function Documentation

◆ add()

void vanedb::HNSWIndex::add ( uint64_t  id,
const float *  vec 
)
inline

Definition at line 82 of file hnsw_index.h.

References INVALID_ID.

◆ capacity()

size_t vanedb::HNSWIndex::capacity ( ) const
inline

Definition at line 189 of file hnsw_index.h.

◆ contains()

bool vanedb::HNSWIndex::contains ( uint64_t  id) const
inline

Definition at line 190 of file hnsw_index.h.

◆ dimension()

size_t vanedb::HNSWIndex::dimension ( ) const
inline

Definition at line 188 of file hnsw_index.h.

Referenced by HNSWIndex().

◆ get_ef_search()

size_t vanedb::HNSWIndex::get_ef_search ( ) const
inline

Definition at line 186 of file hnsw_index.h.

◆ get_vector()

std::vector< float > vanedb::HNSWIndex::get_vector ( uint64_t  id) const
inline

Definition at line 192 of file hnsw_index.h.

◆ load()

static std::unique_ptr< HNSWIndex > vanedb::HNSWIndex::load ( const std::string &  filename)
inlinestatic

◆ save()

void vanedb::HNSWIndex::save ( const std::string &  filename) const
inline

◆ search()

std::vector< HNSWSearchResult > vanedb::HNSWIndex::search ( const float *  query,
size_t  k 
) const
inline

Definition at line 150 of file hnsw_index.h.

References size().

◆ set_ef_search()

void vanedb::HNSWIndex::set_ef_search ( size_t  ef)
inline

Definition at line 182 of file hnsw_index.h.

◆ size()

size_t vanedb::HNSWIndex::size ( ) const
inline

Definition at line 187 of file hnsw_index.h.

Referenced by save(), and search().

Member Data Documentation

◆ INVALID_ID

constexpr size_t vanedb::HNSWIndex::INVALID_ID = static_cast<size_t>(-1)
staticconstexpr

Definition at line 60 of file hnsw_index.h.

Referenced by add(), and load().

◆ MAGIC

constexpr uint32_t vanedb::HNSWIndex::MAGIC = 0x51565244
staticconstexpr

Definition at line 57 of file hnsw_index.h.

Referenced by load(), and save().

◆ MAX_LEVEL

constexpr int vanedb::HNSWIndex::MAX_LEVEL = 32
staticconstexpr

Definition at line 59 of file hnsw_index.h.

Referenced by load().

◆ VERSION

constexpr uint32_t vanedb::HNSWIndex::VERSION = 2
staticconstexpr

Definition at line 58 of file hnsw_index.h.

Referenced by load(), and save().


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