Add document database stats

This commit is contained in:
ManyTheFish 2025-02-10 14:10:13 +01:00 committed by Kerollmops
parent 91a8a97045
commit 9a6c1730aa
No known key found for this signature in database
GPG key ID: F250A4C4E3AE5F5F
9 changed files with 145 additions and 6 deletions

View file

@ -11,6 +11,7 @@ use rstar::RTree;
use serde::{Deserialize, Serialize};
use crate::constants::{self, RESERVED_VECTORS_FIELD_NAME};
use crate::database_stats::DatabaseStats;
use crate::documents::PrimaryKey;
use crate::error::{InternalError, UserError};
use crate::fields_ids_map::FieldsIdsMap;
@ -403,6 +404,11 @@ impl Index {
Ok(count.unwrap_or_default())
}
/// Returns the stats of the database.
pub fn documents_database_stats(&self, rtxn: &RoTxn<'_>) -> Result<DatabaseStats> {
Ok(DatabaseStats::new(self.documents.remap_types::<Bytes, Bytes>(), rtxn)?)
}
/* primary key */
/// Writes the documents primary key, this is the field name that is used to store the id.