pub trait Input: Scope {
// Required methods
fn new_input<D: Data>(
&mut self,
) -> (Handle<<Self as ScopeParent>::Timestamp, D>, Stream<Self, D>);
fn new_input_core<D: Container>(
&mut self,
) -> (HandleCore<<Self as ScopeParent>::Timestamp, D>, StreamCore<Self, D>);
fn input_from<D: Data>(
&mut self,
handle: &mut Handle<<Self as ScopeParent>::Timestamp, D>,
) -> Stream<Self, D>;
fn input_from_core<D: Container>(
&mut self,
handle: &mut HandleCore<<Self as ScopeParent>::Timestamp, D>,
) -> StreamCore<Self, D>;
}
Expand description
Create a new Stream
and Handle
through which to supply input.
Required Methods§
Sourcefn new_input<D: Data>(
&mut self,
) -> (Handle<<Self as ScopeParent>::Timestamp, D>, Stream<Self, D>)
fn new_input<D: Data>( &mut self, ) -> (Handle<<Self as ScopeParent>::Timestamp, D>, Stream<Self, D>)
Create a new Stream
and Handle
through which to supply input.
The new_input
method returns a pair (Handle, Stream)
where the Stream
can be used
immediately for timely dataflow construction, and the Handle
is later used to introduce
data into the timely dataflow computation.
The Handle
also provides a means to indicate
to timely dataflow that the input has advanced beyond certain timestamps, allowing timely
to issue progress notifications.
§Examples
use timely::*;
use timely::dataflow::operators::{Input, Inspect};
// construct and execute a timely dataflow
timely::execute(Config::thread(), |worker| {
// add an input and base computation off of it
let mut input = worker.dataflow(|scope| {
let (input, stream) = scope.new_input();
stream.inspect(|x| println!("hello {:?}", x));
input
});
// introduce input, advance computation
for round in 0..10 {
input.send(round);
input.advance_to(round + 1);
worker.step();
}
});
Sourcefn new_input_core<D: Container>(
&mut self,
) -> (HandleCore<<Self as ScopeParent>::Timestamp, D>, StreamCore<Self, D>)
fn new_input_core<D: Container>( &mut self, ) -> (HandleCore<<Self as ScopeParent>::Timestamp, D>, StreamCore<Self, D>)
Create a new StreamCore and HandleCore through which to supply input.
The new_input_core
method returns a pair (HandleCore, StreamCore)
where the StreamCore can be used
immediately for timely dataflow construction, and the HandleCore
is later used to introduce
data into the timely dataflow computation.
The HandleCore
also provides a means to indicate
to timely dataflow that the input has advanced beyond certain timestamps, allowing timely
to issue progress notifications.
§Examples
use timely::*;
use timely::dataflow::operators::{Input, Inspect};
// construct and execute a timely dataflow
timely::execute(Config::thread(), |worker| {
// add an input and base computation off of it
let mut input = worker.dataflow(|scope| {
let (input, stream) = scope.new_input_core::<Vec<_>>();
stream.inspect(|x| println!("hello {:?}", x));
input
});
// introduce input, advance computation
for round in 0..10 {
input.send(round);
input.advance_to(round + 1);
worker.step();
}
});
Sourcefn input_from<D: Data>(
&mut self,
handle: &mut Handle<<Self as ScopeParent>::Timestamp, D>,
) -> Stream<Self, D>
fn input_from<D: Data>( &mut self, handle: &mut Handle<<Self as ScopeParent>::Timestamp, D>, ) -> Stream<Self, D>
Create a new stream from a supplied interactive handle.
This method creates a new timely stream whose data are supplied interactively through the handle
argument. Each handle may be used multiple times (or not at all), and will clone data as appropriate
if it as attached to more than one stream.
§Examples
use timely::*;
use timely::dataflow::operators::{Input, Inspect};
use timely::dataflow::operators::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(|x| println!("hello {:?}", x));
});
// introduce input, advance computation
for round in 0..10 {
input.send(round);
input.advance_to(round + 1);
worker.step();
}
});
Sourcefn input_from_core<D: Container>(
&mut self,
handle: &mut HandleCore<<Self as ScopeParent>::Timestamp, D>,
) -> StreamCore<Self, D>
fn input_from_core<D: Container>( &mut self, handle: &mut HandleCore<<Self as ScopeParent>::Timestamp, D>, ) -> StreamCore<Self, D>
Create a new stream from a supplied interactive handle.
This method creates a new timely stream whose data are supplied interactively through the handle
argument. Each handle may be used multiple times (or not at all), and will clone data as appropriate
if it as attached to more than one stream.
§Examples
use timely::*;
use timely::dataflow::operators::{Input, Inspect};
use timely::dataflow::operators::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_core(&mut input)
.inspect(|x| println!("hello {:?}", x));
});
// introduce input, advance computation
for round in 0..10 {
input.send(round);
input.advance_to(round + 1);
worker.step();
}
});
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.