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

Method load_graph_sections

atomic-repository/src/redb_change_store/queries.rs:93–127  ·  view source on GitHub ↗

Load all graph sections for a change. Reads from CHANGE_GRAPH only. This is the "thin apply" path — the minimum data needed to apply a change to the repository DAG. # Returns A vector of decompressed graph section payloads, ordered by file index.

(&self, hash: &[u8; 32])

Source from the content-addressed store, hash-verified

91 ///
92 /// A vector of decompressed graph section payloads, ordered by file index.
93 pub fn load_graph_sections(&self, hash: &[u8; 32]) -> RedbStoreResult<Vec<StoredSection>> {
94 let txn = self.db().begin_read()?;
95 let (meta, _, span) = self.load_meta_with_header_in_txn(&txn, hash)?;
96 if span.is_some() {
97 return Err(RedbStoreError::UnsupportedSpanSelectiveRead);
98 }
99 let table = txn.open_table(tables::CHANGE_GRAPH)?;
100
101 let mut sections = Vec::with_capacity(meta.graph_section_count as usize);
102
103 for idx in 0..meta.graph_section_count {
104 let key = tables::encode_change_file_key(hash, idx);
105 if let Some(value) = table.get(&key)? {
106 let compressed = value.value();
107 let decompressed = zstd::decode_all(compressed).map_err(|e| {
108 RedbStoreError::Corrupt(format!(
109 "graph section {} decompression failed: {}",
110 idx, e
111 ))
112 })?;
113
114 // Extract path from the payload (it's a postcard-encoded GraphSectionPayload)
115 let path = extract_path_from_payload(&decompressed);
116
117 sections.push(StoredSection {
118 section_type: SectionType::Graph,
119 payload: decompressed,
120 path,
121 file_index: idx,
122 });
123 }
124 }
125
126 Ok(sections)
127 }
128
129 /// Load all semantic sections for a change.
130 ///

Callers 3

regenerate_changeFunction · 0.80
test_load_graph_sectionsFunction · 0.80

Calls 8

encode_change_file_keyFunction · 0.85
begin_readMethod · 0.80
dbMethod · 0.80
valueMethod · 0.80
getMethod · 0.65
pushMethod · 0.45

Tested by 2

test_load_graph_sectionsFunction · 0.64