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

Method upsert_kg_node

atomic-core/src/pristine/txn/write/triples.rs:201–226  ·  view source on GitHub ↗
(&mut self, node: &KgNode)

Source from the content-addressed store, hash-verified

199
200impl<'a> KgMutTxnT for WriteTxn<'a> {
201 fn upsert_kg_node(&mut self, node: &KgNode) -> PristineResult<()> {
202 let mut table = self.txn.open_table(KG_NODES)?;
203 let bytes = serde_json::to_vec(node).map_err(|e| PristineError::Serialization {
204 message: e.to_string(),
205 })?;
206 table.insert(node.id.as_str(), bytes.as_slice())?;
207 drop(table);
208
209 // Update FTS index: add new tokens (duplicates are harmless
210 // in a multimap — the node_id appears multiple times but deduplication
211 // happens at query time via HashMap).
212 let mut fts_table = self.txn.open_multimap_table(KG_FTS)?;
213 let mut text = String::with_capacity(node.id.len() + node.label.len() + 64);
214 text.push_str(&node.id);
215 text.push(' ');
216 text.push_str(&node.label);
217 if let Some(ref summary) = node.summary {
218 text.push(' ');
219 text.push_str(summary);
220 }
221 for token in tokenize_for_fts(&text) {
222 fts_table.insert(token.as_str(), node.id.as_str())?;
223 }
224
225 Ok(())
226 }
227
228 fn upsert_kg_edge(&mut self, edge: &KgEdge) -> PristineResult<()> {
229 let edge_key = encode_edge_key(&edge.from_id, &edge.to_id, &edge.kind);

Callers 13

test_kg_edge_crudFunction · 0.80
test_kg_neighborsFunction · 0.80
test_kg_fts_searchFunction · 0.80
test_kg_persistenceFunction · 0.80
kg_enrich_viewsMethod · 0.80
kg_enrich_modulesMethod · 0.80
kg_enrich_filesMethod · 0.80
kg_enrich_changesMethod · 0.80
kg_enrich_changeMethod · 0.80
kg_enrich_entitiesMethod · 0.80

Calls 6

tokenize_for_ftsFunction · 0.85
insertMethod · 0.45
as_strMethod · 0.45
as_sliceMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by 6

test_kg_edge_crudFunction · 0.64
test_kg_neighborsFunction · 0.64
test_kg_fts_searchFunction · 0.64
test_kg_persistenceFunction · 0.64