MCPcopy Create free account
hub / github.com/comnik/declarative-dataflow / source

Method source

src/sources/timely_logging.rs:30–185  ·  view source on GitHub ↗
(
        &self,
        scope: &mut S,
        context: SourcingContext<S::Timestamp>,
    )

Source from the content-addressed store, hash-verified

28
29impl<S: Scope<Timestamp = Duration>> Sourceable<S> for TimelyLogging {
30 fn source(
31 &self,
32 scope: &mut S,
33 context: SourcingContext<S::Timestamp>,
34 ) -> Vec<(
35 Aid,
36 AttributeConfig,
37 Stream<S, ((Value, Value), Duration, isize)>,
38 )> {
39 let input = match self.remote_peers {
40 None => {
41 // Read events introspectively.
42 Some(context.timely_events).replay_into(scope)
43 }
44 Some(source_peers) => {
45 // Listen for events from a remote computation.
46 let sockets = open_sockets(source_peers);
47 make_replayers(sockets, scope.index(), scope.peers()).replay_into(scope)
48 }
49 };
50
51 let mut demux = OperatorBuilder::new("Timely Logging Demux".to_string(), scope.clone());
52
53 let mut input = demux.new_input(&input, Pipeline);
54
55 let mut wrappers = HashMap::with_capacity(self.attributes.len());
56 let mut streams = HashMap::with_capacity(self.attributes.len());
57
58 for aid in self.attributes.iter() {
59 let (wrapper, stream) = demux.new_output();
60 wrappers.insert(aid.to_string(), wrapper);
61 streams.insert(aid.to_string(), stream);
62 }
63
64 let mut demux_buffer = Vec::new();
65 let num_interests = self.attributes.len();
66
67 demux.build(move |_capability| {
68 move |_frontiers| {
69 let mut handles = HashMap::with_capacity(num_interests);
70 for (aid, wrapper) in wrappers.iter_mut() {
71 handles.insert(aid.to_string(), wrapper.activate());
72 }
73
74 input.for_each(|time, data: RefOrMut<Vec<_>>| {
75 data.swap(&mut demux_buffer);
76
77 let mut sessions = HashMap::with_capacity(num_interests);
78 for (aid, handle) in handles.iter_mut() {
79 sessions.insert(aid.to_string(), handle.session(&time));
80 }
81
82 for (time, _worker, datum) in demux_buffer.drain(..) {
83 match datum {
84 TimelyEvent::Operates(mut x) => {
85 let eid = Eid((x.id as u64).into());
86 let name = Value::String(x.name);
87

Callers

nothing calls this directly

Calls 4

open_socketsFunction · 0.85
make_replayersFunction · 0.85
indexMethod · 0.80
intoMethod · 0.80

Tested by

no test coverage detected