MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / read

Function read

nodedb/src/engine/sparse/fts_redb/backend/stats.rs:12–33  ·  view source on GitHub ↗
(
    backend: &RedbFtsBackend,
    tid: u64,
    collection: &str,
)

Source from the content-addressed store, hash-verified

10use crate::engine::sparse::fts_redb::tables::STATS;
11
12pub(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
35pub(super) fn increment(
36 backend: &RedbFtsBackend,

Callers

nothing calls this directly

Calls 2

redb_errFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected