Skip to content

Commit

Permalink
chore: propagate error for table index stats (lancedb#1426)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyxu authored Jul 4, 2024
1 parent 08d25c5 commit ef30f87
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions rust/lancedb/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,22 +1277,25 @@ impl NativeTable {

/// Get statistics about an index.
/// Returns an error if the index does not exist.
pub async fn index_stats<S: AsRef<str>>(
pub async fn index_stats(
&self,
index_name: S,
index_name: impl AsRef<str>,
) -> Result<Option<IndexStatistics>> {
self.dataset
let stats = match self
.dataset
.get()
.await?
.index_statistics(index_name.as_ref())
.await
.ok()
.map(|stats| {
serde_json::from_str(&stats).map_err(|e| Error::InvalidInput {
message: format!("error deserializing index statistics: {}", e),
})
})
.transpose()
{
Ok(stats) => stats,
Err(lance::error::Error::IndexNotFound { .. }) => return Ok(None),
Err(e) => return Err(Error::from(e)),
};

serde_json::from_str(&stats).map_err(|e| Error::InvalidInput {
message: format!("error deserializing index statistics: {}", e),
})
}

pub async fn load_indices(&self) -> Result<Vec<VectorIndex>> {
Expand Down

0 comments on commit ef30f87

Please sign in to comment.