Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Altor-lab/altor-vec
/ functions
Functions
78 in github.com/Altor-lab/altor-vec
⨍
Functions
78
◇
Types & classes
6
↓ 21 callers
Method
insert
Insert a vector into the index. The vector will be L2-normalized. Returns the assigned node ID.
src/hnsw/mod.rs:44
↓ 20 callers
Method
search
Search for the `top_k` nearest neighbors of a query vector. Returns JSON: `[[node_id, distance], ...]`
wasm/src/lib.rs:50
↓ 12 callers
Function
normalize
L2-normalize a vector in place. Returns the original norm.
src/distance.rs:10
↓ 9 callers
Method
len
Number of vectors in the index.
src/hnsw/mod.rs:61
↓ 7 callers
Function
random_vector
(dims: usize, rng: &mut impl Rng)
tests/edge_cases_test.rs:5
↓ 5 callers
Method
partial_cmp
(&self, other: &Self)
src/hnsw/search.rs:23
↓ 5 callers
Function
random_unit_vector
(dims: usize, rng: &mut impl Rng)
tests/recall_test.rs:5
↓ 5 callers
Function
search_layer
Search a single layer for the ef closest neighbors to the query. Returns a list of (node_id, distance) sorted by distance ascending.
src/hnsw/search.rs:73
↓ 5 callers
Method
set_neighbors
Set neighbors for a node at a specific layer.
src/hnsw/graph.rs:73
↓ 4 callers
Function
dot_product
Compute dot product of two f32 slices. When vectors are L2-normalized, this equals cosine similarity. This will auto-vectorize with SIMD in release mo
src/distance.rs:4
↓ 4 callers
Method
len
Number of vectors in the index.
wasm/src/lib.rs:61
↓ 4 callers
Function
random_unit_vector
(dims: usize, rng: &mut impl Rng)
benches/search_bench.rs:6
↓ 3 callers
Method
add_node
Add a node with the given vector and layer assignment. Returns the new node's ID.
src/hnsw/graph.rs:52
↓ 3 callers
Function
build_test_index
(n: usize, dims: usize, ef_search: usize)
benches/search_bench.rs:12
↓ 3 callers
Function
knn_search
Top-level KNN search: traverse from top layer to layer 0.
src/hnsw/search.rs:154
↓ 3 callers
Method
to_bytes
Export the index as bytes for later loading.
wasm/src/lib.rs:56
↓ 2 callers
Method
cmp
(&self, other: &Self)
src/hnsw/search.rs:29
↓ 2 callers
Function
dist
(a: &[f32], b: &[f32])
src/hnsw/search.rs:67
↓ 2 callers
Method
get_neighbors
Get neighbors for a node at a specific layer.
src/hnsw/graph.rs:78
↓ 2 callers
Function
measure_recall
( index: &HnswIndex, vectors: &[Vec<f32>], dims: usize, k: usize, num_queries: usize,
tests/recall_test.rs:21
↓ 2 callers
Function
randomQuery
(dims)
wasm/test/node_test.mjs:20
↓ 2 callers
Function
random_layer
Select a random layer for a new node using the HNSW exponential distribution.
src/hnsw/construction.rs:14
↓ 2 callers
Function
random_vector
(dims: usize, rng: &mut impl Rng)
tests/serialization_test.rs:7
↓ 1 callers
Function
brute_force_knn
(vectors: &[Vec<f32>], query: &[f32], k: usize)
tests/recall_test.rs:11
↓ 1 callers
Function
dist
(a: &[f32], b: &[f32])
src/hnsw/construction.rs:9
↓ 1 callers
Function
handleInit
()
wasm/demo/worker.js:10
↓ 1 callers
Function
handleSearch
(query, requestId)
wasm/demo/worker.js:44
↓ 1 callers
Function
insert
Insert a new vector into the HNSW graph. The vector should already be L2-normalized.
src/hnsw/construction.rs:22
↓ 1 callers
Function
main
()
scripts/download_msmarco.py:13
↓ 1 callers
Function
main
()
scripts/embed.py:21
↓ 1 callers
Method
max_connections
Get the max number of connections for a given layer.
src/hnsw/graph.rs:64
↓ 1 callers
Function
search_layer_counted
Like search_layer but also returns the number of distance computations.
src/hnsw/search.rs:84
Method
add_vectors
Add vectors to an existing index. `flat` is a contiguous array of vectors, each of length `dims`.
wasm/src/lib.rs:42
Function
bench_search_1k
(c: &mut Criterion)
benches/search_bench.rs:42
Function
bench_search_ef50
(c: &mut Criterion)
benches/search_bench.rs:22
Function
bench_search_ef500
(c: &mut Criterion)
benches/search_bench.rs:32
Method
eq
(&self, other: &Self)
src/hnsw/search.rs:14
Method
from_bytes
(bytes: &[u8])
src/hnsw/mod.rs:78
Method
from_vectors
Build a new index from a flat f32 array of vectors. `flat` is a contiguous array of vectors, each of length `dims`.
wasm/src/lib.rs:25
Method
is_empty
Whether the index is empty.
src/hnsw/mod.rs:66
Function
main
()
examples/build_index.rs:6
Function
main
()
examples/generate_fixture.rs:6
Method
new
(bytes: &[u8])
wasm/src/lib.rs:16
Method
new
(m: usize)
src/hnsw/graph.rs:40
Method
new
Create a new HNSW index. - `dims`: vector dimensionality - `m`: max connections per node per layer (default: 16) - `ef_construction`: beam width durin
src/hnsw/mod.rs:33
Method
search
Search for the k nearest neighbors of a query vector. The query will be L2-normalized before search. Returns Vec<(node_id, distance)> sorted by ascend
src/hnsw/mod.rs:53
Function
test_basic_search
()
tests/recall_test.rs:116
Function
test_dist_identical
()
src/hnsw/search.rs:181
Function
test_dist_orthogonal
()
src/hnsw/search.rs:187
Function
test_dot_product_high_dimensions
()
src/distance.rs:61
Function
test_dot_product_identical_vectors
()
src/distance.rs:54
Function
test_dot_product_identity
()
src/distance.rs:25
Function
test_dot_product_orthogonal
()
src/distance.rs:32
Function
test_dot_product_zero_vector
()
src/distance.rs:47
Function
test_duplicate_vectors
()
tests/edge_cases_test.rs:32
Function
test_empty_index_search
()
tests/edge_cases_test.rs:10
Function
test_high_dimensional_vectors
()
tests/edge_cases_test.rs:133
Function
test_insert_dimension_mismatch
()
tests/edge_cases_test.rs:55
Function
test_is_empty
()
tests/edge_cases_test.rs:123
Function
test_knn_search_empty_graph
()
src/hnsw/search.rs:194
Function
test_knn_search_single_node
()
src/hnsw/search.rs:202
Function
test_nearest_neighbor_is_self
()
tests/edge_cases_test.rs:157
Function
test_normalize
()
src/distance.rs:39
Function
test_normalize_already_unit
()
src/distance.rs:82
Function
test_normalize_returns_original_norm
()
src/distance.rs:90
Function
test_normalize_zero_vector
()
src/distance.rs:71
Function
test_random_layer_distribution
()
src/hnsw/construction.rs:108
Function
test_recall_at_10
()
tests/recall_test.rs:52
Function
test_recall_matches_reference
()
tests/recall_test.rs:87
Function
test_search_dimension_mismatch
()
tests/edge_cases_test.rs:63
Function
test_search_layer_returns_sorted
()
src/hnsw/search.rs:218
Function
test_search_results_sorted_by_distance
()
tests/edge_cases_test.rs:102
Function
test_search_with_k_zero
()
tests/edge_cases_test.rs:147
Function
test_serialization_round_trip
()
tests/serialization_test.rs:12
Function
test_single_vector_index
()
tests/edge_cases_test.rs:18
Function
test_topk_greater_than_index_size
()
tests/edge_cases_test.rs:84
Function
test_zero_vector_insert
()
tests/edge_cases_test.rs:71
Method
to_bytes
(&self)
src/hnsw/mod.rs:72