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

Method get

nodedb/src/engine/sparse/stats.rs:179–212  ·  view source on GitHub ↗

Load statistics for a column.

(
        &self,
        tenant_id: u64,
        collection: &str,
        field: &str,
    )

Source from the content-addressed store, hash-verified

177
178 /// Load statistics for a column.
179 pub fn get(
180 &self,
181 tenant_id: u64,
182 collection: &str,
183 field: &str,
184 ) -> crate::Result<Option<ColumnStats>> {
185 let key = format!("{tenant_id}:{collection}:{field}");
186 let read_txn = self.db.begin_read().map_err(|e| crate::Error::Storage {
187 engine: "stats".into(),
188 detail: format!("read txn: {e}"),
189 })?;
190 let table = read_txn
191 .open_table(COLUMN_STATS)
192 .map_err(|e| crate::Error::Storage {
193 engine: "stats".into(),
194 detail: format!("open table: {e}"),
195 })?;
196 match table.get(key.as_str()) {
197 Ok(Some(guard)) => {
198 let bytes = guard.value();
199 let stats: ColumnStats =
200 zerompk::from_msgpack(bytes).map_err(|e| crate::Error::Storage {
201 engine: "stats".into(),
202 detail: format!("deserialize: {e}"),
203 })?;
204 Ok(Some(stats))
205 }
206 Ok(None) => Ok(None),
207 Err(e) => Err(crate::Error::Storage {
208 engine: "stats".into(),
209 detail: format!("get: {e}"),
210 }),
211 }
212 }
213
214 /// Persist updated statistics for a column.
215 pub fn put(

Callers 3

observe_documentMethod · 0.45
stats_store_roundtripFunction · 0.45

Calls 1

as_strMethod · 0.45

Tested by 1

stats_store_roundtripFunction · 0.36