Skip to content

[flat] Post-processing support and use DataProvider::InternalId#1160

Merged
arkrishn94 merged 12 commits into
mainfrom
u/adkrishnan/flat-post-process
Jun 15, 2026
Merged

[flat] Post-processing support and use DataProvider::InternalId#1160
arkrishn94 merged 12 commits into
mainfrom
u/adkrishnan/flat-post-process

Conversation

@arkrishn94

@arkrishn94 arkrishn94 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This PR adds support to do post-processing in the FlatIndex::knn_search via the diskann::glue::SearchPostProcess trait; which is the same interface used by the graph search API.

In addition, I had left a hook in the flat search SearchStrategy and DistancesUnordered to support ID types that were not convertible to and from scalar-like values. With #1145, that constraint is now gone in VectorId and we are free to correctly tie the ID type in the DistancesUnordered implementation used by the flat index to the InternalId of the underlying DataProvider. This means:

  • DistancesUnordered now has HasId as a super-trait.
  • SearchStrategy no longer needs Id as an associated type.

Testing

Added testing in the test module to make sure post-processing works as it should via a custom post-processor that only keeps even ids. Added some extra code in the test::harness module just to make the dispatch to post-processing generic enough so I can enumerate easily over cases.

For reviewers: Review the flat\strategy.rs changes first, then flat\index.rs. Optionally, then, review the testing code.

arkrishn94 added 10 commits May 21, 2026 19:10
# Conflicts:
#	diskann-bftree/src/neighbors.rs
…t-process

# Conflicts:
#	diskann-bftree/src/neighbors.rs
#	diskann-providers/src/model/graph/provider/async_/inmem/full_precision.rs
#	diskann-providers/src/model/graph/provider/async_/inmem/product.rs
#	diskann-providers/src/model/graph/provider/async_/inmem/provider.rs
#	diskann-providers/src/model/graph/provider/async_/inmem/scalar.rs
#	diskann-providers/src/model/graph/provider/async_/inmem/spherical.rs
#	diskann/src/graph/index.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends FlatIndex::knn_search to support post-processing via the shared diskann::graph::glue::SearchPostProcess interface, aligning flat search with the graph search pipeline. It also simplifies flat search ID plumbing by tying DistancesUnordered/SearchStrategy directly to the provider’s DataProvider::InternalId (and making DistancesUnordered require HasId).

Changes:

  • Add post-processing support to FlatIndex::knn_search via SearchPostProcess.
  • Simplify flat-search ID typing by removing SearchStrategy::Id and making DistancesUnordered: HasId, using P::InternalId end-to-end.
  • Extend flat test harness/tests to validate post-processing behavior (including an “even IDs only” post-processor).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
diskann/src/flat/test/provider.rs Updates test visitor/strategy implementations for the new HasId-based ID wiring.
diskann/src/flat/test/harness.rs Adds an oracle/processor abstraction and post-processing test utilities.
diskann/src/flat/test/cases/flat_knn_search.rs Updates baseline flat knn test to use the new harness API (processor-aware).
diskann/src/flat/strategy.rs Makes DistancesUnordered require HasId and ties SearchStrategy visitor IDs to P::InternalId.
diskann/src/flat/mod.rs Updates module docs to reflect the shared post-processing interface.
diskann/src/flat/index.rs Adds the SearchPostProcess hook to FlatIndex::knn_search and updates tests accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread diskann/src/flat/index.rs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread diskann/src/flat/strategy.rs
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.47%. Comparing base (de5ac3c) to head (512427e).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1160      +/-   ##
==========================================
+ Coverage   89.46%   89.47%   +0.01%     
==========================================
  Files         487      487              
  Lines       92106    92155      +49     
==========================================
+ Hits        82401    82455      +54     
+ Misses       9705     9700       -5     
Flag Coverage Δ
miri 89.47% <100.00%> (+0.01%) ⬆️
unittests 89.12% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann/src/flat/index.rs 97.77% <100.00%> (+0.29%) ⬆️
diskann/src/flat/strategy.rs 96.89% <ø> (ø)
diskann/src/flat/test/cases/flat_knn_search.rs 94.38% <100.00%> (+0.26%) ⬆️
diskann/src/flat/test/harness.rs 100.00% <100.00%> (ø)
diskann/src/flat/test/provider.rs 73.14% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread diskann/src/flat/test/harness.rs
@arkrishn94 arkrishn94 merged commit 47c6555 into main Jun 15, 2026
24 checks passed
@arkrishn94 arkrishn94 deleted the u/adkrishnan/flat-post-process branch June 15, 2026 20:14
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.

6 participants