barrel_vectordb_index_hnsw (barrel_vectordb v2.1.2)
View SourceHNSW backend wrapper for barrel_vectordb_index behaviour
Thin wrapper around barrel_vectordb_hnsw that adapts its API to the barrel_vectordb_index behaviour specification.
Summary
Functions
Delete a vector by ID.
Deserialize index from binary.
Get index information and statistics.
Insert a vector with the given ID.
Create a new HNSW index.
Search for K nearest neighbors.
Search for K nearest neighbors with options.
Serialize index to binary.
Get the number of vectors in the index.
Types
-type hnsw_config() :: #hnsw_config{m :: pos_integer(), m_max0 :: pos_integer(), ef_construction :: pos_integer(), ml :: float() | undefined, distance_fn :: cosine | euclidean, quantization :: quantization_method(), tq_state :: term() | undefined}.
-type hnsw_index() :: #hnsw_index{entry_point :: binary() | undefined, max_layer :: non_neg_integer(), nodes :: #{binary() => hnsw_node()}, config :: hnsw_config(), size :: non_neg_integer(), dimension :: pos_integer()}.
-type hnsw_node() :: #hnsw_node{id :: binary(), vector :: quantized_vector(), norm :: float(), layer :: non_neg_integer(), neighbors :: #{non_neg_integer() => [binary()]}}.
-type quantization_method() :: scalar | pq | turboquant | subspace_turboquant | none.
-type quantized_vector() :: binary().
Functions
-spec delete(hnsw_index(), binary()) -> {ok, hnsw_index()} | {error, term()}.
Delete a vector by ID.
-spec deserialize(binary()) -> {ok, hnsw_index()} | {error, term()}.
Deserialize index from binary.
-spec info(hnsw_index()) -> map().
Get index information and statistics.
-spec insert(hnsw_index(), binary(), [float()]) -> {ok, hnsw_index()} | {error, term()}.
Insert a vector with the given ID.
-spec new(map()) -> {ok, hnsw_index()} | {error, term()}.
Create a new HNSW index.
-spec search(hnsw_index(), [float()], pos_integer()) -> [{binary(), float()}].
Search for K nearest neighbors.
-spec search(hnsw_index(), [float()], pos_integer(), map()) -> [{binary(), float()}].
Search for K nearest neighbors with options.
-spec serialize(hnsw_index()) -> binary().
Serialize index to binary.
-spec size(hnsw_index()) -> non_neg_integer().
Get the number of vectors in the index.