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

Function insert_events

indexer/src/database.rs:136–165  ·  view source on GitHub ↗
(
    db: &Database,
    events: impl Iterator<Item = event::ActiveModel>,
)

Source from the content-addressed store, hash-verified

134}
135
136pub async fn insert_events(
137 db: &Database,
138 events: impl Iterator<Item = event::ActiveModel>,
139) -> Result<(), DbErr> {
140 let db = db.db();
141 let mut hits: HashMap<u32, usize> = Default::default();
142 let mut functions: HashSet<String> = Default::default();
143 let events: Vec<_> = events.collect();
144 for event in events.iter() {
145 if let Some(function_name) = event.function_name.as_ref() {
146 functions.insert(function_name.clone());
147 }
148 let bp_id = event.breakpoint_id.as_ref();
149 let hit = hits.entry(*bp_id).or_default();
150 *hit += 1;
151 }
152
153 let start = std::time::Instant::now();
154 let res = Event::insert_many(events)
155 .on_empty_do_nothing()
156 .exec(db)
157 .await?;
158 let duration = start.elapsed();
159 log::debug!("Event::insert_many: {:?} in {:?}", res, duration);
160
161 inc_hit_count(db, hits).await?;
162 insert_functions(db, functions).await?;
163
164 Ok(())
165}
166
167async fn inc_hit_count(db: &DbConn, breakpoints: HashMap<u32, usize>) -> Result<(), DbErr> {
168 // we batch the updates for all the breakpoints hit by N

Callers 1

batchMethod · 0.85

Calls 5

inc_hit_countFunction · 0.85
insert_functionsFunction · 0.85
dbMethod · 0.80
insertMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected