MCPcopy Create free account
hub / github.com/SeaQL/FireDBG.for.Rust / batch

Method batch

indexer/src/main.rs:160–229  ·  view source on GitHub ↗
(&mut self, messages: impl Iterator<Item = SharedMessage> + Send)

Source from the content-addressed store, hash-verified

158#[async_trait::async_trait]
159impl Processor for DatabaseSink {
160 async fn batch(&mut self, messages: impl Iterator<Item = SharedMessage> + Send) -> Result<()> {
161 let mut files = Vec::new();
162 let mut bps = Vec::new();
163 let mut events = Vec::new();
164 let mut types = Vec::new();
165 let mut allocs = Vec::new();
166 let mut flush = false;
167
168 for message in messages {
169 match message.header().stream_key().name() {
170 INFO_STREAM => {
171 save_debugger_info(&self.db, translate::debugger_info(deser_info(&message)))
172 .await?
173 }
174 FILE_STREAM => files.push(deser(&message)),
175 BREAKPOINT_STREAM => bps.push(deser(&message)),
176 EVENT_STREAM => events.push({
177 let event = EventStream::read_from(message.message().into_bytes().into());
178 translate::type_info(&event, |ty| types.push(ty));
179 let mut parent_frame_id = None;
180 match &event {
181 Event::FunctionCall {
182 thread_id,
183 frame_id,
184 ..
185 } => {
186 let stack = self.stack.entry(*thread_id).or_default();
187 parent_frame_id = stack.last().copied();
188 stack.push(*frame_id);
189 }
190 Event::FunctionReturn {
191 thread_id,
192 frame_id,
193 ..
194 } => {
195 assert_eq!(
196 *frame_id,
197 self.stack
198 .get_mut(thread_id)
199 .expect("Thread not found")
200 .pop()
201 .expect("Stack frame empty")
202 );
203 }
204 _ => (),
205 }
206 let mut event = translate::event(message.timestamp(), event);
207 event.parent_frame_id = sea_orm::Set(parent_frame_id.map(|s| s as i64));
208 event
209 }),
210 ALLOCATION_STREAM => allocs.push(deser(&message)),
211 _ => anyhow::bail!("Unexpected stream key {}", message.stream_key()),
212 }
213 self.count += 1;
214 flush |= self.count % 10000 == 0;
215 }
216
217 insert_files(&self.db, files.into_iter().map(translate::source_file)).await?;

Callers 1

runFunction · 0.45

Calls 15

save_debugger_infoFunction · 0.85
debugger_infoFunction · 0.85
deser_infoFunction · 0.85
deserFunction · 0.85
type_infoFunction · 0.85
eventFunction · 0.85
insert_filesFunction · 0.85
insert_breakpointsFunction · 0.85
insert_eventsFunction · 0.85
insert_type_infoFunction · 0.85
insert_allocationsFunction · 0.85
into_bytesMethod · 0.80

Tested by

no test coverage detected