Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6b6c63c
first draft
arkrishn94 Apr 28, 2026
9f718a1
remove unnecessary parts
arkrishn94 Apr 28, 2026
55cafc2
Merge remote-tracking branch 'origin/main' into u/adkrishnan/flat-index
arkrishn94 Apr 28, 2026
f0a9dbd
rename file
arkrishn94 Apr 28, 2026
0672f3d
fmt
arkrishn94 Apr 28, 2026
3ac0e1b
split iterator to callback
arkrishn94 Apr 29, 2026
f887f2f
use distance unordered callback
arkrishn94 Apr 29, 2026
dc2281c
rfc update
arkrishn94 Apr 29, 2026
ee48f7d
rustfmt flat module
arkrishn94 Apr 29, 2026
3b2a1e0
Merge remote-tracking branch 'origin/main' into u/adkrishnan/flat-index
arkrishn94 Apr 29, 2026
7fd903e
fix clippy: replace doc-comment divider with regular comment
arkrishn94 Apr 29, 2026
8af5e00
small edits
arkrishn94 Apr 29, 2026
1dd1c72
renames and uplevel query computer
arkrishn94 May 4, 2026
3d24ef7
split buildquerycomputer, haselementref and distancesunordered
arkrishn94 May 5, 2026
0a63759
delete flatpostprocess, cleanup and docs
arkrishn94 May 5, 2026
1f48945
Merge remote-tracking branch 'origin/main' into u/adkrishnan/flat-index
arkrishn94 May 5, 2026
57d86e9
update rfc
arkrishn94 May 6, 2026
715150a
error types
arkrishn94 May 6, 2026
0627cc0
small doc fixes
arkrishn94 May 7, 2026
1d4e90b
iterator docs
arkrishn94 May 7, 2026
b4d9df0
strong pass on testing
arkrishn94 May 8, 2026
f338a83
minor cleanup docs
arkrishn94 May 8, 2026
2928404
Add HasQueryComputer trait
May 12, 2026
3620c6d
Revert "Add HasQueryComputer trait"
May 12, 2026
409d177
minor comments
arkrishn94 May 13, 2026
cf8847f
Merge remote-tracking branch 'origin/main' into u/adkrishnan/flat-index
arkrishn94 May 13, 2026
ffc70db
Merge branch 'u/adkrishnan/flat-index' of https://github.com/microsof…
arkrishn94 May 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions diskann-disk/src/search/provider/disk_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use diskann::{
},
neighbor::Neighbor,
provider::{
Accessor, BuildQueryComputer, DataProvider, DefaultContext, DelegateNeighbor, HasId,
NeighborAccessor, NoopGuard,
Accessor, BuildQueryComputer, DataProvider, DefaultContext, DelegateNeighbor,
DistancesUnordered, HasElementRef, HasId, NeighborAccessor, NoopGuard,
},
utils::{IntoUsize, VectorRepr},
ANNError, ANNResult,
Expand Down Expand Up @@ -428,7 +428,13 @@ where
.to_vec(),
})
}
}

impl<Data, VP> DistancesUnordered<&[Data::VectorDataType]> for DiskAccessor<'_, Data, VP>
where
Data: GraphDataType<VectorIdType = u32>,
VP: VertexProvider<Data>,
{
async fn distances_unordered<Itr, F>(
&mut self,
vec_id_itr: Itr,
Expand Down Expand Up @@ -689,6 +695,15 @@ where
type Id = u32;
}

impl<Data, VP> HasElementRef for DiskAccessor<'_, Data, VP>
where
Data: GraphDataType<VectorIdType = u32>,
VP: VertexProvider<Data>,
{
/// `ElementRef` can have arbitrary lifetimes.
type ElementRef<'a> = &'a [u8];
}

impl<Data, VP> Accessor for DiskAccessor<'_, Data, VP>
where
Data: GraphDataType<VectorIdType = u32>,
Expand All @@ -701,9 +716,6 @@ where
where
Self: 'a;

/// `ElementRef` can have arbitrary lifetimes.
type ElementRef<'a> = &'a [u8];

/// Choose to panic on an out-of-bounds access rather than propagate an error.
type GetError = ANNError;

Expand Down
10 changes: 8 additions & 2 deletions diskann-garnet/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use diskann::{
neighbor::Neighbor,
provider::{
Accessor, BuildDistanceComputer, BuildQueryComputer, DataProvider, DelegateNeighbor,
Delete, ElementStatus, HasId, NeighborAccessor, NeighborAccessorMut, NoopGuard, SetElement,
Delete, DistancesUnordered, ElementStatus, HasElementRef, HasId, NeighborAccessor,
NeighborAccessorMut, NoopGuard, SetElement,
},
utils::VectorRepr,
};
Expand Down Expand Up @@ -519,12 +520,15 @@ impl<T: VectorRepr> ExpandBeam<&[T]> for FullAccessor<'_, T> {
}
}

