Update save_many
This commit is contained in:
1 parent
3eba0c93d4
commit
0326b56ded
2 files changed
+20
-17
No files matched your search
@@ -8,7 +8,6 @@ use rayon::prelude::*;
|
||||
use rhai::{Engine, Scope};
|
||||
use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::time::Instant;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
+20
-16
@@ -221,7 +221,7 @@ for DataRepositoryInner<T, D>
|
||||
}
|
||||
let find = temp[cell].id;
|
||||
let remove = x.id() == find;
|
||||
if remove || find > x.id() {
|
||||
if remove {
|
||||
cell += 1;
|
||||
values.push(x.clone());
|
||||
}
|
||||
@@ -230,21 +230,25 @@ for DataRepositoryInner<T, D>
|
||||
|
||||
self.data_layer
|
||||
.add_many_entity(&mut values, &self.connection.lock())?;
|
||||
let mut index = self.cache.len();
|
||||
values
|
||||
.iter()
|
||||
.zip(temp)
|
||||
.for_each(|(x, y)| {
|
||||
y.id = x.id();
|
||||
y.index = index as u32;
|
||||
index += 1;
|
||||
});
|
||||
|
||||
for in_cache in cached {
|
||||
let value = self.get_ref(in_cache).unwrap();
|
||||
self.data_layer.write_entity(value, &self.connection.lock())?;
|
||||
let start = self.cache.len();
|
||||
self.cache.extend(values);
|
||||
|
||||
for (i, handle) in temp.into_iter().enumerate() {
|
||||
let h = handle;
|
||||
h.id = self.cache[start + i].id();
|
||||
h.index = (start + i) as u32;
|
||||
h.real = true;
|
||||
}
|
||||
todo!()
|
||||
|
||||
for handle in cached.iter_mut() {
|
||||
let h = &mut **handle;
|
||||
let idx = fast_position_of(self.cache.as_slice(), h).unwrap();
|
||||
self.data_layer
|
||||
.write_entity(&self.cache[idx], &self.connection.lock())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn delete_many(&mut self, handles: &mut [EntityHandle<T>]) -> MaybeError {
|
||||
@@ -258,7 +262,7 @@ for DataRepositoryInner<T, D>
|
||||
}
|
||||
let find = temp[cell];
|
||||
let remove = x.id() == find;
|
||||
if remove || find > x.id() {
|
||||
if remove {
|
||||
cell += 1;
|
||||
}
|
||||
!remove
|
||||
@@ -273,7 +277,7 @@ for DataRepositoryInner<T, D>
|
||||
}
|
||||
let find = cached[cell];
|
||||
let remove = x.id() == find;
|
||||
if remove || find > x.id() {
|
||||
if remove {
|
||||
cell += 1;
|
||||
}
|
||||
!remove
|
||||
|
||||
Reference in new issue
Block a user