(
&self,
nested: &mut Iterative<'b, S, u64>,
local_arrangements: &VariableMap<Iterative<'b, S, u64>>,
context: &mut I,
)
| 49 | } |
| 50 | |
| 51 | fn implement<'b, T, I, S>( |
| 52 | &self, |
| 53 | nested: &mut Iterative<'b, S, u64>, |
| 54 | local_arrangements: &VariableMap<Iterative<'b, S, u64>>, |
| 55 | context: &mut I, |
| 56 | ) -> (Implemented<'b, S>, ShutdownHandle) |
| 57 | where |
| 58 | T: Timestamp + Lattice, |
| 59 | I: ImplContext<T>, |
| 60 | S: Scope<Timestamp = T>, |
| 61 | { |
| 62 | let (relation, mut shutdown_handle) = |
| 63 | self.plan.implement(nested, local_arrangements, context); |
| 64 | |
| 65 | let key_offsets: Vec<usize> = self |
| 66 | .variables |
| 67 | .iter() |
| 68 | .map(|variable| relation.binds(*variable).expect("variable not found")) |
| 69 | .collect(); |
| 70 | |
| 71 | let mut variables = relation.variables(); |
| 72 | variables.push(self.result_variable); |
| 73 | |
| 74 | let constants_local = self.constants.clone(); |
| 75 | |
| 76 | let tuples = { |
| 77 | let (tuples, shutdown) = relation.tuples(nested, context); |
| 78 | shutdown_handle.merge_with(shutdown); |
| 79 | tuples |
| 80 | }; |
| 81 | |
| 82 | let transformed = match self.function { |
| 83 | Function::TRUNCATE => CollectionRelation { |
| 84 | variables, |
| 85 | tuples: tuples.map(move |tuple| { |
| 86 | let mut t = match tuple[key_offsets[0]] { |
| 87 | Value::Instant(inst) => inst as u64, |
| 88 | _ => panic!("TRUNCATE can only be applied to timestamps"), |
| 89 | }; |
| 90 | let default_interval = String::from(":hour"); |
| 91 | let interval_param = match constants_local[1].clone() { |
| 92 | Some(Value::String(interval)) => interval, |
| 93 | None => default_interval, |
| 94 | _ => panic!("Parameter for TRUNCATE must be a string"), |
| 95 | }; |
| 96 | |
| 97 | let mod_val = match interval_param.as_ref() { |
| 98 | ":minute" => 60000, |
| 99 | ":hour" => 3_600_000, |
| 100 | ":day" => 86_400_000, |
| 101 | ":week" => 604_800_000, |
| 102 | _ => panic!("Unknown interval for TRUNCATE"), |
| 103 | }; |
| 104 | |
| 105 | t = t - (t % mod_val); |
| 106 | let mut v = tuple.clone(); |
| 107 | v.push(Value::Instant(t)); |
| 108 | v |
nothing calls this directly
no test coverage detected