pub struct Handle<T: Timestamp, C: Container> { /* private fields */ }
Expand description
A handle to an input StreamCore
, used to introduce data to a timely dataflow computation.
Implementations§
source§impl<T: Timestamp, C: Container> Handle<T, C>
impl<T: Timestamp, C: Container> Handle<T, C>
sourcepub fn new() -> Self
pub fn new() -> Self
Allocates a new input handle, from which one can create timely streams.
§Examples
use timely::*;
use timely::dataflow::operators::core::{Input, Inspect};
use timely::dataflow::operators::core::input::Handle;
// construct and execute a timely dataflow
timely::execute(Config::thread(), |worker| {
// add an input and base computation off of it
let mut input = Handle::new();
worker.dataflow(|scope| {
scope.input_from(&mut input)
.container::<Vec<_>>()
.inspect(|x| println!("hello {:?}", x));
});
// introduce input, advance computation
for round in 0..10 {
input.send(round);
input.advance_to(round + 1);
worker.step();
}
});
sourcepub fn to_stream<G>(&mut self, scope: &mut G) -> StreamCore<G, C>
pub fn to_stream<G>(&mut self, scope: &mut G) -> StreamCore<G, C>
Creates an input stream from the handle in the supplied scope.
§Examples
use timely::*;
use timely::dataflow::operators::core::{Input, Inspect};
use timely::dataflow::operators::core::input::Handle;
// construct and execute a timely dataflow
timely::execute(Config::thread(), |worker| {
// add an input and base computation off of it
let mut input = Handle::new();
worker.dataflow(|scope| {
input.to_stream(scope)
.container::<Vec<_>>()
.inspect(|x| println!("hello {:?}", x));
});
// introduce input, advance computation
for round in 0..10 {
input.send(round);
input.advance_to(round + 1);
worker.step();
}
});
sourcepub fn send_batch(&mut self, buffer: &mut C)
pub fn send_batch(&mut self, buffer: &mut C)
Sends a batch of records into the corresponding timely dataflow StreamCore, at the current epoch.
This method flushes single elements previously sent with send
, to keep the insertion order.
§Examples
use timely::*;
use timely::dataflow::operators::core::{Input, InspectCore};
use timely::dataflow::operators::core::input::Handle;
// construct and execute a timely dataflow
timely::execute(Config::thread(), |worker| {
// add an input and base computation off of it
let mut input = Handle::new();
worker.dataflow(|scope| {
scope.input_from(&mut input)
.inspect_container(|x| println!("hello {:?}", x));
});
// introduce input, advance computation
for round in 0..10 {
input.send_batch(&mut vec![format!("{}", round)]);
input.advance_to(round + 1);
worker.step();
}
});
sourcepub fn advance_to(&mut self, next: T)
pub fn advance_to(&mut self, next: T)
Advances the current epoch to next
.
This method allows timely dataflow to issue progress notifications as it can now determine that this input can no longer produce data at earlier timestamps.
source§impl<T: Timestamp, C: PushContainer> Handle<T, C>
impl<T: Timestamp, C: PushContainer> Handle<T, C>
sourcepub fn send<D: PushInto<C>>(&mut self, data: D)
pub fn send<D: PushInto<C>>(&mut self, data: D)
Sends one record into the corresponding timely dataflow Stream
, at the current epoch.
§Examples
use timely::*;
use timely::dataflow::operators::core::{Input, Inspect};
use timely::dataflow::operators::core::input::Handle;
// construct and execute a timely dataflow
timely::execute(Config::thread(), |worker| {
// add an input and base computation off of it
let mut input = Handle::new();
worker.dataflow(|scope| {
scope.input_from(&mut input)
.container::<Vec<_>>()
.inspect(|x| println!("hello {:?}", x));
});
// introduce input, advance computation
for round in 0..10 {
input.send(round);
input.advance_to(round + 1);
worker.step();
}
});
Trait Implementations§
Auto Trait Implementations§
impl<T, C> Freeze for Handle<T, C>
impl<T, C> !RefUnwindSafe for Handle<T, C>
impl<T, C> !Send for Handle<T, C>
impl<T, C> !Sync for Handle<T, C>
impl<T, C> Unpin for Handle<T, C>
impl<T, C> !UnwindSafe for Handle<T, C>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<R, O, T> CopyOnto<ConsecutiveOffsetPairs<R, O>> for T
impl<R, O, T> CopyOnto<ConsecutiveOffsetPairs<R, O>> for T
source§fn copy_onto(
self,
target: &mut ConsecutiveOffsetPairs<R, O>
) -> <ConsecutiveOffsetPairs<R, O> as Region>::Index
fn copy_onto( self, target: &mut ConsecutiveOffsetPairs<R, O> ) -> <ConsecutiveOffsetPairs<R, O> as Region>::Index
Copy self into the target container, returning an index that allows to
look up the corresponding read item.