impl<T: VectorRepr> HasElementRef for FullAccessor<'_, T> {
type ElementRef<'a> = &'a [T];
}

impl<T: VectorRepr> Accessor for FullAccessor<'_, T> {
type Element<'a>
= Vec<T>
where
Self: 'a;
type ElementRef<'a> = &'a [T];
type GetError = GarnetProviderError;

fn get_element(
Expand Down Expand Up @@ -581,6 +585,8 @@ impl<T: VectorRepr> BuildQueryComputer<&[T]> for FullAccessor<'_, T> {
}
}

impl<T: VectorRepr> DistancesUnordered<&[T]> for FullAccessor<'_, T> {}

/// An escape hatch for the blanket implementation of [`workingset::Fill`].
///
/// Without an `&[T]: Into<Escape<T>>`, the blanket implementation for `workingset::Map`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ use std::sync::{Arc, RwLock};
use diskann::{
error::{ErrorExt, IntoANNResult},
graph::glue::{ExpandBeam, SearchExt},
provider::{Accessor, AsNeighbor, BuildQueryComputer, DelegateNeighbor, HasId},
provider::{
Accessor, AsNeighbor, BuildQueryComputer, DelegateNeighbor, DistancesUnordered,
HasElementRef, HasId,
},
ANNError, ANNErrorKind,
};
use diskann_utils::Reborrow;
Expand Down Expand Up @@ -68,6 +71,13 @@ where
type Id = <IA as HasId>::Id;
}

impl<IA> HasElementRef for EncodedDocumentAccessor<IA>
where
IA: Accessor,
{
type ElementRef<'a> = EncodedDocument<IA::ElementRef<'a>, &'a RoaringTreemap>;
}

impl<IA> Accessor for EncodedDocumentAccessor<IA>
where
IA: Accessor,
Expand All @@ -76,7 +86,6 @@ where
= EncodedDocument<IA::Element<'a>, RoaringTreemap>
where
Self: 'a;
type ElementRef<'a> = EncodedDocument<IA::ElementRef<'a>, &'a RoaringTreemap>;
type GetError = ANNError;

async fn get_element(&mut self, id: Self::Id) -> Result<Self::Element<'_>, Self::GetError> {
Expand Down Expand Up @@ -164,7 +173,7 @@ where

impl<'q, IA, Q> BuildQueryComputer<&'q FilteredQuery<Q>> for EncodedDocumentAccessor<IA>
where
IA: BuildQueryComputer<&'q Q>,
IA: BuildQueryComputer<&'q Q> + Accessor,
{
type QueryComputerError = ANNError;
type QueryComputer = InlineBetaComputer<IA::QueryComputer>;
Expand Down Expand Up @@ -195,6 +204,14 @@ where
{
}

impl<IA, Q> DistancesUnordered<Q> for EncodedDocumentAccessor<IA>
where
IA: Accessor,
EncodedDocumentAccessor<IA>: BuildQueryComputer<Q>,
Q: Clone,
{
}

impl<'a, IA> DelegateNeighbor<'a> for EncodedDocumentAccessor<IA>
where
IA: DelegateNeighbor<'a>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub struct FilterResults<IPP> {
impl<'q, Q, IA, IPP> SearchPostProcess<EncodedDocumentAccessor<IA>, &'q FilteredQuery<Q>>
for FilterResults<IPP>
where
IA: BuildQueryComputer<&'q Q>,
IA: BuildQueryComputer<&'q Q> + Accessor,
Q: Send + Sync,
IPP: SearchPostProcess<IA, &'q Q> + Send + Sync,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use diskann::{
neighbor::Neighbor,
provider::{
Accessor, BuildDistanceComputer, BuildQueryComputer, DataProvider, DefaultContext,
DelegateNeighbor, Delete, ElementStatus, HasId, NeighborAccessor, NeighborAccessorMut,
NoopGuard, SetElement,
DelegateNeighbor, Delete, DistancesUnordered, ElementStatus, HasElementRef, HasId,
NeighborAccessor, NeighborAccessorMut, NoopGuard, SetElement,
},
utils::{IntoUsize, VectorRepr},
};
Expand Down Expand Up @@ -974,6 +974,15 @@ where
}
}

impl<T, Q, D> HasElementRef for FullAccessor<'_, T, Q, D>
where
T: VectorRepr,
Q: AsyncFriendly,
D: AsyncFriendly,
{
type ElementRef<'a> = &'a [T];
}

