|
|
@ -0,0 +1,29 @@ |
|
|
|
#pragma once |
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
#include "utils.h" |
|
|
|
|
|
|
|
typedef struct NSWGraph |
|
|
|
{ |
|
|
|
|
|
|
|
} NSWGraph; |
|
|
|
|
|
|
|
typedef struct HNSWGraph |
|
|
|
{ |
|
|
|
size_t layers_num; // number of layers |
|
|
|
NSWGraph **layers; |
|
|
|
} HNSWGraph; |
|
|
|
|
|
|
|
typedef struct HNSWContext |
|
|
|
{ |
|
|
|
size_t dim; // dimension of dataset |
|
|
|
size_t len; // size of dataset |
|
|
|
HNSWGraph *graph; // graph of HNSW |
|
|
|
} HNSWContext; |
|
|
|
|
|
|
|
// help functions |
|
|
|
|
|
|
|
// public functions |
|
|
|
HNSWContext *init_hnsw_context(const char *file_path, size_t dim, size_t len); |
|
|
|
void insert_vec(HNSWContext *ctx, VecData vec); |
|
|
|
void approximate_knn(HNSWContext *ctx, VecData *results); |