TimelyDataflow / TimelyDataflow/differential-dataflow
Error messages can be confusing
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3k
- Forks
- 211
- Avg merge
- 10h 42m
- Merged PRs (30d)
- 34
Description
I have this smallish example:
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 https://github.com/rust-lang/rust/issues/41078?):
error[E0631]: type mismatch in closure arguments
--> src/timely.rs:133:18
|
133 | .group(|_group, log_ids: &[(&(_, &isize))], out: &mut Vec<_>| {
| ^^^^^ ------------------------------------------------------ found signature of `for<'r, 's, 't0, 't1> fn(_, &'r [&'s (&u64, &'t0 isize)], &'t1 mut std::vec::Vec<(u64, {integer})>) -> _`
| |
| expected signature of `for<'r, 's, 't0, 't1> fn(&'r _, &'s [(&'t0 _, _)], &'t1 mut std::vec::Vec<(_, _)>) -> _`
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the example in src/timely.rs around lines 131-146 and reproduce the reported compilation errors. Check whether the project's examples or documentation should pin the diff type as suggested; done should be an agreed, actionable change that makes the intended annotation guidance clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100