impl<T, Q, D> Accessor for FullAccessor<'_, T, Q, D>
where
T: VectorRepr,
Expand All @@ -986,9 +995,6 @@ where
where
Self: 'a;

/// The reference version of `Element` is the same as `Element`.
type ElementRef<'a> = &'a [T];

// Choose to panic on an out-of-bounds access rather than propagate an error.
//
type GetError = Panics;
Expand Down Expand Up @@ -1058,6 +1064,14 @@ where
{
}

impl<T, Q, D> DistancesUnordered<&[T]> for FullAccessor<'_, T, Q, D>
where
T: VectorRepr,
Q: AsyncFriendly,
D: AsyncFriendly,
{
}

impl<'a, T, Q, D> AsDeletionCheck for FullAccessor<'a, T, Q, D>
where
T: VectorRepr,
Expand Down Expand Up @@ -1134,6 +1148,14 @@ where
}
}

impl<T, D> HasElementRef for QuantAccessor<'_, T, D>
where
T: VectorRepr,
D: AsyncFriendly,
{
type ElementRef<'a> = &'a [u8];
}

impl<T, D> Accessor for QuantAccessor<'_, T, D>
where
T: VectorRepr,
Expand All @@ -1145,9 +1167,6 @@ where
where
Self: 'a;

/// The reference version of `Element` is simply `Element`.
type ElementRef<'a> = &'a [u8];

// ANNError on access failures in bf-tree
//
type GetError = ANNError;
Expand Down Expand Up @@ -1220,6 +1239,13 @@ where
{
}

impl<T, D> DistancesUnordered<&[T]> for QuantAccessor<'_, T, D>
where
T: VectorRepr,
D: AsyncFriendly,
{
}

impl<'a, T, D> AsDeletionCheck for QuantAccessor<'a, T, D>
where
T: VectorRepr,
Expand Down Expand Up @@ -1282,6 +1308,14 @@ where
}
}

impl<T, D> HasElementRef for HybridAccessor<'_, T, D>
where
T: VectorRepr,
D: AsyncFriendly,
{
type ElementRef<'a> = distances::pq::Hybrid<&'a [T], &'a [u8]>;
}

impl<T, D> Accessor for HybridAccessor<'_, T, D>
where
T: VectorRepr,
Expand All @@ -1296,9 +1330,6 @@ where
where
Self: 'a;

/// The generalized reference form of `Element`.
type ElementRef<'a> = distances::pq::Hybrid<&'a [T], &'a [u8]>;

// Choose to panic on an out-of-bounds access rather than propagate an error.
type GetError = Panics;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use diskann::{
neighbor::Neighbor,
provider::{
Accessor, BuildDistanceComputer, BuildQueryComputer, DefaultContext, DelegateNeighbor,
ExecutionContext, HasId,
DistancesUnordered, ExecutionContext, HasElementRef, HasId,
},
utils::{IntoUsize, VectorRepr},
};
Expand Down Expand Up @@ -185,6 +185,16 @@ where
}
}

impl<T, Q, D, Ctx> HasElementRef for FullAccessor<'_, T, Q, D, Ctx>
where
T: VectorRepr,
Q: AsyncFriendly,
D: AsyncFriendly,
Ctx: ExecutionContext,
{
type ElementRef<'a> = &'a [T];
}

impl<T, Q, D, Ctx> Accessor for FullAccessor<'_, T, Q, D, Ctx>
where
T: VectorRepr,
Expand All @@ -199,9 +209,6 @@ where
where
Self: 'a;

/// `ElementRef` has an arbitrarily short lifetime.
type ElementRef<'a> = &'a [T];

/// Choose to panic on an out-of-bounds access rather than propagate an error.
type GetError = Panics;

Expand Down Expand Up @@ -316,6 +323,15 @@ where
{
}

impl<T, Q, D, Ctx> DistancesUnordered<&[T]> for FullAccessor<'_, T, Q, D, Ctx>
where
T: VectorRepr,
Q: AsyncFriendly,
D: AsyncFriendly,
Ctx: ExecutionContext,
{
}

//-------------------//
// In-mem Extensions //
//-------------------//
Expand Down Expand Up @@ -353,7 +369,7 @@ pub struct Rerank;
impl<'a, A, T> glue::SearchPostProcess<A, &'a [T]> for Rerank
where
T: VectorRepr,
A: BuildQueryComputer<&'a [T], Id = u32> + GetFullPrecision<Repr = T> + AsDeletionCheck,
A: BuildQueryComputer<&'a [T]> + HasId<Id = u32> + GetFullPrecision<Repr = T> + AsDeletionCheck,
{
type Error = Panics;

Expand Down
Loading
Loading