Skip to content

Commit 25c7774

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 7880cc5 commit 25c7774

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
@@ -136,14 +136,15 @@ pub(crate) fn gallop<T>(mut slice: &[T], mut cmp: impl FnMut(&T) -> bool) -> &[T
136136

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

144-
/// If we are on iteration N of the loop, these are the tuples
145-
/// added on iteration N - 2 or before. (For a `Relation`, this is
146-
/// just `self`.)
144+
/// For a `Variable` on iteration N of the loop, these are the tuples added on iteration N-2 or
145+
/// before.
146+
///
147+
/// For a `Relation`, this will be empty.
147148
type StableTuples: Deref<Target = [Relation<Tuple>]>;
148149

149150
/// Get the set of recent tuples.
@@ -171,10 +172,10 @@ impl<'me, Tuple: Ord> JoinInput<'me, Tuple> for &'me Relation<Tuple> {
171172
type StableTuples = &'me [Relation<Tuple>];
172173

173174
fn recent(self) -> Self::RecentTuples {
174-
&[]
175+
&self.elements
175176
}
176177

177178
fn stable(self) -> Self::StableTuples {
178-
std::slice::from_ref(self)
179+
&[]
179180
}
180181
}

0 commit comments

Comments
 (0)