(&self, query: &str)
| 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) { |
nothing calls this directly
no test coverage detected