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

Method get_embedding

atomic-core/src/pristine/txn/write/embeddings.rs:40–63  ·  view source on GitHub ↗
(&self, path: &str, chunk_idx: u32)

Source from the content-addressed store, hash-verified

38
39impl<'a> EmbeddingsTxnT for WriteTxn<'a> {
40 fn get_embedding(&self, path: &str, chunk_idx: u32) -> PristineResult<Option<EmbeddingRecord>> {
41 let table = match self.txn.open_table(EMBEDDINGS) {
42 Ok(table) => table,
43 Err(redb::TableError::TableDoesNotExist(_)) => return Ok(None),
44 Err(e) => return Err(PristineError::from(e)),
45 };
46
47 let key = encode_embedding_key(path, chunk_idx);
48 let result = match table.get(key.as_str())? {
49 Some(guard) => {
50 let bytes = guard.value();
51 let record: EmbeddingRecord =
52 postcard::from_bytes(bytes).map_err(|e| PristineError::Serialization {
53 message: format!(
54 "failed to deserialize EmbeddingRecord at '{}': {}",
55 key, e
56 ),
57 })?;
58 Ok(Some(record))
59 }
60 None => Ok(None),
61 };
62 result
63 }
64
65 fn list_embeddings(&self, path: &str) -> PristineResult<Vec<(u32, EmbeddingRecord)>> {
66 let table = match self.txn.open_table(EMBEDDINGS) {

Callers 3

test_embedding_crudFunction · 0.45
test_embedding_overwriteFunction · 0.45

Calls 3

encode_embedding_keyFunction · 0.85
getMethod · 0.65
as_strMethod · 0.45

Tested by 3

test_embedding_crudFunction · 0.36
test_embedding_overwriteFunction · 0.36