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
+32 -16
+32 -16
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();
if self.parallel {
let mut cache: Vec<EntityHandle<T>> = data_repository
self.cache = data_repository
.cache
.par_iter()
.enumerate()
@@ -138,21 +138,37 @@ impl<T: EntityData + Clone, R: Repository<T, D>, D: DbLayer<T>> Query<T, R, D> {
})
.collect();
cache.extend(
data_repository
.temporal
.iter()
.enumerate()
.filter(|(_, entity)| (self.rule)(entity))
.map(|(i, entity)| EntityHandle {
id: entity.id(),
real: false,
index: i as u32,
_phantom: PhantomData,
})
.collect::<Vec<_>>(),
);
}
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
.temporal
.iter()
.enumerate()
.filter(|(_, entity)| (self.rule)(entity))
.map(|(i, entity)| EntityHandle {
id: entity.id(),
real: false,
index: i as u32,
_phantom: PhantomData,
})
.collect::<Vec<_>>(),
);
}
}