Skip to content

Commit f093870

Browse files
Return Relation tuples in JoinInput::recent instead of stable
This is a bit unintuitive, but we don't have another choice given the implementation of `Relation::from_antijoin` and the `transmute` in the next commit, although we could probably assume that `Relation<Vec<T>>` and `Relation<Vec<(T, ())>>` are layout compatible, it is not guaranteed. Perhaps these should be renamed to `old`/`new` to make things clearer?
1 parent dc5e0fe commit f093870

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/join.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,15 @@ pub(crate) fn gallop<T>(mut slice: &[T], mut cmp: impl FnMut(&T) -> bool) -> &[T
132132

133133
/// An input that can be used with `from_join`; either a `Variable` or a `Relation`.
134134
pub trait JoinInput<'me, Tuple: Ord>: Copy {
135-
/// If we are on iteration N of the loop, these are the tuples
136-
/// added on iteration N-1. (For a `Relation`, this is always an
137-
/// empty slice.)
135+
/// For a `Variable` on iteration N of the loop, these are the tuples added on iteration N-1.
136+
///
137+
/// For a `Relation`, this is `self.elements`.
138138
type RecentTuples: Deref<Target = [Tuple]>;
139139

140-
/// If we are on iteration N of the loop, these are the tuples
141-
/// added on iteration N - 2 or before. (For a `Relation`, this is
142-
/// just `self`.)
140+
/// For a `Variable` on iteration N of the loop, these are the tuples added on iteration N-2 or
141+
/// before.
142+
///
143+
/// For a `Relation`, this will be empty.
143144
type StableTuples: Deref<Target = [Relation<Tuple>]>;
144145

145146
/// Get the set of recent tuples.
@@ -167,10 +168,10 @@ impl<'me, Tuple: Ord> JoinInput<'me, Tuple> for &'me Relation<Tuple> {
167168
type StableTuples = &'me [Relation<Tuple>];
168169

169170
fn recent(self) -> Self::RecentTuples {
170-
&[]
171+
&self.elements
171172
}
172173

173174
fn stable(self) -> Self::StableTuples {
174-
std::slice::from_ref(self)
175+
&[]
175176
}
176177
}

0 commit comments

Comments
 (0)