Load code fixed

This commit is contained in:
micialware committed 2026-08-28 17:15:16 +03:00
1 parent a01a29c492
commit d8e3a5b6db
1 file changed
+20 -4
+20 -4
View File
@@ -122,10 +122,10 @@ impl<T: EntityData + Clone, R: Repository<T, D>, D: DbLayer<T>> Query<T, R, D> {
} }
} }
pub fn load(&mut self, data_repository: DataRepositoryInner<T, D>) { pub fn load(&mut self, data_repository: &DataRepositoryInner<T, D>) where T : Send + Sync {
self.cache.clear(); self.cache.clear();
if self.parallel { if self.parallel {
let mut cache: Vec<EntityHandle<T>> = data_repository self.cache = data_repository
.cache .cache
.par_iter() .par_iter()
.enumerate() .enumerate()
@@ -138,7 +138,24 @@ impl<T: EntityData + Clone, R: Repository<T, D>, D: DbLayer<T>> Query<T, R, D> {
}) })
.collect(); .collect();
cache.extend(
}
else {
self.cache = data_repository
.cache
.iter()
.enumerate()
.filter(|(_, entity)| (self.rule)(entity))
.map(|(i, entity)| EntityHandle {
id: entity.id(),
real: true,
index: i as u32,
_phantom: PhantomData,
})
.collect();
}
self.cache.extend(
data_repository data_repository
.temporal .temporal
.iter() .iter()
@@ -154,7 +171,6 @@ impl<T: EntityData + Clone, R: Repository<T, D>, D: DbLayer<T>> Query<T, R, D> {
); );
} }
} }
}
pub trait BatchedRepository<T, D> pub trait BatchedRepository<T, D>
where where