Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 20, 2025

This PR updates the Rust ingest system to use the modern hnsw_rs API by replacing deprecated methods with their current equivalents.

Changes Made

Fixed Import Issues

  • Removed incorrect hnsw_rs::dist::DistCosine import (module doesn't exist in current version)
  • Updated to use hnsw_rs::prelude::* which properly includes DistCosine from anndists

Replaced Deprecated Methods

  • ingest.rs: Replaced index.dump(&index_path) with index.file_dump(output_dir, "index")
  • query.rs: Replaced Hnsw::file_load(&data_dir, "index") with proper HnswIo::new(&data_dir, "index").load_hnsw()

Fixed Type System Issues

  • Added required lifetime parameters to Hnsw<'_, f32, DistCosine> type annotations
  • Restructured query loading logic to properly manage HnswIo lifetime requirements
  • Updated method signatures for compatibility with current hnsw_rs version

Before

// ingest.rs - deprecated dump method
index.dump(&index_path)?;

// query.rs - incorrect file_load usage
let index: Hnsw<f32, DistCosine> = Hnsw::file_load(&data_dir, "index")?.0;

After

// ingest.rs - modern file_dump method
index.file_dump(output_dir, "index")?;

// query.rs - proper HnswIo usage
let mut reloader = HnswIo::new(&data_dir, "index");
let index = reloader.load_hnsw::<f32, DistCosine>()?;

The code now compiles successfully and uses the current hnsw_rs API as intended.

Fixes #3.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@BryanChasko BryanChasko marked this pull request as ready for review July 20, 2025 01:29
@BryanChasko BryanChasko merged commit 508bb77 into main Jul 20, 2025
1 check passed
Copilot AI changed the title [WIP] Rust ingest: replace deprecated {save/load} with {file_dump/file_load} Replace deprecated hnsw_rs save/load methods with file_dump/file_load Jul 20, 2025
Copilot AI requested a review from BryanChasko July 20, 2025 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust ingest: replace deprecated {save/load} with {file_dump/file_load}

2 participants