Skip to content

Commit de922dd

Browse files
Use circulants for routing
1 parent ecbd343 commit de922dd

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

parallel-hnsw/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,14 @@ impl<C> Layer<C> {
158158
}
159159

160160
pub fn routing_nodes(&self, nodeid: NodeId, sp: SearchParameters) -> Vec<NodeId> {
161-
if sp.grid_network_dimension == 0 {
162-
return Vec::new();
163-
}
164-
let increment = self.node_count() / sp.grid_network_dimension;
165-
let mut routing_nodes = Vec::with_capacity(sp.grid_network_dimension);
166-
for i in 1..sp.grid_network_dimension + 1 {
167-
let new_node_id = (i * increment + nodeid.0) % self.node_count();
168-
routing_nodes.push(NodeId(new_node_id))
169-
}
170-
routing_nodes
161+
let primes = [1, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37];
162+
// Calculate using the circulants
163+
let size = self.node_count();
164+
primes
165+
.iter()
166+
.take(sp.grid_network_dimension)
167+
.map(|prime| NodeId((nodeid.0 + prime) % size))
168+
.collect()
171169
}
172170
}
173171

vectorlink-store/src/file.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ impl VectorFile {
8080

8181
let file = options.open(&path)?;
8282
let byte_size = file.metadata()?.size() as usize;
83-
83+
eprintln!("byte_size: {byte_size}");
84+
eprintln!("vector_byte_size: {vector_byte_size}");
8485
assert!(byte_size % vector_byte_size == 0);
8586

8687
let num_vecs = byte_size / vector_byte_size;

0 commit comments

Comments
 (0)