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

Method kg_fts_match_ids

atomic-core/src/pristine/txn/write/triples.rs:296–323  ·  view source on GitHub ↗
(&self, query: &str)

Source from the content-addressed store, hash-verified

294 }
295
296 fn kg_fts_match_ids(&self, query: &str) -> PristineResult<Vec<(String, usize)>> {
297 let fts_table = match self.txn.open_multimap_table(KG_FTS) {
298 Ok(t) => t,
299 Err(redb::TableError::TableDoesNotExist(_)) => return Ok(Vec::new()),
300 Err(e) => return Err(PristineError::from(e)),
301 };
302
303 let tokens = tokenize_for_fts(query);
304 if tokens.is_empty() {
305 return Ok(Vec::new());
306 }
307
308 let mut hit_counts: std::collections::HashMap<String, usize> =
309 std::collections::HashMap::new();
310 for token in &tokens {
311 let iter = match fts_table.get(token.as_str()) {
312 Ok(iter) => iter,
313 Err(_) => continue,
314 };
315 for result in iter {
316 let node_id_guard = result?;
317 let node_id = node_id_guard.value().to_string();
318 *hit_counts.entry(node_id).or_insert(0) += 1;
319 }
320 }
321
322 Ok(hit_counts.into_iter().collect())
323 }
324
325 fn count_kg_nodes(&self) -> PristineResult<usize> {
326 let table = match self.txn.open_table(KG_NODES) {

Callers

nothing calls this directly

Calls 5

tokenize_for_ftsFunction · 0.85
getMethod · 0.65
is_emptyMethod · 0.45
as_strMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected