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:152–179  ·  view source on GitHub ↗
(&self, query: &str)

Source from the content-addressed store, hash-verified

150 }
151
152 fn kg_fts_match_ids(&self, query: &str) -> PristineResult<Vec<(String, usize)>> {
153 let fts_table = match self.txn.open_multimap_table(KG_FTS) {
154 Ok(t) => t,
155 Err(redb::TableError::TableDoesNotExist(_)) => return Ok(Vec::new()),
156 Err(e) => return Err(PristineError::from(e)),
157 };
158
159 let tokens = tokenize_for_fts(query);
160 if tokens.is_empty() {
161 return Ok(Vec::new());
162 }
163
164 let mut hit_counts: std::collections::HashMap<String, usize> =
165 std::collections::HashMap::new();
166 for token in &tokens {
167 let iter = match fts_table.get(token.as_str()) {
168 Ok(iter) => iter,
169 Err(_) => continue,
170 };
171 for result in iter {
172 let node_id_guard = result?;
173 let node_id = node_id_guard.value().to_string();
174 *hit_counts.entry(node_id).or_insert(0) += 1;
175 }
176 }
177
178 Ok(hit_counts.into_iter().collect())
179 }
180
181 fn count_kg_nodes(&self) -> PristineResult<usize> {
182 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