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

Method implement

src/plan/graphql_v2.rs:269–416  ·  view source on GitHub ↗

See Implementable::implement, as GraphQl v2 can't implement Implementable directly.

(
        &self,
        nested: &mut Iterative<'b, S, u64>,
        context: &mut I,
    )

Source from the content-addressed store, hash-verified

267 /// See Implementable::implement, as GraphQl v2 can't implement
268 /// Implementable directly.
269 pub fn implement<'b, T, I, S>(
270 &self,
271 nested: &mut Iterative<'b, S, u64>,
272 context: &mut I,
273 ) -> (Stream<S, Output>, ShutdownHandle)
274 where
275 T: Timestamp + Lattice,
276 I: ImplContext<T>,
277 S: Scope<Timestamp = T>,
278 S::Timestamp: std::convert::Into<crate::timestamp::Time>,
279 {
280 use timely::dataflow::operators::Concatenate;
281
282 let states = Rc::new(RefCell::new(JValue::Object(Map::new())));
283
284 let dummy = VariableMap::new();
285
286 let mut paths = {
287 let mut paths_map = self
288 .paths
289 .iter()
290 .flat_map(|path| {
291 let (streams, shutdown) = path.implement(nested, &dummy, context);
292 std::mem::forget(shutdown);
293 streams
294 })
295 .collect::<HashMap<PathId, _>>();
296
297 let mut paths = paths_map.drain().collect::<Vec<(PathId, _)>>();
298
299 // Important for cross-worker determinism.
300 paths.sort_by_key(|(path_id, _)| path_id.clone());
301
302 paths
303 };
304
305 let streams = paths.drain(..).map(|(path_id, stream)| {
306 let states = states.clone();
307 let mut buffer = HashMap::new();
308 let mut vector = Vec::new();
309
310 stream
311 .exchange(|(path, _t, _diff)| path[0].clone().hashed())
312 .delay(|(_path, t, _diff), _cap| t.clone())
313 .unary_notify(
314 Pipeline,
315 "Changes",
316 vec![],
317 move |input, output, notificator| {
318 input.for_each(|cap, data| {
319 data.swap(&mut vector);
320 buffer
321 .entry(cap.time().clone())
322 .or_insert_with(Vec::new)
323 .extend(vector.drain(..));
324
325 notificator.notify_at(cap.retain());
326 });

Callers 2

implementFunction · 0.45
implement_neuFunction · 0.45

Calls 4

pointer_mutFunction · 0.85
extendMethod · 0.80
intoMethod · 0.80
interleaveFunction · 0.70

Tested by

no test coverage detected