kevy_embedded/
ops_index_admin.rs1use kevy_index::{IndexKind, IndexSpec};
5
6use crate::KevyResult;
7use crate::ops_index::SegmentStats;
8use crate::store::Store;
9
10impl Store {
11 pub fn idx_stats(&self, name: &[u8]) -> KevyResult<SegmentStats> {
14 let mut sum = SegmentStats::default();
15 self.for_each_segment(name, |seg| {
16 let s = seg.stats();
17 sum.entries += s.entries;
18 sum.approx_bytes += s.approx_bytes;
19 sum.coerce_failures += s.coerce_failures;
20 sum.duplicates += s.duplicates;
21 })?;
22 Ok(sum)
23 }
24
25 pub fn idx_list(&self) -> Vec<(Vec<u8>, Vec<u8>, IndexKind)> {
27 let g = self.indexes.catalog.read().unwrap_or_else(std::sync::PoisonError::into_inner);
28 g.1.iter().map(|(s, _)| (s.name().to_vec(), s.prefix().to_vec(), s.kind())).collect()
29 }
30
31 pub fn idx_spec(&self, name: &[u8]) -> Option<IndexSpec> {
33 let g = self.indexes.catalog.read().unwrap_or_else(std::sync::PoisonError::into_inner);
34 g.1.get(name).map(|(s, _)| s.clone())
35 }
36}