MCPcopy Create free account
hub / github.com/ceramicnetwork/rust-ceramic / write_all

Method write_all

pipeline/src/cache_table.rs:261–286  ·  view source on GitHub ↗
(
        &self,
        mut data: SendableRecordBatchStream,
        _context: &Arc<TaskContext>,
    )

Source from the content-addressed store, hash-verified

259
260 #[instrument(skip_all, ret(level = Level::DEBUG), err(level = Level::ERROR))]
261 async fn write_all(
262 &self,
263 mut data: SendableRecordBatchStream,
264 _context: &Arc<TaskContext>,
265 ) -> Result<u64> {
266 let num_partitions = self.batches.len();
267
268 // buffer up the data round robin style into num_partitions
269
270 let mut new_batches = vec![vec![]; num_partitions];
271 let mut i = 0;
272 let mut row_count = 0;
273 while let Some(batch) = data.next().await.transpose()? {
274 row_count += batch.num_rows();
275 new_batches[i].push(batch);
276 i = (i + 1) % num_partitions;
277 }
278
279 // write the outputs into the batches
280 for (target, mut batches) in self.batches.iter().zip(new_batches.into_iter()) {
281 // Append all the new batches in one go to minimize locking overhead
282 target.write().await.append(&mut batches);
283 }
284
285 Ok(row_count as u64)
286 }
287}
288
289#[cfg(test)]

Callers 7

writeMethod · 0.80
ld_writeFunction · 0.80
writeMethod · 0.80
ld_writeFunction · 0.80
writeMethod · 0.80
migrateMethod · 0.80
print_record_batchesFunction · 0.80

Calls 7

into_iterMethod · 0.80
appendMethod · 0.80
lenMethod · 0.45
nextMethod · 0.45
pushMethod · 0.45
iterMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected