Skip to content

Commit d8b7d9f

Browse files
authored
Merge pull request #161 from naomijub/issue-159
Issue 159
2 parents 7562e0e + 943307d commit d8b7d9f

File tree

14 files changed

+63
-30
lines changed

14 files changed

+63
-30
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ zstd = "0.6.0+zstd.1.4.8"
4242
bcrypt = "0.8"
4343
actix-web-httpauth = "0.5.0"
4444
serde_json = { version = "1.0", optional = true }
45+
bincode = "1.3"
4546

4647
[dev-dependencies]
4748
bytes = "1.0.1"

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ PORT=1438
8282
> 2,3 GHz Intel Core i9 8-Core 32 GB 2667 MHz DDR4
8383
8484
- `create_entity` time: [4.7008 ms 4.7367 ms 4.7725 ms]
85-
- `insert_entity` time: [9.5938 ms 9.8263 ms 10.057 ms]
86-
- `update_set_entity` time: [11.899 ms 11.984 ms 12.083 ms]
87-
- `update_content_entity` time: [12.048 ms 12.328 ms 12.719 ms]
85+
- `insert_entity` time: [12.647 ms 12.977 ms 13.308 ms]
86+
- `update_set_entity` time: [14.896 ms 15.087 ms 15.309 ms]
87+
- `update_content_entity` time: [14.871 ms 15.070 ms 15.307 ms]
8888
- `delete_entity` time: [5.3966 ms 5.4423 ms 5.4908 ms] - Filtered 400s
8989
- `evict_entity_id` time: [15.534 ms 15.623 ms 15.721 ms] - Filtered 400s
9090
- `evict_entity` time: [12.318 ms 12.416 ms 12.540 ms] - Filtered 400s
91-
- `select_all` 20 entities time: [5.8810 ms 5.9318 ms 5.9889 ms]
92-
- `select_all` 10 entities time: [5.4012 ms 5.4432 ms 5.4860 ms]
93-
- `select_all` 1 entity time: [4.8442 ms 4.8786 ms 4.9140 ms]
94-
- `history_10_registries_for_entity` time: [5.7265 ms 5.7868 ms 5.8673 ms]
95-
- `history_20_registries_for_entity` time: [6.1166 ms 6.1943 ms 6.2987 ms]
91+
- `select_all` 20 entities time: [6.3402 ms 6.4743 ms 6.6356 ms]
92+
- `select_all` 10 entities time: [5.8318 ms 5.9682 ms 6.1340 ms]
93+
- `select_all` 1 entity time: [5.1030 ms 5.1379 ms 5.1738 ms]
94+
- `history_10_registries_for_entity` time: [5.4936 ms 5.5328 ms 5.5725 ms]
95+
- `history_20_registries_for_entity` time: [6.0676 ms 6.1049 ms 6.1429 ms]
9696

9797
### WQL
9898
> 2,3 GHz Intel Core i9 8-Core 32 GB 2667 MHz DDR4

data/local_data.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"encrypt_ent": {},"encrypt_ent2": {},"hello": {"50e68bc1-0c3b-4ffc-93be-46e57f59b415": ((file_name: "2021_02_10.log",offset: 447,bytes_length: 153,), {},),},"oh_yeah": {"27367bd0-1966-4005-a8b5-5e323e1c3524": ((file_name: "2021_02_10.log",offset: 180,bytes_length: 247,), {}),},}
1+
{"encrypt_ent": {},"encrypt_ent2": {},"hello": {"50e68bc1-0c3b-4ffc-93be-46e57f59b415": ((file_name: "2021_02_10.log",offset: 447,bytes_length: 153,),[0, 0, 0, 0, 0, 0, 0, 0,],),},"oh_yeah": {"27367bd0-1966-4005-a8b5-5e323e1c3524": ((file_name: "2021_02_10.log",offset: 180,bytes_length: 247,), [0, 0, 0, 0, 0, 0, 0, 0,],),},}

woori-db/Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

woori-db/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ glob = "0.3.0"
3838
zstd = "0.6.0+zstd.1.4.8"
3939
bcrypt = "0.8"
4040
actix-web-httpauth = "0.5.0"
41+
bincode = "1.3"
4142

4243
[dev-dependencies]
4344
bytes = "1.0.1"

woori-db/data/local_data.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"encrypt_ent": {},"encrypt_ent2": {},"hello": {"50e68bc1-0c3b-4ffc-93be-46e57f59b415": ((file_name: "2021_02_10.log",offset: 447,bytes_length: 153,), {},),},"oh_yeah": {"27367bd0-1966-4005-a8b5-5e323e1c3524": ((file_name: "2021_02_10.log",offset: 180,bytes_length: 247,), {}),},}
1+
{"encrypt_ent": {},"encrypt_ent2": {},"hello": {"50e68bc1-0c3b-4ffc-93be-46e57f59b415": ((file_name: "2021_02_10.log",offset: 447,bytes_length: 153,), [0, 0, 0, 0, 0, 0, 0, 0,],),},"oh_yeah": {"27367bd0-1966-4005-a8b5-5e323e1c3524": ((file_name: "2021_02_10.log",offset: 180,bytes_length: 247,), [0, 0, 0, 0, 0, 0, 0, 0,],),},}

woori-db/src/actors/history.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ fn get_previous_registry(fractions: &[&str]) -> Result<Option<DataRegister>, Err
8484
.to_owned();
8585
let state = &state[..(state.len() - 1)];
8686

87-
let resp: Result<(DataRegister, HashMap<String, Types>), Error> = match ron::de::from_str(state)
88-
{
87+
let resp: Result<(DataRegister, Vec<u8>), Error> = match ron::de::from_str(state) {
8988
Ok(x) => Ok(x),
9089
Err(_) => Err(Error::FailedToParseRegistry),
9190
};

woori-db/src/controllers/clauses.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,12 @@ fn or_clauses(
229229
}
230230

231231
async fn generate_state(
232-
registries: &BTreeMap<Uuid, (DataRegister, HashMap<String, Types>)>,
232+
registries: &BTreeMap<Uuid, (DataRegister, Vec<u8>)>,
233233
args_to_select: ToSelect,
234234
) -> Result<BTreeMap<Uuid, HashMap<String, Types>>, Error> {
235235
let mut states: BTreeMap<Uuid, HashMap<String, Types>> = BTreeMap::new();
236236
for (uuid, (_, state)) in registries {
237+
let state: HashMap<String, Types> = bincode::deserialize(&state).unwrap();
237238
let state = state
238239
.into_par_iter()
239240
.filter(|(_, v)| !v.is_hash())

woori-db/src/controllers/query.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ pub async fn select_all_with_id(
295295
registry
296296
};
297297

298-
let state = registry.1;
298+
let state: HashMap<String, Types> = bincode::deserialize(&registry.1).unwrap();
299299
let filterd_state = filter_keys_and_hash(state, None);
300300
Ok(filterd_state.into())
301301
}
@@ -327,7 +327,7 @@ pub async fn select_all_with_ids(
327327
.filter(|(_id, reg)| reg.is_some())
328328
})
329329
.map(|(uuid, reg)| (uuid, reg.map(ToOwned::to_owned)))
330-
.collect::<Vec<(Uuid, Option<(DataRegister, HashMap<String, Types>)>)>>()
330+
.collect::<Vec<(Uuid, Option<(DataRegister, Vec<u8>)>)>>()
331331
} else {
332332
return Err(Error::EntityNotCreated(entity));
333333
};
@@ -337,6 +337,7 @@ pub async fn select_all_with_ids(
337337
let mut states: BTreeMap<Uuid, Option<HashMap<String, Types>>> = BTreeMap::new();
338338
for (uuid, registry) in registries.into_iter().skip(offset).take(limit) {
339339
if let Some((_, state)) = registry {
340+
let state: HashMap<String, Types> = bincode::deserialize(&state).unwrap();
340341
let filtered = filter_keys_and_hash(state, None);
341342
states.insert(uuid, Some(filtered));
342343
} else {
@@ -377,7 +378,7 @@ pub async fn select_keys_with_id(
377378
registry
378379
};
379380

380-
let state = registry.1;
381+
let state: HashMap<String, Types> = bincode::deserialize(&registry.1).unwrap();
381382
let filtered = filter_keys_and_hash(state, Some(keys));
382383
Ok(filtered.into())
383384
}
@@ -411,7 +412,7 @@ pub async fn select_keys_with_ids(
411412
.filter(|(_id, reg)| reg.is_some())
412413
})
413414
.map(|(uuid, reg)| (uuid, reg.map(ToOwned::to_owned)))
414-
.collect::<Vec<(Uuid, Option<(DataRegister, HashMap<String, Types>)>)>>()
415+
.collect::<Vec<(Uuid, Option<(DataRegister, Vec<u8>)>)>>()
415416
} else {
416417
return Err(Error::EntityNotCreated(entity));
417418
};
@@ -421,6 +422,7 @@ pub async fn select_keys_with_ids(
421422
let mut states: BTreeMap<Uuid, Option<HashMap<String, Types>>> = BTreeMap::new();
422423
for (uuid, registry) in registries.into_iter().skip(offset).take(limit) {
423424
if let Some((_, state)) = registry {
425+
let state: HashMap<String, Types> = bincode::deserialize(&state).unwrap();
424426
let filtered = filter_keys_and_hash(state, Some(keys.clone()));
425427
states.insert(uuid, Some(filtered));
426428
} else {

0 commit comments

Comments
 (0)