timely/progress/
mod.rs

1//! Progress tracking mechanisms to support notification in timely dataflow
2
3pub use self::operate::Operate;
4pub use self::subgraph::{Subgraph, SubgraphBuilder};
5pub use self::timestamp::{Timestamp, PathSummary};
6pub use self::change_batch::ChangeBatch;
7pub use self::frontier::Antichain;
8
9pub mod change_batch;
10pub mod frontier;
11pub mod timestamp;
12pub mod operate;
13pub mod broadcast;
14pub mod reachability;
15pub mod subgraph;
16
17/// A timely dataflow location.
18#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Abomonation, Serialize, Deserialize)]
19pub struct Location {
20    /// A scope-local operator identifier.
21    pub node: usize,
22    /// An operator port identifier.`
23    pub port: Port,
24}
25
26impl Location {
27    /// Creates a new target location (operator input or scope output).
28    pub fn new_target(node: usize, port: usize) -> Location {
29        Location { node, port: Port::Target(port) }
30    }
31    /// Creates a new source location (operator output or scope input).
32    pub fn new_source(node: usize, port: usize) -> Location {
33        Location { node, port: Port::Source(port) }
34    }
35    /// If the location is a target.
36    pub fn is_target(&self) -> bool { matches!(self.port, Port::Target(_)) }
37    /// If the location is a source.
38    pub fn is_source(&self) -> bool { matches!(self.port, Port::Source(_)) }
39}
40
41impl From<Target> for Location {
42    fn from(target: Target) -> Self {
43        Location {
44            node: target.node,
45            port: Port::Target(target.port),
46        }
47    }
48}
49
50impl From<Source> for Location {
51    fn from(source: Source) -> Self {
52        Location {
53            node: source.node,
54            port: Port::Source(source.port),
55        }
56    }
57}
58
59/// An operator port.
60#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Abomonation, Serialize, Deserialize)]
61pub enum Port {
62    /// An operator input.
63    Target(usize),
64    /// An operator output.
65    Source(usize),
66}
67
68/// Names a source of a data stream.
69///
70/// A source of data is either a child output, or an input from a parent.
71/// Conventionally, `index` zero is used for parent input.
72#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
73pub struct Source {
74    /// Index of the source operator.
75    pub node: usize,
76    /// Number of the output port from the operator.
77    pub port: usize,
78}
79
80impl Source {
81    /// Creates a new source from node and port identifiers.
82    pub fn new(node: usize, port: usize) -> Self {
83        Self { node, port }
84    }
85}
86
87/// Names a target of a data stream.
88///
89/// A target of data is either a child input, or an output to a parent.
90/// Conventionally, `index` zero is used for parent output.
91#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
92pub struct Target {
93    /// Index of the target operator.
94    pub node: usize,
95    /// Number of the input port to the operator.
96    pub port: usize,
97}
98
99impl Target {
100    /// Creates a new target from node and port identifiers.
101    pub fn new(node: usize, port: usize) -> Self {
102        Self { node, port }
103    }
104}