| 10 | use crate::engine::sparse::fts_redb::tables::STATS; |
| 11 | |
| 12 | pub(super) fn read( |
| 13 | backend: &RedbFtsBackend, |
| 14 | tid: u64, |
| 15 | collection: &str, |
| 16 | ) -> crate::Result<(u32, u64)> { |
| 17 | let read_txn = backend |
| 18 | .db |
| 19 | .begin_read() |
| 20 | .map_err(|e| redb_err("read txn", e))?; |
| 21 | let table = read_txn |
| 22 | .open_table(STATS) |
| 23 | .map_err(|e| redb_err("open stats", e))?; |
| 24 | match table.get((tid, collection)) { |
| 25 | Ok(Some(val)) => { |
| 26 | let stats: (u32, u64) = |
| 27 | zerompk::from_msgpack(val.value()).map_err(|e| redb_err("deserialize stats", e))?; |
| 28 | Ok(stats) |
| 29 | } |
| 30 | Ok(None) => Ok((0, 0)), |
| 31 | Err(e) => Err(redb_err("get stats", e)), |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | pub(super) fn increment( |
| 36 | backend: &RedbFtsBackend, |