MCPcopy Create free account
hub / github.com/cosdata/cosdata / serialize_processing_stats

Function serialize_processing_stats

src/models/serializer/transaction_status.rs:120–156  ·  view source on GitHub ↗

size: [17, 41]

(stats: &ProcessingStats, buf: &mut Vec<u8>)

Source from the content-addressed store, hash-verified

118
119// size: [17, 41]
120pub fn serialize_processing_stats(stats: &ProcessingStats, buf: &mut Vec<u8>) {
121 buf.extend_from_slice(&stats.records_upserted.to_le_bytes());
122 buf.extend_from_slice(&stats.records_deleted.to_le_bytes());
123 buf.extend_from_slice(&stats.total_operations.to_le_bytes());
124 buf.extend_from_slice(&stats.percentage_complete.to_le_bytes());
125
126 let mut flags_byte = 0;
127 let flags_idx = buf.len();
128 buf.push(flags_byte);
129
130 if let Some(processing_time_seconds) = stats.processing_time_seconds {
131 buf.extend_from_slice(&processing_time_seconds.to_le_bytes());
132 flags_byte |= 1;
133 }
134
135 if let Some(average_throughput) = stats.average_throughput {
136 buf.extend_from_slice(&average_throughput.to_le_bytes());
137 flags_byte |= 2;
138 }
139
140 if let Some(current_processing_rate) = stats.current_processing_rate {
141 buf.extend_from_slice(&current_processing_rate.to_le_bytes());
142 flags_byte |= 4;
143 }
144
145 if let Some(estimated_completion) = stats.estimated_completion {
146 buf.extend_from_slice(&estimated_completion.timestamp().to_le_bytes());
147 flags_byte |= 8;
148 }
149
150 if let Some(version_created) = stats.version_created {
151 buf.extend_from_slice(&version_created.to_le_bytes());
152 flags_byte |= 16;
153 }
154
155 buf[flags_idx] = flags_byte;
156}
157
158pub fn deserialize_processing_stats(
159 bufman: &BufferManager,

Callers 1

serializeMethod · 0.85

Calls 2

lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected