Conversation
There was a problem hiding this comment.
Pull request overview
Barebones Rust/Axum vector search server initialization, with in-memory brute-force search used as a temporary engine before CUDA integration.
Changes:
- Adds Axum server routes for health, insert, search, and delete.
- Introduces request/response models, shared app state, and API error helpers.
- Implements an in-memory
FlatIndexusing cosine similarity.
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml |
Defines Rust package and Axum/Tokio/Serde dependencies. |
Cargo.lock |
Locks dependency graph for the new Rust server. |
.gitignore |
Ignores Rust build output and local files. |
src/main.rs |
Wires server startup and HTTP routes. |
src/state.rs |
Adds shared application state for the vector engine. |
src/models.rs |
Adds API request and response structs. |
src/engine.rs |
Adds brute-force in-memory vector index and similarity scoring. |
src/api/mod.rs |
Exposes API modules. |
src/api/response.rs |
Adds API result/error response helpers. |
src/api/handlers.rs |
Implements health, insert, search, and delete handlers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let mut left_norm = 0.0; | ||
| let mut right_norm = 0.0; | ||
|
|
||
| for (left_value, right_value) in left.iter().zip(right.iter()) { |
Comment on lines
+56
to
+58
| dot += left_value * right_value; | ||
| left_norm += left_value * left_value; | ||
| right_norm += right_value * right_value; |
Comment on lines
+51
to
+59
| let engine = state.engine.lock().expect("engine mutex poisoned"); | ||
|
|
||
| if let Some(expected_dimension) = engine.dimension() { | ||
| if request.query.len() != expected_dimension { | ||
| return Err(bad_request("query dimension does not match stored vectors")); | ||
| } | ||
| } | ||
|
|
||
| let results = engine.search(request.query, request.k); |
Comment on lines
+31
to
+41
| let mut results: Vec<SearchResult> = self | ||
| .vectors | ||
| .iter() | ||
| .map(|(id, vector)| SearchResult { | ||
| id: id.clone(), | ||
| score: cosine_similarity(&query, vector), | ||
| }) | ||
| .collect(); | ||
|
|
||
| results.sort_by(|left, right| right.score.total_cmp(&left.score)); | ||
| results.truncate(k); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
barebone initialization of rust server, no cuda engine yet. currently using brute force vector search for testing purposes (making sure engine works).