1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use timely::dataflow::scopes::child::Iterative;
use timely::dataflow::Scope;
use timely::order::TotalOrder;
use timely::progress::Timestamp;
use differential_dataflow::lattice::Lattice;
use crate::binding::Binding;
use crate::plan::{next_id, Dependencies, ImplContext, Implementable};
use crate::{Aid, Eid, Value, Var};
use crate::{CollectionRelation, Relation, ShutdownHandle, VariableMap};
#[derive(Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Debug, Serialize, Deserialize)]
pub struct Project<P: Implementable> {
pub variables: Vec<Var>,
pub plan: Box<P>,
}
impl<P: Implementable> Implementable for Project<P> {
fn dependencies(&self) -> Dependencies {
self.plan.dependencies()
}
fn into_bindings(&self) -> Vec<Binding> {
self.plan.into_bindings()
}
fn datafy(&self) -> Vec<(Eid, Aid, Value)> {
let eid = next_id();
let mut data = self.plan.datafy();
if data.is_empty() {
Vec::new()
} else {
let child_eid = data[0].0;
data.push((eid, "df.project/binding".to_string(), Value::Eid(child_eid)));
data
}
}
fn implement<'b, T, I, S>(
&self,
nested: &mut Iterative<'b, S, u64>,
local_arrangements: &VariableMap<Iterative<'b, S, u64>>,
context: &mut I,
) -> (CollectionRelation<'b, S>, ShutdownHandle)
where
T: Timestamp + Lattice + TotalOrder,
I: ImplContext<T>,
S: Scope<Timestamp = T>,
{
let (relation, shutdown_handle) = self.plan.implement(nested, local_arrangements, context);
let projected = CollectionRelation {
variables: self.variables.to_vec(),
tuples: relation.projected(&self.variables),
};
(projected, shutdown_handle)
}
}