MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / iterator_operator

Function iterator_operator

src/storage-operators/src/persist_source.rs:1434–1463  ·  view source on GitHub ↗

An operator that emits `Part`'s at the specified timestamps. Does not drop its capability until it gets a signal from the `Sender` it returns.

(
        scope: Scope<'scope, (u64, Subtime)>,
        mut input: I,
    )

Source from the content-addressed store, hash-verified

1432 /// An operator that emits `Part`'s at the specified timestamps. Does not
1433 /// drop its capability until it gets a signal from the `Sender` it returns.
1434 fn iterator_operator<'scope, I: Iterator<Item = (u64, Part)> + 'static>(
1435 scope: Scope<'scope, (u64, Subtime)>,
1436 mut input: I,
1437 ) -> (StreamVec<'scope, (u64, Subtime), Part>, oneshot::Sender<()>) {
1438 let (finalizer_tx, finalizer_rx) = oneshot::channel();
1439 let mut iterator = AsyncOperatorBuilder::new("iterator".to_string(), scope);
1440 let (output_handle, output) = iterator.new_output::<CapacityContainerBuilder<Vec<Part>>>();
1441
1442 iterator.build(|mut caps| async move {
1443 let mut capability = Some(caps.pop().unwrap());
1444 let mut last = None;
1445 while let Some(element) = input.next() {
1446 let time = element.0.clone();
1447 let part = element.1;
1448 last = Some((time, Subtime(0)));
1449 output_handle.give(&capability.as_ref().unwrap().delayed(&last.unwrap()), part);
1450 }
1451 if let Some(last) = last {
1452 capability
1453 .as_mut()
1454 .unwrap()
1455 .downgrade(&(last.0 + 1, last.1));
1456 }
1457
1458 let _ = finalizer_rx.await;
1459 capability.take();
1460 });
1461
1462 (output, finalizer_tx)
1463 }
1464
1465 /// An operator that consumes its input ONLY when given a signal to do from
1466 /// the `UnboundedSender` it returns. Each `send` corresponds with 1 `Data` event

Callers 1

backpressure_runnerFunction · 0.85

Calls 13

channelFunction · 0.85
SubtimeClass · 0.85
unwrapMethod · 0.80
downgradeMethod · 0.80
to_stringMethod · 0.45
buildMethod · 0.45
popMethod · 0.45
nextMethod · 0.45
cloneMethod · 0.45
giveMethod · 0.45
as_refMethod · 0.45
as_mutMethod · 0.45

Tested by

no test coverage detected