You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extern crate differential_dataflow;
extern crate timely;
type Timestamp = u64;
fn main() {
use differential_dataflow::input::Input;
use differential_dataflow::operators::group::Group;
timely::execute(timely::Configuration::Thread, move |worker| {
let (mut handle, probe) = worker.dataflow::<Timestamp, _, _>(|scope| {
let (handle, data) = scope.new_collection();
let probe = data
.group(|_group, log_ids, out| {
let log_id: u64 = log_ids.iter().map(|&(&ts, &diff)| ts).max().unwrap();
out.push((log_id, 1))
})
.inspect(|&((group, log_id), _time, _diff)| {
println!("{} {}", group, log_id)
})
.probe();
(handle, probe)
});
let (group, log_id) = (4, 1004);
handle.advance_to(0);
handle.insert((group, log_id));
handle.close();
worker.step_while(|| !probe.done());
}).unwrap();
}
But when trying to compile it gives me 6 errors of two varieties:
error[E0277]: the trait bound `&_: differential_dataflow::Diff` is not satisfied
--> src/timely.rs:131:40
|
131 | let (handle, data) = scope.new_collection();
| ^^^^^^^^^^^^^^ the trait `differential_dataflow::Diff` is not implemented for `&_`
|
= help: the following implementations were found:
<i32 as differential_dataflow::Diff>
<isize as differential_dataflow::Diff>
<i64 as differential_dataflow::Diff>
<differential_dataflow::difference::DiffPair<R1, R2> as differential_dataflow::Diff>
and
error[E0599]: no method named `insert` found for type `differential_dataflow::input::InputSession<u64, (_, u64), &_>` in the current scope
--> src/timely.rs:146:16
|
146 | handle.insert((group, log_id));
| ^^^^^^
My standard debugging mechanism in cases like this is to add type annotations and see when there's a contradiction. But when you add the annotations to the closure params, like .group(|_group, log_ids: &[(&(_, &isize))], out: &mut Vec<_>| {, you get a different cryptic error message (maybe rust-lang/rust#41078?):
In this case, the actual problem is that the &diff should be diff - both of the failed compiles contain hints if you look hard enough, but it's not easy to figure out. The correct place to add type annotations to help out inference is actually to pin down the diff type, i.e. scope.new_collection::<_, isize>().
I don't know if there's anything actionable here, but I thought I'd raise the issue. One thing I'd observe is that many of the examples and documentation show type annotations on worker.dataflow to pin down the timestamp type - I suppose one possible solution is to just make it so that the 'idiomatic' examples demonstrate a similar thing for the diff type.
The text was updated successfully, but these errors were encountered:
Interesting. I don't think I've ever run in to this before, but I obviously have some biases. The Diff type is currently hidden as a default generic parameter, and .. yeah not sure where the trade-off between "reveal as idiomatic to set" vs "hide to avoid issues" lives.
It would be great to have errors about type parameters earlier, and if you have any tips (or examples elsewhere) of putting more constraints on the types so that they bail earlier rather than with whole-program type inference errors (which I also have a hard time grokking), I'm all ears/eyes/etc.
I think one take-away is that the documentation and examples for differential aren't up to snuff yet. I OD'd on DD recently and am currently recuperating, but up for making that the next priority. :)
I have this smallish example:
But when trying to compile it gives me 6 errors of two varieties:
and
My standard debugging mechanism in cases like this is to add type annotations and see when there's a contradiction. But when you add the annotations to the closure params, like
.group(|_group, log_ids: &[(&(_, &isize))], out: &mut Vec<_>| {
, you get a different cryptic error message (maybe rust-lang/rust#41078?):In this case, the actual problem is that the
&diff
should bediff
- both of the failed compiles contain hints if you look hard enough, but it's not easy to figure out. The correct place to add type annotations to help out inference is actually to pin down the diff type, i.e.scope.new_collection::<_, isize>()
.I don't know if there's anything actionable here, but I thought I'd raise the issue. One thing I'd observe is that many of the examples and documentation show type annotations on
worker.dataflow
to pin down the timestamp type - I suppose one possible solution is to just make it so that the 'idiomatic' examples demonstrate a similar thing for the diff type.The text was updated successfully, but these errors were encountered: