From e3bc17e503727fce74fb10a90db53a23e965564f Mon Sep 17 00:00:00 2001 From: Mark Hildebrand Date: Thu, 29 Oct 2026 12:26:34 -0700 Subject: [PATCH] Remove `DataProvider::to_external_id`. --- diskann-bftree/src/provider.rs | 11 ---------- .../src/search/provider/disk_provider.rs | 17 --------------- diskann-garnet/src/provider.rs | 21 ++++++++++--------- diskann-inmem/src/provider.rs | 17 --------------- .../document_provider.rs | 8 ------- .../graph/provider/async_/inmem/provider.rs | 10 --------- diskann/src/flat/test/provider.rs | 8 ------- diskann/src/graph/test/provider.rs | 20 ------------------ diskann/src/provider.rs | 7 ------- 9 files changed, 11 insertions(+), 108 deletions(-) diff --git a/diskann-bftree/src/provider.rs b/diskann-bftree/src/provider.rs index 8078770430..f3c64353f9 100644 --- a/diskann-bftree/src/provider.rs +++ b/diskann-bftree/src/provider.rs @@ -621,16 +621,6 @@ where ) -> Result { Ok(*gid) } - - // Translate an internal id its corresponding external id. - // - fn to_external_id( - &self, - _context: &DefaultContext, - id: Self::InternalId, - ) -> Result { - Ok(id) - } } impl HasId for BfTreeProvider @@ -2864,7 +2854,6 @@ mod tests { } for i in iter.clone() { - assert_eq!(provider.to_external_id(ctx, i).unwrap(), i); assert_eq!(provider.to_internal_id(ctx, &i).unwrap(), i); assert_eq!( provider.status_by_internal_id(ctx, i).await.unwrap(), diff --git a/diskann-disk/src/search/provider/disk_provider.rs b/diskann-disk/src/search/provider/disk_provider.rs index 85ae57a6a9..e86efaa661 100644 --- a/diskann-disk/src/search/provider/disk_provider.rs +++ b/diskann-disk/src/search/provider/disk_provider.rs @@ -117,15 +117,6 @@ where ) -> Result { Ok(*gid) } - - /// Translate an internal id its corresponding external id. - fn to_external_id( - &self, - _context: &DefaultContext, - id: Self::InternalId, - ) -> Result { - Ok(id) - } } impl LoadWith for DiskProvider @@ -2098,14 +2089,6 @@ mod disk_provider_tests { create_disk_index_searcher::(params, &storage_provider); // minor validation tests to improve code coverage - assert_eq!( - search_engine - .index - .data_provider - .to_external_id(ctx, 0) - .unwrap(), - 0 - ); assert_eq!( search_engine .index diff --git a/diskann-garnet/src/provider.rs b/diskann-garnet/src/provider.rs index 30f985af9d..2f244293df 100644 --- a/diskann-garnet/src/provider.rs +++ b/diskann-garnet/src/provider.rs @@ -1735,6 +1735,17 @@ impl GarnetProvider { } } + /// Convert the internal `id` into an external one. + fn to_external_id(&self, context: &Context, id: u32) -> Result { + match self + .callbacks + .read_varsize_iid(&context.term(Term::ExtMap), id) + { + Some(eid) => Ok(eid.into()), + None => Err(GarnetProviderError::Garnet(GarnetError::Read)), + } + } + /// Provides an estimate of quantizer state size. /// This is allowed to be wrong, but should ideally be an overestimate. #[cfg(test)] @@ -1765,16 +1776,6 @@ impl DataProvider for GarnetProvider { } Ok(id) } - - fn to_external_id(&self, context: &Context, id: u32) -> Result { - match self - .callbacks - .read_varsize_iid(&context.term(Term::ExtMap), id) - { - Some(eid) => Ok(eid.into()), - None => Err(GarnetProviderError::Garnet(GarnetError::Read)), - } - } } impl SetElement<(&[T], &[u8])> for GarnetProvider { diff --git a/diskann-inmem/src/provider.rs b/diskann-inmem/src/provider.rs index 09e6150e01..95760abe16 100644 --- a/diskann-inmem/src/provider.rs +++ b/diskann-inmem/src/provider.rs @@ -148,18 +148,6 @@ where None => Err(ANNError::message("no mapping")), } } - - /// Translate an internal id to its corresponding external id. - fn to_external_id( - &self, - _context: &Self::Context, - id: Self::InternalId, - ) -> Result { - match self.mapping.to_external(id) { - Some(gid) => Ok(gid), - None => Err(ANNError::message("no mapping")), - } - } } // TODO: The element-status checks here are profoundly approximate because we try to avoid @@ -888,10 +876,6 @@ mod tests { let i = (10 * i + 1) as u64; let internal = index.provider().to_internal_id(&Context, &i).unwrap(); assert_ne!(internal as u64, i); - assert_eq!( - index.provider().to_external_id(&Context, internal).unwrap(), - i - ); assert!( !index @@ -913,7 +897,6 @@ mod tests { // Assert that out-of-bounds translations returns errors. assert!(index.provider().to_internal_id(&Context, &0).is_err()); - assert!(index.provider().to_external_id(&Context, 26).is_err()); // Searches should return something reasonable. let knn = Knn::new(10, None).unwrap(); diff --git a/diskann-label-filter/src/encoded_attribute_provider/document_provider.rs b/diskann-label-filter/src/encoded_attribute_provider/document_provider.rs index e60b5bc15b..fd33c73c33 100644 --- a/diskann-label-filter/src/encoded_attribute_provider/document_provider.rs +++ b/diskann-label-filter/src/encoded_attribute_provider/document_provider.rs @@ -64,14 +64,6 @@ where ) -> Result { self.inner_provider.to_internal_id(context, gid) } - - fn to_external_id( - &self, - context: &Self::Context, - id: Self::InternalId, - ) -> Result { - self.inner_provider.to_external_id(context, id) - } } impl<'a, VT, DP, AS> SetElement> for DocumentProvider diff --git a/diskann-providers/src/model/graph/provider/async_/inmem/provider.rs b/diskann-providers/src/model/graph/provider/async_/inmem/provider.rs index 539a1dad25..05be367f03 100644 --- a/diskann-providers/src/model/graph/provider/async_/inmem/provider.rs +++ b/diskann-providers/src/model/graph/provider/async_/inmem/provider.rs @@ -582,15 +582,6 @@ where ) -> Result { Ok(*gid) } - - /// Translate an internal id its corresponding external id. - fn to_external_id( - &self, - _context: &Self::Context, - id: Self::InternalId, - ) -> Result { - Ok(id) - } } /// Support deletes when we have a valid delete provider. @@ -760,7 +751,6 @@ mod tests { let iter = provider.iter(); for i in iter.clone() { - assert_eq!(provider.to_external_id(ctx, i).unwrap(), i); assert_eq!(provider.to_internal_id(ctx, &i).unwrap(), i); assert_eq!( provider.status_by_internal_id(ctx, i).await.unwrap(), diff --git a/diskann/src/flat/test/provider.rs b/diskann/src/flat/test/provider.rs index 5212cbf5d2..03373385a6 100644 --- a/diskann/src/flat/test/provider.rs +++ b/diskann/src/flat/test/provider.rs @@ -256,14 +256,6 @@ impl provider::DataProvider for Provider { Err(InvalidId(*gid)) } } - - fn to_external_id(&self, _ctx: &Context, id: u32) -> Result { - if (id as usize) < self.items.nrows() { - Ok(id) - } else { - Err(InvalidId(id)) - } - } } ///////////// diff --git a/diskann/src/graph/test/provider.rs b/diskann/src/graph/test/provider.rs index d6613bcb7d..366774afd9 100644 --- a/diskann/src/graph/test/provider.rs +++ b/diskann/src/graph/test/provider.rs @@ -681,15 +681,6 @@ impl provider::DataProvider for Provider { Err(InvalidId::External(*gid)) } } - - fn to_external_id(&self, _context: &Context, id: u32) -> Result { - let valid = self.terms.contains_key(&id); - if valid { - Ok(id) - } else { - Err(InvalidId::Internal(id)) - } - } } impl provider::Delete for Provider { @@ -1744,9 +1735,6 @@ mod tests { for i in 0u32..3u32 { let internal = provider.to_internal_id(&context, &i).unwrap(); assert_eq!(internal, i); - - let external = provider.to_external_id(&context, i).unwrap(); - assert_eq!(external, i); } let err = provider.to_internal_id(&context, &5).unwrap_err(); @@ -1756,14 +1744,6 @@ mod tests { "got {}", message ); - - let err = provider.to_external_id(&context, 5).unwrap_err(); - let message = err.to_string(); - assert_eq!( - message, "internal id 5 is not initialized", - "got {}", - message - ); } #[test] diff --git a/diskann/src/provider.rs b/diskann/src/provider.rs index bb2e9741ae..4b660ace2c 100644 --- a/diskann/src/provider.rs +++ b/diskann/src/provider.rs @@ -142,13 +142,6 @@ pub trait DataProvider: Sized + Send + Sync + 'static { context: &Self::Context, gid: &Self::ExternalId, ) -> Result; - - /// Translate an internal id to its corresponding external id. - fn to_external_id( - &self, - context: &Self::Context, - id: Self::InternalId, - ) -> Result; } ////////////