pub struct LazyJoinQuery<'a, L: 'static, R: 'static> { /* private fields */ }Expand description
A lazy join query builder that returns iterators instead of collecting results.
Supports inner joins and left joins with deferred execution for better performance on large datasets.
§Type Parameters
'a- The lifetime of the data being joinedL- The type of items in the left collectionR- The type of items in the right collection
§Example
ⓘ
let user_orders = LazyJoinQuery::new(&users, &orders)
.inner_join_lazy(
User::id(),
Order::user_id(),
|user, order| (user.name.clone(), order.total)
);
// Nothing executed yet - just an iterator
let first_5: Vec<_> = user_orders.take(5).collect();Implementations§
Source§impl<'a, L: 'static, R: 'static> LazyJoinQuery<'a, L, R>
impl<'a, L: 'static, R: 'static> LazyJoinQuery<'a, L, R>
Sourcepub fn inner_join_lazy<K, O, F>(
&self,
left_key: KeyPaths<L, K>,
right_key: KeyPaths<R, K>,
mapper: F,
) -> impl Iterator<Item = O> + 'a
pub fn inner_join_lazy<K, O, F>( &self, left_key: KeyPaths<L, K>, right_key: KeyPaths<R, K>, mapper: F, ) -> impl Iterator<Item = O> + 'a
Performs a lazy inner join between two collections.
Returns an iterator over matching pairs. The join is evaluated lazily, allowing for early termination and memory efficiency.
§Arguments
left_key- Key-path to the join field in the left collectionright_key- Key-path to the join field in the right collectionmapper- Function to transform matching pairs into the result type
§Example
ⓘ
let results: Vec<_> = LazyJoinQuery::new(&users, &orders)
.inner_join_lazy(
User::id(),
Order::user_id(),
|user, order| (user.name.clone(), order.total)
)
.take(10) // Early termination - only process first 10 matches
.collect();Sourcepub fn left_join_lazy<K, O, F>(
&self,
left_key: KeyPaths<L, K>,
right_key: KeyPaths<R, K>,
mapper: F,
) -> impl Iterator<Item = O> + 'a
pub fn left_join_lazy<K, O, F>( &self, left_key: KeyPaths<L, K>, right_key: KeyPaths<R, K>, mapper: F, ) -> impl Iterator<Item = O> + 'a
Performs a lazy left join between two collections.
Returns an iterator over all left items with optional right matches. The join is evaluated lazily, allowing for early termination.
§Arguments
left_key- Key-path to the join field in the left collectionright_key- Key-path to the join field in the right collectionmapper- Function to transform pairs into the result type (right item may be None)
§Example
ⓘ
let results: Vec<_> = LazyJoinQuery::new(&users, &orders)
.left_join_lazy(
User::id(),
Order::user_id(),
|user, order| match order {
Some(o) => format!("{} has order {}", user.name, o.id),
None => format!("{} has no orders", user.name),
}
)
.take(5) // Early termination
.collect();Sourcepub fn inner_join_where_lazy<K, O, F, P>(
&self,
left_key: KeyPaths<L, K>,
right_key: KeyPaths<R, K>,
predicate: P,
mapper: F,
) -> impl Iterator<Item = O> + 'a
pub fn inner_join_where_lazy<K, O, F, P>( &self, left_key: KeyPaths<L, K>, right_key: KeyPaths<R, K>, predicate: P, mapper: F, ) -> impl Iterator<Item = O> + 'a
Performs a lazy inner join with an additional filter predicate.
Like inner_join_lazy, but only includes pairs that satisfy both the join
condition and the additional predicate.
§Arguments
left_key- Key-path to the join field in the left collectionright_key- Key-path to the join field in the right collectionpredicate- Additional condition that must be true for pairs to be includedmapper- Function to transform matching pairs into the result type
§Example
ⓘ
let results: Vec<_> = LazyJoinQuery::new(&orders, &products)
.inner_join_where_lazy(
Order::product_id(),
Product::id(),
|order, _product| order.total > 100.0,
|order, product| (product.name.clone(), order.total)
)
.take(10)
.collect();Auto Trait Implementations§
impl<'a, L, R> Freeze for LazyJoinQuery<'a, L, R>
impl<'a, L, R> RefUnwindSafe for LazyJoinQuery<'a, L, R>where
L: RefUnwindSafe,
R: RefUnwindSafe,
impl<'a, L, R> Send for LazyJoinQuery<'a, L, R>
impl<'a, L, R> Sync for LazyJoinQuery<'a, L, R>
impl<'a, L, R> Unpin for LazyJoinQuery<'a, L, R>
impl<'a, L, R> UnwindSafe for LazyJoinQuery<'a, L, R>where
L: RefUnwindSafe,
R: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more