MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / kg_node_ids_by_source

Method kg_node_ids_by_source

atomic-core/src/pristine/txn/write/triples.rs:309–326  ·  view source on GitHub ↗
(&self, sources: &[&str])

Source from the content-addressed store, hash-verified

307 }
308
309 fn kg_node_ids_by_source(&self, sources: &[&str]) -> PristineResult<Vec<String>> {
310 self.require_current_kg()?;
311 let table = match self.txn.open_table(KG_NODES) {
312 Ok(t) => t,
313 Err(redb::TableError::TableDoesNotExist(_)) => return Ok(Vec::new()),
314 Err(e) => return Err(PristineError::from(e)),
315 };
316 let mut ids = Vec::new();
317 for entry in table.iter()? {
318 let (key, value) = entry?;
319 if let Ok(node) = serde_json::from_slice::<KgNode>(value.value()) {
320 if sources.contains(&node.source.as_str()) {
321 ids.push(key.value().to_string());
322 }
323 }
324 }
325 Ok(ids)
326 }
327
328 fn count_kg_edges(&self) -> PristineResult<usize> {
329 self.require_current_kg()?;

Callers

nothing calls this directly

Calls 6

require_current_kgMethod · 0.80
valueMethod · 0.80
iterMethod · 0.45
containsMethod · 0.45
as_strMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected