//! The serialisation is performed on-demand when each node is emitted. Using this
//! scheme, we do not need to keep the current graph in memory.
//!
-//! The deserisalisation is performed manually, in order to convert from the stored
+//! The deserialization is performed manually, in order to convert from the stored
//! sequence of NodeInfos to the different arrays in SerializedDepGraph. Since the
//! node and edge count are stored at the end of the file, all the arrays can be
//! pre-allocated with the right length.
let mut edge_list_data = Vec::with_capacity(edge_count);
for _index in 0..node_count {
- d.read_struct(|d| {
- let dep_node: DepNode<K> = d.read_struct_field("node", Decodable::decode);
- let _i: SerializedDepNodeIndex = nodes.push(dep_node);
- debug_assert_eq!(_i.index(), _index);
-
- let fingerprint: Fingerprint =
- d.read_struct_field("fingerprint", Decodable::decode);
- let _i: SerializedDepNodeIndex = fingerprints.push(fingerprint);
- debug_assert_eq!(_i.index(), _index);
-
- d.read_struct_field("edges", |d| {
- d.read_seq(|d, len| {
- let start = edge_list_data.len().try_into().unwrap();
- for _ in 0..len {
- let edge = d.read_seq_elt(Decodable::decode);
- edge_list_data.push(edge);
- }
- let end = edge_list_data.len().try_into().unwrap();
- let _i: SerializedDepNodeIndex = edge_list_indices.push((start, end));
- debug_assert_eq!(_i.index(), _index);
- })
- })
- });
+ let dep_node: DepNode<K> = Decodable::decode(d);
+ let _i: SerializedDepNodeIndex = nodes.push(dep_node);
+ debug_assert_eq!(_i.index(), _index);
+
+ let fingerprint: Fingerprint = Decodable::decode(d);
+ let _i: SerializedDepNodeIndex = fingerprints.push(fingerprint);
+ debug_assert_eq!(_i.index(), _index);
+
+ // Deserialize edges -- sequence of DepNodeIndex
+ let len = d.read_usize();
+ let start = edge_list_data.len().try_into().unwrap();
+ for _ in 0..len {
+ let edge = Decodable::decode(d);
+ edge_list_data.push(edge);
+ }
+ let end = edge_list_data.len().try_into().unwrap();
+ let _i: SerializedDepNodeIndex = edge_list_indices.push((start, end));
+ debug_assert_eq!(_i.index(), _index);
}
let index: FxHashMap<_, _> =
}
}
- #[instrument(level = "debug", skip(self, record_graph))]
fn encode_node(
&mut self,
node: &NodeInfo<K>,
stat.edge_counter += edge_count as u64;
}
- debug!(?index, ?node);
let encoder = &mut self.encoder;
if self.result.is_ok() {
self.result = node.encode(encoder);