Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 0 additions & 11 deletions diskann-bftree/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,6 @@ where
) -> Result<Self::InternalId, Self::Error> {
Ok(*gid)
}

// Translate an internal id its corresponding external id.
//
fn to_external_id(
&self,
_context: &DefaultContext,
id: Self::InternalId,
) -> Result<Self::ExternalId, Self::Error> {
Ok(id)
}
}

impl<T, Q, I> HasId for BfTreeProvider<T, Q, I>
Expand Down Expand Up @@ -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(),
Expand Down
17 changes: 0 additions & 17 deletions diskann-disk/src/search/provider/disk_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ where
) -> Result<Self::InternalId, Self::Error> {
Ok(*gid)
}

/// Translate an internal id its corresponding external id.
fn to_external_id(
&self,
_context: &DefaultContext,
id: Self::InternalId,
) -> Result<Self::ExternalId, Self::Error> {
Ok(id)
}
}

impl<Data> LoadWith<AsyncDiskLoadContext> for DiskProvider<Data>
Expand Down Expand Up @@ -2098,14 +2089,6 @@ mod disk_provider_tests {
create_disk_index_searcher::<GraphDataF32VectorU32Data>(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
Expand Down
21 changes: 11 additions & 10 deletions diskann-garnet/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,17 @@ impl<T: VectorRepr> GarnetProvider<T> {
}
}

/// Convert the internal `id` into an external one.
fn to_external_id(&self, context: &Context, id: u32) -> Result<GarnetId, GarnetProviderError> {
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)]
Expand Down Expand Up @@ -1765,16 +1776,6 @@ impl<T: VectorRepr> DataProvider for GarnetProvider<T> {
}
Ok(id)
}

fn to_external_id(&self, context: &Context, id: u32) -> Result<Self::ExternalId, Self::Error> {
match self
.callbacks
.read_varsize_iid(&context.term(Term::ExtMap), id)
{
Some(eid) => Ok(eid.into()),
None => Err(GarnetProviderError::Garnet(GarnetError::Read)),
}
}
}

impl<T: VectorRepr> SetElement<(&[T], &[u8])> for GarnetProvider<T> {
Expand Down
17 changes: 0 additions & 17 deletions diskann-inmem/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::ExternalId, Self::Error> {
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
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ where
) -> Result<Self::InternalId, Self::Error> {
self.inner_provider.to_internal_id(context, gid)
}

fn to_external_id(
&self,
context: &Self::Context,
id: Self::InternalId,
) -> Result<Self::ExternalId, Self::Error> {
self.inner_provider.to_external_id(context, id)
}
}

impl<'a, VT, DP, AS> SetElement<Document<'a, VT>> for DocumentProvider<DP, AS>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,15 +582,6 @@ where
) -> Result<Self::InternalId, Self::Error> {
Ok(*gid)
}

/// Translate an internal id its corresponding external id.
fn to_external_id(
&self,
_context: &Self::Context,
id: Self::InternalId,
) -> Result<Self::ExternalId, Self::Error> {
Ok(id)
}
}

/// Support deletes when we have a valid delete provider.
Expand Down Expand Up @@ -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(),
Expand Down
8 changes: 0 additions & 8 deletions diskann/src/flat/test/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,6 @@ impl provider::DataProvider for Provider {
Err(InvalidId(*gid))
}
}

fn to_external_id(&self, _ctx: &Context, id: u32) -> Result<u32, InvalidId> {
if (id as usize) < self.items.nrows() {
Ok(id)
} else {
Err(InvalidId(id))
}
}
}

/////////////
Expand Down
20 changes: 0 additions & 20 deletions diskann/src/graph/test/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,15 +681,6 @@ impl provider::DataProvider for Provider {
Err(InvalidId::External(*gid))
}
}

fn to_external_id(&self, _context: &Context, id: u32) -> Result<u32, InvalidId> {
let valid = self.terms.contains_key(&id);
if valid {
Ok(id)
} else {
Err(InvalidId::Internal(id))
}
}
}

impl provider::Delete for Provider {
Expand Down Expand Up @@ -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();
Expand All @@ -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]
Expand Down
7 changes: 0 additions & 7 deletions diskann/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@ pub trait DataProvider: Sized + Send + Sync + 'static {
context: &Self::Context,
gid: &Self::ExternalId,
) -> Result<Self::InternalId, Self::Error>;

/// Translate an internal id to its corresponding external id.
fn to_external_id(
&self,
context: &Self::Context,
id: Self::InternalId,
) -> Result<Self::ExternalId, Self::Error>;
}

////////////
Expand Down
Loading