Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions doublets/src/data/traits.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use bumpalo::Bump;

Check warning on line 1 in doublets/src/data/traits.rs

View workflow job for this annotation

GitHub Actions / Benchmark

unused import: `bumpalo::Bump`
#[cfg(feature = "rayon")]
use rayon::prelude::*;
use std::{
default::default,
iter,
ops::{ControlFlow, Try},
};

Expand Down Expand Up @@ -653,18 +654,27 @@
self.each_iter([self.constants().any; 3])
}

type ImplIterEach = impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator;
type ImplIterEach = impl Iterator<Item = Link<T>>;

#[cfg_attr(feature = "more-inline", inline)]
fn each_iter(&self, query: impl ToQuery<T>) -> Self::ImplIterEach {
let cap = self.count_by(query.to_query()).as_usize();

let query = query.to_query();

// We still need to collect into a Vec first because the current architecture
// uses callbacks, but this prepares for future generator-based implementation
let cap = self.count_by(&query).as_usize();
let mut vec = Vec::with_capacity(cap);
self.each_by(query, &mut |link| {
vec.push(link);
Flow::Continue
});
vec.into_iter()

// Use from_coroutine to create an iterator from the collected data
iter::from_coroutine(#[coroutine] move || {

Check failure on line 673 in doublets/src/data/traits.rs

View workflow job for this annotation

GitHub Actions / Benchmark

cannot find function `from_coroutine` in module `iter`

Check failure on line 673 in doublets/src/data/traits.rs

View workflow job for this annotation

GitHub Actions / Benchmark

cannot find attribute `coroutine` in this scope

Check failure on line 673 in doublets/src/data/traits.rs

View workflow job for this annotation

GitHub Actions / Benchmark

attributes on expressions are experimental
for link in vec {
yield link;

Check failure on line 675 in doublets/src/data/traits.rs

View workflow job for this annotation

GitHub Actions / Benchmark

yield syntax is experimental
}
})
}

#[cfg(feature = "small-search")]
Expand All @@ -677,22 +687,28 @@
}

#[cfg(feature = "small-search")]
type ImplIterEachSmall =
impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator;
type ImplIterEachSmall = impl Iterator<Item = Link<T>>;

#[cfg(feature = "small-search")]
#[cfg_attr(feature = "more-inline", inline)]
fn each_iter_small(&self, query: impl ToQuery<T>) -> Self::ImplIterEachSmall {
// fixme: later use const generics
const SIZE_HINT: usize = 2;


let query = query.to_query();
let mut vec = smallvec::SmallVec::<[Link<_>; SIZE_HINT]>::with_capacity(
self.count_by(query.to_query()).as_usize(),
self.count_by(&query).as_usize(),
);
self.each_by(query, |link| {
vec.push(link);
Flow::Continue
});
vec.into_iter()

// Use from_coroutine to create an iterator from the collected data
iter::from_coroutine(#[coroutine] move || {

Check failure on line 708 in doublets/src/data/traits.rs

View workflow job for this annotation

GitHub Actions / Benchmark

cannot find function `from_coroutine` in module `iter`

Check failure on line 708 in doublets/src/data/traits.rs

View workflow job for this annotation

GitHub Actions / Benchmark

cannot find attribute `coroutine` in this scope

Check failure on line 708 in doublets/src/data/traits.rs

View workflow job for this annotation

GitHub Actions / Benchmark

attributes on expressions are experimental
for link in vec {
yield link;

Check failure on line 710 in doublets/src/data/traits.rs

View workflow job for this annotation

GitHub Actions / Benchmark

yield syntax is experimental
}
})
}
}
4 changes: 3 additions & 1 deletion doublets/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![feature(fn_traits)]
#![feature(generators)]
#![feature(coroutines)]

Check failure on line 2 in doublets/src/lib.rs

View workflow job for this annotation

GitHub Actions / Benchmark

unknown feature `coroutines`
#![feature(yield_expr)]
#![feature(iter_from_coroutine)]

Check failure on line 4 in doublets/src/lib.rs

View workflow job for this annotation

GitHub Actions / Benchmark

unknown feature `iter_from_coroutine`
#![feature(try_trait_v2)]
#![feature(default_free_fn)]
#![feature(unboxed_closures)]
Expand Down
Loading